modulift 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modulift/__init__.py +3 -0
- modulift/api.py +196 -0
- modulift/data.py +6 -0
- modulift-0.0.1.dist-info/METADATA +197 -0
- modulift-0.0.1.dist-info/RECORD +7 -0
- modulift-0.0.1.dist-info/WHEEL +5 -0
- modulift-0.0.1.dist-info/top_level.txt +1 -0
modulift/__init__.py
ADDED
modulift/api.py
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from typing import List, Optional, Union
|
|
3
|
+
from .data import load_data
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def search_by_keywords(*args: str, relation: str = "or", limit: Optional[int] = None, markdown: bool = False) -> List[dict]:
|
|
7
|
+
"""
|
|
8
|
+
Search for keywords in the 'keywords' column with a specified relation ('or' or 'and') and optional limit on results.
|
|
9
|
+
|
|
10
|
+
Parameters:
|
|
11
|
+
*args (str): Keywords to search for in the 'keywords' column.
|
|
12
|
+
relation (str, optional): Defines the logical relationship for keyword matching.
|
|
13
|
+
Use "or" for matching any keyword, and "and" for matching all keywords.
|
|
14
|
+
Defaults to "or".
|
|
15
|
+
limit (int, optional): The maximum number of results to return. Defaults to None, which returns all matches.
|
|
16
|
+
markdown (bool, optional): If True, prints the results in markdown format. Defaults to False.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
List[dict]: A list of dictionaries with 'package', 'description', 'keywords', and 'popularity' fields
|
|
20
|
+
for each row that matches the search criteria, sorted by 'popularity' in the specified order.
|
|
21
|
+
|
|
22
|
+
Notes:
|
|
23
|
+
- The 'popularity' column is sorted in the order ['very popular', 'popular', 'not popular'].
|
|
24
|
+
- Markdown output is only printed and does not affect the returned result structure.
|
|
25
|
+
|
|
26
|
+
Example:
|
|
27
|
+
>>> search_by_keywords("machine learning", "data science", relation="and", limit=5, markdown=True)
|
|
28
|
+
[
|
|
29
|
+
{
|
|
30
|
+
'package': 'example-package',
|
|
31
|
+
'description': 'An example package for machine learning.',
|
|
32
|
+
'keywords': 'machine learning, data science, AI',
|
|
33
|
+
'popularity': 'very popular'
|
|
34
|
+
},
|
|
35
|
+
...
|
|
36
|
+
]
|
|
37
|
+
"""
|
|
38
|
+
# Validate and normalize inputs
|
|
39
|
+
if not args:
|
|
40
|
+
raise ValueError("At least one keyword must be provided for search.")
|
|
41
|
+
|
|
42
|
+
if relation not in {"or", "and"}:
|
|
43
|
+
raise ValueError("The 'relation' parameter must be either 'or' or 'and'.")
|
|
44
|
+
|
|
45
|
+
if limit is not None and (not isinstance(limit, int) or limit <= 0):
|
|
46
|
+
raise ValueError("The 'limit' parameter must be a positive integer if specified.")
|
|
47
|
+
|
|
48
|
+
# Load the DataFrame
|
|
49
|
+
df = load_data()
|
|
50
|
+
|
|
51
|
+
# Convert the input keywords to a list
|
|
52
|
+
keywords = list(args)
|
|
53
|
+
|
|
54
|
+
# Define the boolean mask based on 'or' or 'and' logic
|
|
55
|
+
if relation == "and":
|
|
56
|
+
mask = df['keywords'].apply(lambda cell: all(keyword.lower() in str(cell).lower() for keyword in keywords))
|
|
57
|
+
else: # default to 'or' logic
|
|
58
|
+
mask = df['keywords'].apply(lambda cell: any(keyword.lower() in str(cell).lower() for keyword in keywords))
|
|
59
|
+
|
|
60
|
+
# Filter the DataFrame with matching rows and select required columns
|
|
61
|
+
result_df = df[mask][['package', 'description', 'keywords', 'popularity']]
|
|
62
|
+
|
|
63
|
+
# Define a custom order for sorting popularity
|
|
64
|
+
popularity_order = ['very popular', 'popular', 'not popular']
|
|
65
|
+
|
|
66
|
+
# Sort the DataFrame by 'POPULARITY' based on the defined order
|
|
67
|
+
result_df['popularity'] = pd.Categorical(result_df['popularity'], categories=popularity_order, ordered=True)
|
|
68
|
+
result_df = result_df.sort_values('popularity')
|
|
69
|
+
|
|
70
|
+
# Apply limit if specified
|
|
71
|
+
if limit is not None:
|
|
72
|
+
result_df = result_df.head(limit)
|
|
73
|
+
|
|
74
|
+
# Convert to a list of dictionaries
|
|
75
|
+
results = result_df.to_dict(orient='records')
|
|
76
|
+
|
|
77
|
+
# Print in markdown format if markdown is True
|
|
78
|
+
if markdown:
|
|
79
|
+
for i, row in enumerate(results, 1):
|
|
80
|
+
print(f"**{i}. {row['package']}**")
|
|
81
|
+
print(f"- **Description**: {row['description']}")
|
|
82
|
+
print(f"- **Keywords**: {row['keywords']}")
|
|
83
|
+
print(f"- **Popularity**: {row['popularity']}")
|
|
84
|
+
print("\n---\n")
|
|
85
|
+
|
|
86
|
+
return results
|
|
87
|
+
|
|
88
|
+
def search_by_package_name(package_name: str, markdown: bool = False) -> Optional[dict]:
|
|
89
|
+
"""
|
|
90
|
+
Search for an exact package name in the 'package' column of the DataFrame.
|
|
91
|
+
|
|
92
|
+
Parameters:
|
|
93
|
+
package_name (str): The exact package name to search for.
|
|
94
|
+
markdown (bool, optional): If True, prints the result in markdown format. Defaults to False.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
Optional[dict]: A dictionary with 'package', 'description', 'keywords', and 'popularity' fields if a match is found;
|
|
98
|
+
otherwise, returns None.
|
|
99
|
+
|
|
100
|
+
Example:
|
|
101
|
+
>>> search_by_package_name("example-package", markdown=True)
|
|
102
|
+
{
|
|
103
|
+
'package': 'example-package',
|
|
104
|
+
'description': 'An example package for data processing.',
|
|
105
|
+
'keywords': 'data processing, analysis, example',
|
|
106
|
+
'popularity': 'very popular'
|
|
107
|
+
}
|
|
108
|
+
"""
|
|
109
|
+
if not isinstance(package_name, str) or not package_name.strip():
|
|
110
|
+
raise ValueError("The 'package_name' parameter must be a non-empty string.")
|
|
111
|
+
|
|
112
|
+
# Load the DataFrame
|
|
113
|
+
df = load_data()
|
|
114
|
+
|
|
115
|
+
# Perform exact match search in the 'package' column
|
|
116
|
+
result_df = df[df['package'] == package_name][['package', 'description', 'keywords', 'popularity']]
|
|
117
|
+
|
|
118
|
+
# Check if there is a match
|
|
119
|
+
if not result_df.empty:
|
|
120
|
+
result = result_df.iloc[0].to_dict()
|
|
121
|
+
|
|
122
|
+
# Print in markdown format if markdown is True
|
|
123
|
+
if markdown:
|
|
124
|
+
print(f"**Package**: {result['package']}")
|
|
125
|
+
print(f"- **Description**: {result['description']}")
|
|
126
|
+
print(f"- **Keywords**: {result['keywords']}")
|
|
127
|
+
print(f"- **Popularity**: {result['popularity']}")
|
|
128
|
+
print("\n---\n")
|
|
129
|
+
|
|
130
|
+
return result
|
|
131
|
+
else:
|
|
132
|
+
if markdown:
|
|
133
|
+
print(f"No match found for package name '{package_name}'.")
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def search_by_description(text: str, limit: Optional[int] = None, markdown: bool = False) -> List[dict]:
|
|
138
|
+
"""
|
|
139
|
+
Perform a full-text search in the 'description' column for a specific text, with an optional limit and markdown output.
|
|
140
|
+
|
|
141
|
+
Parameters:
|
|
142
|
+
text (str): The text to search for in the 'description' column.
|
|
143
|
+
limit (int, optional): The maximum number of results to return. Defaults to None, which returns all matches.
|
|
144
|
+
markdown (bool, optional): If True, prints the results in markdown format. Defaults to False.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
List[dict]: A list of dictionaries with 'package', 'description', 'keywords', and 'popularity' fields
|
|
148
|
+
for rows where the 'description' column contains the search text, limited by 'limit' if specified.
|
|
149
|
+
|
|
150
|
+
Example:
|
|
151
|
+
>>> search_by_description("data analysis", limit=5, markdown=True)
|
|
152
|
+
[
|
|
153
|
+
{
|
|
154
|
+
'package': 'example-package',
|
|
155
|
+
'description': 'A package for data analysis and visualization.',
|
|
156
|
+
'keywords': 'data, analysis, visualization',
|
|
157
|
+
'popularity': 'very popular'
|
|
158
|
+
},
|
|
159
|
+
...
|
|
160
|
+
]
|
|
161
|
+
"""
|
|
162
|
+
# Validate 'text' input
|
|
163
|
+
if not isinstance(text, str) or not text.strip():
|
|
164
|
+
raise ValueError("The 'text' parameter must be a non-empty string.")
|
|
165
|
+
|
|
166
|
+
# Validate 'limit' parameter
|
|
167
|
+
if limit is not None and (not isinstance(limit, int) or limit <= 0):
|
|
168
|
+
raise ValueError("The 'limit' parameter must be a positive integer if specified.")
|
|
169
|
+
|
|
170
|
+
# Load the DataFrame
|
|
171
|
+
df = load_data()
|
|
172
|
+
|
|
173
|
+
# Perform case-insensitive full-text search in the 'description' column
|
|
174
|
+
mask = df['description'].str.contains(text, case=False, na=False)
|
|
175
|
+
|
|
176
|
+
# Filter the DataFrame with matching rows and select required columns
|
|
177
|
+
result_df = df[mask][['package', 'description', 'keywords', 'popularity']]
|
|
178
|
+
|
|
179
|
+
# Apply limit if specified
|
|
180
|
+
if limit is not None:
|
|
181
|
+
result_df = result_df.head(limit)
|
|
182
|
+
|
|
183
|
+
# Convert to a list of dictionaries
|
|
184
|
+
results = result_df.to_dict(orient='records')
|
|
185
|
+
|
|
186
|
+
# Print in markdown format if markdown is True
|
|
187
|
+
if markdown:
|
|
188
|
+
for i, row in enumerate(results, 1):
|
|
189
|
+
print(f"**{i}. {row['package']}**")
|
|
190
|
+
print(f"- **Description**: {row['description']}")
|
|
191
|
+
print(f"- **Keywords**: {row['keywords']}")
|
|
192
|
+
print(f"- **Popularity**: {row['popularity']}")
|
|
193
|
+
print("\n---\n")
|
|
194
|
+
else:
|
|
195
|
+
print(f"No matches found for the text '{text}'.")
|
|
196
|
+
return results
|
modulift/data.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: modulift
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A powerful search tool for discovering Python packages based on user queries
|
|
5
|
+
Home-page: https://github.com/okanyenigun/modulift
|
|
6
|
+
Author: Okan Yenigün
|
|
7
|
+
Author-email: okanyenigun@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Intended Audience :: Information Technology
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Requires-Python: >=3.7
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Requires-Dist: datasets==3.1.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: twine==5.1.1; extra == "dev"
|
|
30
|
+
Provides-Extra: test
|
|
31
|
+
Requires-Dist: pytest==8.2.2; extra == "test"
|
|
32
|
+
|
|
33
|
+
# Modulift
|
|
34
|
+
|
|
35
|
+
**Modulift** is a powerful and efficient Python package designed to help developers, data scientists, and researchers explore and discover Python packages on PyPI based on specific keywords, package names, or full-text search within package descriptions. With a comprehensive dataset of PyPI packages, Modulift allows you to find relevant libraries for your project needs, making it an invaluable tool for anyone looking to streamline package selection and integration.
|
|
36
|
+
|
|
37
|
+
## Key Features
|
|
38
|
+
|
|
39
|
+
- **Exact Package Name Search**: Retrieve detailed information on a specific package by name.
|
|
40
|
+
- **Keyword-Based Search**: Search packages by multiple keywords with flexible "or" and "and" logic to refine results.
|
|
41
|
+
- **Full-Text Description Search**: Locate packages by searching for specific phrases or content in their descriptions.
|
|
42
|
+
- **Markdown Output Option**: Print search results in Markdown format, ideal for documentation or presentations.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
Install Modulift via pip:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install modulift
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
Modulift provides an easy-to-use API for searching and exploring Python packages. Here’s a quick guide on how to use its core features.
|
|
55
|
+
|
|
56
|
+
### 1. Search by Package Name
|
|
57
|
+
|
|
58
|
+
Retrieve detailed information for a specific package by name:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import modulift as mf
|
|
62
|
+
|
|
63
|
+
result = mf.search_by_package_name("numpy")
|
|
64
|
+
print(result)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Output**:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
{
|
|
71
|
+
'package': 'numpy',
|
|
72
|
+
'description': 'NumPy is the fundamental package for scientific computing with Python. It provides powerful N-dimensional arrays, sophisticated mathematical functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.',
|
|
73
|
+
'keywords': 'scientific computing, array, linear algebra, Fourier transform, random number generation, data processing, numerical analysis',
|
|
74
|
+
'popularity': 'very popular'
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For a different package:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
result = mf.search_by_package_name("nullsweep")
|
|
82
|
+
print(result)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Output**:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
{
|
|
89
|
+
'package': 'nullsweep',
|
|
90
|
+
'description': 'NullSweep is a Python library designed for detecting and handling patterns of missing data in pandas DataFrames. It provides a simple API to identify global missing data patterns across the entire dataset, patterns related to specific features within the dataset, and to impute missing values using various strategies.',
|
|
91
|
+
'keywords': 'missing data, data imputation, pandas, pattern detection, feature-specific patterns',
|
|
92
|
+
'popularity': 'popular'
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Markdown Output
|
|
97
|
+
To display the result in Markdown format:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
result = mf.search_by_package_name("numpy", markdown=True)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Package**: numpy
|
|
104
|
+
|
|
105
|
+
- **Description**: NumPy is the fundamental package for scientific computing with Python. It provides powerful N-dimensional arrays, sophisticated mathematical functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.
|
|
106
|
+
- **Keywords**: scientific computing, array, linear algebra, Fourier transform, random number generation, data processing, numerical analysis
|
|
107
|
+
- **Popularity**: very popular
|
|
108
|
+
|
|
109
|
+
### 2. Search by Keywords
|
|
110
|
+
|
|
111
|
+
Search for packages using one or more keywords. Modulift supports both "or" and "and" relations.
|
|
112
|
+
|
|
113
|
+
Single Keyword Search
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
result = mf.search_by_keywords("data science")
|
|
117
|
+
print(len(result))
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Output:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
3141 # Number of packages related to "data science"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Multi-Keyword Search with "and" Relation
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
result = mf.search_by_keywords("data science", "machine learning", "deep learning", relation="and")
|
|
130
|
+
print(len(result))
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Output:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
115 # Number of packages related to all three keywords
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Limiting Results with Markdown Output
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
result = mf.search_by_keywords("data science", "machine learning", "deep learning", relation="and", limit=3, markdown=True)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Markdown Output
|
|
146
|
+
|
|
147
|
+
**1. sagemaker**
|
|
148
|
+
|
|
149
|
+
- **Description**: The SageMaker Python SDK is an open-source library designed for training and deploying machine learning models on Amazon SageMaker. It supports popular deep learning frameworks like Apache MXNet and TensorFlow, as well as Amazon's own scalable algorithms optimized for SageMaker. Users can also deploy custom algorithms in Docker containers, making it versatile for various machine learning tasks.
|
|
150
|
+
- **Keywords**: machine learning, deep learning, model deployment, Amazon SageMaker, data science, AI, Docker
|
|
151
|
+
- **Popularity**: very popular
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
**2. fastbook**
|
|
156
|
+
|
|
157
|
+
- **Description**: fastbook is a comprehensive resource for learning deep learning through practical coding examples using the fastai library and PyTorch. It is designed for coders of all backgrounds, providing accessible education on deep learning techniques and applications across various domains, including computer vision and natural language processing.
|
|
158
|
+
- **Keywords**: deep learning, fastai, PyTorch, computer vision, natural language processing, machine learning, data science, Jupyter Notebooks
|
|
159
|
+
- **Popularity**: very popular
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
**3. ProAiLab**
|
|
164
|
+
|
|
165
|
+
- **Description**: ProAiLab is a Python library designed for building and deploying AI models. It provides tools for data preprocessing, model training, and evaluation, making it suitable for both beginners and experienced machine learning practitioners.
|
|
166
|
+
- **Keywords**: machine learning, AI, deep learning, data science, model development
|
|
167
|
+
- **Popularity**: popular
|
|
168
|
+
|
|
169
|
+
### 3. Full-Text Search in Descriptions
|
|
170
|
+
|
|
171
|
+
Search for packages based on specific phrases within the description.
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
result = mf.search_by_description("training and deploying machine learning models on Amazon", markdown=True)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Markdown Output
|
|
178
|
+
|
|
179
|
+
**1. sagemaker**
|
|
180
|
+
|
|
181
|
+
- **Description**: The SageMaker Python SDK is an open-source library designed for training and deploying machine learning models on Amazon SageMaker. It supports popular deep learning frameworks like Apache MXNet and TensorFlow, as well as Amazon's own scalable algorithms optimized for SageMaker. Users can also deploy custom algorithms in Docker containers, making it versatile for various machine learning tasks.
|
|
182
|
+
- **Keywords**: machine learning, deep learning, model deployment, Amazon SageMaker, data science, AI, Docker
|
|
183
|
+
- **Popularity**: very popular
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
Modulift is licensed under the MIT License. See [LICENSE](Licence.md) for more details.
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
We welcome contributions to Modulift! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
192
|
+
|
|
193
|
+
## Contact
|
|
194
|
+
|
|
195
|
+
For any questions or feedback, please contact the author:
|
|
196
|
+
|
|
197
|
+
- **Okan Yenigün** - [okanyenigun@gmail.com](mailto:okanyenigun@gmail.com)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
modulift/__init__.py,sha256=CdQMLTINFPRegM1vrC37PMBD9MlHD1PBcSh1lDigJRY,41
|
|
2
|
+
modulift/api.py,sha256=uaXLpJcHddumDWD24uMNtmWYaC-MdxkQMeu0XFPc424,8073
|
|
3
|
+
modulift/data.py,sha256=DOQKk42KXckZSRi9shvTdfiL8m0UzqsTjY-r9PfNLGo,147
|
|
4
|
+
modulift-0.0.1.dist-info/METADATA,sha256=zL3Ynj_X-laQ8IEXbR7hPMv3JxUjVJ2Vg3QoRNQavrI,7952
|
|
5
|
+
modulift-0.0.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
6
|
+
modulift-0.0.1.dist-info/top_level.txt,sha256=BKhbSkUIGpGgZJtDObR81O3ECUVZGwGQkIPdxbihzFc,9
|
|
7
|
+
modulift-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
modulift
|