easyreqtxt 0.1.0__tar.gz
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.
- easyreqtxt-0.1.0/.github/workflows/python-publish.yml +53 -0
- easyreqtxt-0.1.0/.gitignore +7 -0
- easyreqtxt-0.1.0/.python-version +1 -0
- easyreqtxt-0.1.0/LICENSE +24 -0
- easyreqtxt-0.1.0/PKG-INFO +86 -0
- easyreqtxt-0.1.0/README.md +78 -0
- easyreqtxt-0.1.0/pyproject.toml +13 -0
- easyreqtxt-0.1.0/src/easyreqtxt/__init__.py +0 -0
- easyreqtxt-0.1.0/src/easyreqtxt/main.py +124 -0
- easyreqtxt-0.1.0/test.py +3 -0
- easyreqtxt-0.1.0/test_project/module_a/api_client.py +19 -0
- easyreqtxt-0.1.0/test_project/module_a/data_model.py +14 -0
- easyreqtxt-0.1.0/test_project/module_a/notes.txt +3 -0
- easyreqtxt-0.1.0/test_project/module_b/image_tools.py +18 -0
- easyreqtxt-0.1.0/test_project/module_b/plotting.py +15 -0
- easyreqtxt-0.1.0/test_project/module_b/readme.txt +2 -0
- easyreqtxt-0.1.0/test_project/module_c/async_client.py +22 -0
- easyreqtxt-0.1.0/test_project/module_c/web_app.py +20 -0
- easyreqtxt-0.1.0/test_project/scripts/config.txt +3 -0
- easyreqtxt-0.1.0/test_project/scripts/run_pipeline.py +16 -0
- easyreqtxt-0.1.0/test_project/utils/helpers.py +22 -0
- easyreqtxt-0.1.0/test_project/utils/log.txt +3 -0
- easyreqtxt-0.1.0/test_project/utils/testing.py +16 -0
- easyreqtxt-0.1.0/uv.lock +13 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
release-build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.14"
|
|
20
|
+
|
|
21
|
+
- name: Build release distributions
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install build
|
|
24
|
+
python -m build
|
|
25
|
+
|
|
26
|
+
- name: Upload distributions
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: release-dists
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
pypi-publish:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
needs:
|
|
35
|
+
- release-build
|
|
36
|
+
permissions:
|
|
37
|
+
id-token: write
|
|
38
|
+
|
|
39
|
+
environment:
|
|
40
|
+
name: pypi
|
|
41
|
+
url: https://pypi.org/project/easyreqtxt/
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Retrieve release distributions
|
|
45
|
+
uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: release-dists
|
|
48
|
+
path: dist/
|
|
49
|
+
|
|
50
|
+
- name: Publish release distributions to PyPI
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
52
|
+
with:
|
|
53
|
+
packages-dir: dist/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
easyreqtxt-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: easyreqtxt
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Easily make requirements.txt files for entire python projects.
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.14
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# easyreqtxt
|
|
10
|
+
|
|
11
|
+
A Python command-line tool that creates `requirements.txt` files by scanning a Python project for its imports.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Clone the repository:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/cayrrs/easyreqtxt.git
|
|
19
|
+
cd easyreqtxt
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Install easyreqtxt:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Provide the directory you want to scan:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
easyreqtxt <folder>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For example:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
easyreqtxt .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This recursively scans the directory for Python files and creates a `requirements.txt` file.
|
|
43
|
+
|
|
44
|
+
### Custom Output File
|
|
45
|
+
|
|
46
|
+
Use `-o` or `--output` to specify a different output file:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
easyreqtxt . -o requirements-dev.txt
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How It Works
|
|
53
|
+
|
|
54
|
+
easyreqtxt:
|
|
55
|
+
|
|
56
|
+
1. Recursively finds Python files in the specified directory.
|
|
57
|
+
2. Finds imported modules using Python's AST parser.
|
|
58
|
+
3. Ignores Python standard-library modules.
|
|
59
|
+
4. Resolves imported modules to installed packages.
|
|
60
|
+
5. Retrieves the installed package versions.
|
|
61
|
+
6. Writes the dependencies to the output file.
|
|
62
|
+
|
|
63
|
+
For example, a project containing:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import requests
|
|
67
|
+
import numpy
|
|
68
|
+
import json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
could produce:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
requests==2.32.5
|
|
75
|
+
numpy==2.3.3
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The `json` module is excluded because it is part of Python's standard library.
|
|
79
|
+
|
|
80
|
+
## Requirements
|
|
81
|
+
|
|
82
|
+
Python 3.14 or newer.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
This project is licensed under the Unlicense (do whatever you want) License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# easyreqtxt
|
|
2
|
+
|
|
3
|
+
A Python command-line tool that creates `requirements.txt` files by scanning a Python project for its imports.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Clone the repository:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/cayrrs/easyreqtxt.git
|
|
11
|
+
cd easyreqtxt
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Install easyreqtxt:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install -e .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Provide the directory you want to scan:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
easyreqtxt <folder>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
easyreqtxt .
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This recursively scans the directory for Python files and creates a `requirements.txt` file.
|
|
35
|
+
|
|
36
|
+
### Custom Output File
|
|
37
|
+
|
|
38
|
+
Use `-o` or `--output` to specify a different output file:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
easyreqtxt . -o requirements-dev.txt
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## How It Works
|
|
45
|
+
|
|
46
|
+
easyreqtxt:
|
|
47
|
+
|
|
48
|
+
1. Recursively finds Python files in the specified directory.
|
|
49
|
+
2. Finds imported modules using Python's AST parser.
|
|
50
|
+
3. Ignores Python standard-library modules.
|
|
51
|
+
4. Resolves imported modules to installed packages.
|
|
52
|
+
5. Retrieves the installed package versions.
|
|
53
|
+
6. Writes the dependencies to the output file.
|
|
54
|
+
|
|
55
|
+
For example, a project containing:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import requests
|
|
59
|
+
import numpy
|
|
60
|
+
import json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
could produce:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
requests==2.32.5
|
|
67
|
+
numpy==2.3.3
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The `json` module is excluded because it is part of Python's standard library.
|
|
71
|
+
|
|
72
|
+
## Requirements
|
|
73
|
+
|
|
74
|
+
Python 3.14 or newer.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
This project is licensed under the Unlicense (do whatever you want) License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "easyreqtxt"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Easily make requirements.txt files for entire python projects."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
|
|
8
|
+
[project.scripts]
|
|
9
|
+
easyreqtxt = "easyreqtxt.main:main"
|
|
10
|
+
|
|
11
|
+
[build-system]
|
|
12
|
+
requires = ["hatchling"]
|
|
13
|
+
build-backend = "hatchling.build"
|
|
File without changes
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import importlib.metadata
|
|
2
|
+
import ast
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import argparse
|
|
7
|
+
|
|
8
|
+
package_map = importlib.metadata.packages_distributions()
|
|
9
|
+
|
|
10
|
+
logging.basicConfig(
|
|
11
|
+
level=logging.INFO,
|
|
12
|
+
format="%(levelname)s: %(message)s"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
modules = []
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def parse_args():
|
|
22
|
+
parser = argparse.ArgumentParser(
|
|
23
|
+
description="Scan a folder for Python imports and resolve their versions, and output them to a requirements.txt"
|
|
24
|
+
)
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"folder",
|
|
27
|
+
type=str,
|
|
28
|
+
help="Path to the folder to scan."
|
|
29
|
+
)
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
"-o", "--output",
|
|
32
|
+
type=str,
|
|
33
|
+
default="requirements.txt",
|
|
34
|
+
help="Output filename (default: requirements.txt)"
|
|
35
|
+
)
|
|
36
|
+
return parser.parse_args()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def walkfile(filepath: Path):
|
|
41
|
+
filename = filepath.name
|
|
42
|
+
module_names = []
|
|
43
|
+
logger.info(f"Beginning walk on {filename}")
|
|
44
|
+
with open(filepath, 'r',encoding='utf-8') as f:
|
|
45
|
+
source = f.read()
|
|
46
|
+
tree = ast.parse(source)
|
|
47
|
+
walk = (ast.walk(tree))
|
|
48
|
+
for node in walk:
|
|
49
|
+
if isinstance(node, ast.Import):
|
|
50
|
+
for alias in node.names:
|
|
51
|
+
nm = alias.name.split(".")[0]
|
|
52
|
+
if nm in module_names:
|
|
53
|
+
continue
|
|
54
|
+
module_names.append(nm)
|
|
55
|
+
logger.info(f"Found {nm} in {filename}")
|
|
56
|
+
else:
|
|
57
|
+
if isinstance(node, ast.ImportFrom):
|
|
58
|
+
name = node.module.split(".")[0]
|
|
59
|
+
if name in module_names:
|
|
60
|
+
continue
|
|
61
|
+
module_names.append(name)
|
|
62
|
+
logger.info(f"Found {name} in {filename}")
|
|
63
|
+
|
|
64
|
+
logger.info(f"Finished dependency walk on {filename}!")
|
|
65
|
+
logger.info(f"Beginning dist name corrections")
|
|
66
|
+
for module in module_names:
|
|
67
|
+
if module in sys.stdlib_module_names:
|
|
68
|
+
logger.info(f"Skipping baselib module: {module}")
|
|
69
|
+
continue
|
|
70
|
+
if module in package_map:
|
|
71
|
+
distnames = package_map[module]
|
|
72
|
+
if len(distnames) > 1:
|
|
73
|
+
logger.warning(f"Module {module} maps to multiple packages. I shall use the first one.")
|
|
74
|
+
distname = distnames[0]
|
|
75
|
+
logger.debug(f"{module} -> {distname}")
|
|
76
|
+
if any(distname in m for m in modules):
|
|
77
|
+
logger.info(f"Skipping repeated module: {distname}")
|
|
78
|
+
continue
|
|
79
|
+
try:
|
|
80
|
+
version = importlib.metadata.version(distname)
|
|
81
|
+
except importlib.metadata.PackageNotFoundError as e:
|
|
82
|
+
logging.warning(f"Unable to obtain a version for module {module}. Reason: {e}")
|
|
83
|
+
version = None
|
|
84
|
+
|
|
85
|
+
modules.append({distname: version})
|
|
86
|
+
else:
|
|
87
|
+
if any(module in m for m in modules):
|
|
88
|
+
logger.info(f"Skipping repeated module: {module}")
|
|
89
|
+
continue
|
|
90
|
+
try:
|
|
91
|
+
version = importlib.metadata.version(module)
|
|
92
|
+
except importlib.metadata.PackageNotFoundError as e:
|
|
93
|
+
logging.warning(f"Unable to obtain a version for module {module}. Reason: {e}. Version number will equal None. This can happen if the module isn't installed.")
|
|
94
|
+
version = None
|
|
95
|
+
modules.append({module: version})
|
|
96
|
+
|
|
97
|
+
logger.info(f"Walk of file {filename} finished!")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def output(filename: str):
|
|
102
|
+
with open(filename, 'w', encoding='utf-8') as f:
|
|
103
|
+
for m in modules:
|
|
104
|
+
for name, ver in m.items():
|
|
105
|
+
if ver == None:
|
|
106
|
+
string = f"{name}"
|
|
107
|
+
else:
|
|
108
|
+
string = f"{name}=={ver}"
|
|
109
|
+
f.write(string + "\n")
|
|
110
|
+
logger.info(f"Outputted depedency list at {filename}")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def main():
|
|
114
|
+
args = parse_args()
|
|
115
|
+
for f in Path(args.folder).rglob("*.py"):
|
|
116
|
+
walkfile(f)
|
|
117
|
+
output(args.output)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
main()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
easyreqtxt-0.1.0/test.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import requests, PIL
|
|
2
|
+
import json
|
|
3
|
+
from bs4 import BeautifulSoup
|
|
4
|
+
import yaml
|
|
5
|
+
from dotenv import load_dotenv
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def fetch_page(url):
|
|
12
|
+
response = requests.get(url)
|
|
13
|
+
soup = BeautifulSoup(response.text, "html.parser")
|
|
14
|
+
return soup.title.string
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def load_config(path):
|
|
18
|
+
with open(path) as f:
|
|
19
|
+
return yaml.safe_load(f)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
import sqlalchemy
|
|
3
|
+
from sqlalchemy.orm import sessionmaker
|
|
4
|
+
import datetime
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class User(BaseModel):
|
|
8
|
+
id: int
|
|
9
|
+
name: str
|
|
10
|
+
created_at: datetime.datetime
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
engine = sqlalchemy.create_engine("sqlite:///test.db")
|
|
14
|
+
Session = sessionmaker(bind=engine)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from PIL import Image, ImageFilter
|
|
2
|
+
import cv2
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def load_and_blur(path):
|
|
9
|
+
img = Image.open(path)
|
|
10
|
+
return img.filter(ImageFilter.BLUR)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def load_with_opencv(path):
|
|
14
|
+
return cv2.imread(path)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def to_array(img):
|
|
18
|
+
return np.array(img)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
from pprint import pprint
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def plot_dataframe(df):
|
|
8
|
+
fig, ax = plt.subplots()
|
|
9
|
+
ax.plot(df["x"], df["y"])
|
|
10
|
+
return fig
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def summarize(df):
|
|
14
|
+
pprint(df.describe())
|
|
15
|
+
return np.mean(df["y"])
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import aiohttp
|
|
2
|
+
import asyncio
|
|
3
|
+
import redis
|
|
4
|
+
import boto3
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def fetch_all(urls):
|
|
9
|
+
async with aiohttp.ClientSession() as session:
|
|
10
|
+
results = []
|
|
11
|
+
for url in tqdm(urls):
|
|
12
|
+
async with session.get(url) as resp:
|
|
13
|
+
results.append(await resp.text())
|
|
14
|
+
return results
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_redis_client():
|
|
18
|
+
return redis.Redis(host="localhost", port=6379)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_s3_client():
|
|
22
|
+
return boto3.client("s3")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from flask import Flask, jsonify
|
|
2
|
+
import click
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
from rich.table import Table
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
app = Flask(__name__)
|
|
8
|
+
console = Console()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.route("/status")
|
|
12
|
+
def status():
|
|
13
|
+
return jsonify({"status": "ok"})
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.command()
|
|
17
|
+
@click.option("--port", default=5000)
|
|
18
|
+
def run(port):
|
|
19
|
+
console.print(f"Starting server on port {port}")
|
|
20
|
+
app.run(port=port)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from sklearn.linear_model import LinearRegression
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
import numpy as np
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
load_dotenv()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def train_model(csv_path):
|
|
11
|
+
df = pd.read_csv(csv_path)
|
|
12
|
+
model = LinearRegression()
|
|
13
|
+
X = np.array(df[["x"]])
|
|
14
|
+
y = np.array(df["y"])
|
|
15
|
+
model.fit(X, y)
|
|
16
|
+
return model
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
import numpy as np
|
|
6
|
+
import requests
|
|
7
|
+
from pydantic import BaseModel
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def safe_request(url):
|
|
14
|
+
try:
|
|
15
|
+
return requests.get(url, timeout=5)
|
|
16
|
+
except requests.exceptions.RequestException as e:
|
|
17
|
+
logger.error(f"Request failed: {e}")
|
|
18
|
+
return None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Config(BaseModel):
|
|
22
|
+
debug: bool = False
|
easyreqtxt-0.1.0/uv.lock
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
revision = 3
|
|
3
|
+
requires-python = ">=3.14"
|
|
4
|
+
resolution-markers = [
|
|
5
|
+
"sys_platform == 'win32'",
|
|
6
|
+
"sys_platform == 'emscripten'",
|
|
7
|
+
"sys_platform != 'emscripten' and sys_platform != 'win32'",
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
[[package]]
|
|
11
|
+
name = "easyreqtxt"
|
|
12
|
+
version = "0.1.0"
|
|
13
|
+
source = { editable = "." }
|