pam-python 0.2.6__py3-none-any.whl → 0.2.8__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.
- pam/__init__.py +1 -1
- pam/cli.py +29 -49
- pam/templates/project/uv/Dockerfile +1 -1
- {pam_python-0.2.6.dist-info → pam_python-0.2.8.dist-info}/METADATA +4 -4
- {pam_python-0.2.6.dist-info → pam_python-0.2.8.dist-info}/RECORD +9 -9
- {pam_python-0.2.6.dist-info → pam_python-0.2.8.dist-info}/WHEEL +0 -0
- {pam_python-0.2.6.dist-info → pam_python-0.2.8.dist-info}/entry_points.txt +0 -0
- {pam_python-0.2.6.dist-info → pam_python-0.2.8.dist-info}/licenses/LICENSE.txt +0 -0
- {pam_python-0.2.6.dist-info → pam_python-0.2.8.dist-info}/top_level.txt +0 -0
pam/__init__.py
CHANGED
pam/cli.py
CHANGED
|
@@ -59,6 +59,8 @@ ENGINE_DEPENDENCIES = {
|
|
|
59
59
|
"pandas": ["pandas>=2.2.3", "pyarrow>=19.0.1"],
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
UV_RUNTIME_DEPENDENCIES = ["Flask>=3.0.2", "gunicorn>=23.0.0"]
|
|
63
|
+
|
|
62
64
|
|
|
63
65
|
def main(argv=None):
|
|
64
66
|
args = list(sys.argv[1:] if argv is None else argv)
|
|
@@ -145,19 +147,10 @@ def _project_name(directory: Path) -> str:
|
|
|
145
147
|
|
|
146
148
|
|
|
147
149
|
def _assert_new_project(directory: Path):
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
conflicts = [
|
|
153
|
-
name for name in sorted(known_project_files)
|
|
154
|
-
if (directory / name).exists()
|
|
155
|
-
]
|
|
156
|
-
if conflicts:
|
|
157
|
-
raise FileExistsError(
|
|
158
|
-
"pam init only supports a new project directory; existing files: "
|
|
159
|
-
+ ", ".join(conflicts)
|
|
160
|
-
)
|
|
150
|
+
# Kept for backward compatibility; collision handling is now in init_project
|
|
151
|
+
# via _prompt_overwrite_if_needed. Do not enforce allow-list here so
|
|
152
|
+
# unrelated files like .DS_Store are ignored.
|
|
153
|
+
return
|
|
161
154
|
|
|
162
155
|
|
|
163
156
|
def _requirement_name(requirement: str) -> str:
|
|
@@ -180,45 +173,26 @@ def _assert_fresh_uv_project(directory: Path):
|
|
|
180
173
|
"Run `uv add pam-python` before `uv run pam init`"
|
|
181
174
|
)
|
|
182
175
|
|
|
183
|
-
python_version = directory / ".python-version"
|
|
184
|
-
if not python_version.is_file() or not python_version.read_text().strip().startswith("3.12"):
|
|
185
|
-
raise FileExistsError(
|
|
186
|
-
"A fresh uv project must pin Python 3.12; run `uv init --python 3.12`"
|
|
187
|
-
)
|
|
188
176
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
unexpected = sorted(path.name for path in directory.iterdir() if path.name not in allowed)
|
|
200
|
-
if unexpected:
|
|
177
|
+
def _prompt_overwrite_if_needed(directory: Path, templates: dict[str, str]) -> bool:
|
|
178
|
+
dest_names = set(templates.values()) | {PROJECT_MARKER, "__init__.py"}
|
|
179
|
+
conflicts = sorted(name for name in dest_names if (directory / name).exists())
|
|
180
|
+
if not conflicts:
|
|
181
|
+
return True
|
|
182
|
+
print("The following files will be overwritten:")
|
|
183
|
+
for name in conflicts:
|
|
184
|
+
print(f" - {name}")
|
|
185
|
+
# Single confirmation round as requested: list collisions once, ask once.
|
|
186
|
+
if not sys.stdin.isatty():
|
|
201
187
|
raise FileExistsError(
|
|
202
|
-
"pam init
|
|
203
|
-
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
readme = directory / "README.md"
|
|
207
|
-
if readme.is_file() and readme.read_text(encoding="utf-8").strip():
|
|
208
|
-
raise FileExistsError("pam init will not overwrite a non-empty README.md")
|
|
209
|
-
|
|
210
|
-
main_file = directory / "main.py"
|
|
211
|
-
if main_file.is_file():
|
|
212
|
-
source = main_file.read_text(encoding="utf-8")
|
|
213
|
-
uv_placeholder = re.fullmatch(
|
|
214
|
-
r'def main\(\):\n'
|
|
215
|
-
r' print\("Hello from [a-z0-9-]+!"\)\n\n\n'
|
|
216
|
-
r'if __name__ == "__main__":\n'
|
|
217
|
-
r' main\(\)\n?',
|
|
218
|
-
source,
|
|
188
|
+
"pam init will overwrite existing files: " + ", ".join(conflicts) + ". "
|
|
189
|
+
"Run in an interactive terminal and confirm to overwrite."
|
|
219
190
|
)
|
|
220
|
-
|
|
221
|
-
|
|
191
|
+
response = input("มีไฟล์ที่จะถูกเขียนทับตามรายการข้างบน ดำเนินการต่อหรือไม่? (y/N): ").strip().lower()
|
|
192
|
+
if response != "y":
|
|
193
|
+
print("Cancelled.")
|
|
194
|
+
return False
|
|
195
|
+
return True
|
|
222
196
|
|
|
223
197
|
|
|
224
198
|
def _run_uv(args: list[str], cwd: Path):
|
|
@@ -263,6 +237,12 @@ def init_project(package_manager: str | None = None):
|
|
|
263
237
|
if dest not in preserved_uv_files
|
|
264
238
|
}
|
|
265
239
|
|
|
240
|
+
if not _prompt_overwrite_if_needed(destination, templates):
|
|
241
|
+
return
|
|
242
|
+
|
|
243
|
+
if preinitialized_uv:
|
|
244
|
+
_run_uv(["add", *UV_RUNTIME_DEPENDENCIES], destination)
|
|
245
|
+
|
|
266
246
|
with tempfile.TemporaryDirectory(prefix=".pam-init-", dir=destination) as temp_dir:
|
|
267
247
|
staging = Path(temp_dir)
|
|
268
248
|
for src, dest in templates.items():
|
|
@@ -17,4 +17,4 @@ RUN mkdir -p "$DATA_FOLDER"
|
|
|
17
17
|
EXPOSE 8000
|
|
18
18
|
|
|
19
19
|
# Keep one worker: service lifecycle state is local to the process.
|
|
20
|
-
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:8000", "main:app"]
|
|
20
|
+
CMD ["uv", "run", "--no-sync", "gunicorn", "-w", "1", "-b", "0.0.0.0:8000", "main:app"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pam-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Pam Python Library
|
|
5
5
|
Author-email: Narongrit Kanhanoi <narongrit@pams.ai>
|
|
6
6
|
Project-URL: Homepage, https://github.com/heart/pam-python
|
|
@@ -70,9 +70,9 @@ uv add pam-python
|
|
|
70
70
|
uv run pam init
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
`pam init` recognizes a fresh uv project, keeps its uv configuration,
|
|
74
|
-
|
|
75
|
-
been edited.
|
|
73
|
+
`pam init` recognizes a fresh uv project, keeps its uv configuration, adds the
|
|
74
|
+
Flask and Gunicorn runtime dependencies, and adds the PAM scaffold. It refuses
|
|
75
|
+
projects whose generated source files have already been edited.
|
|
76
76
|
|
|
77
77
|
Pip remains supported for new projects that do not use uv:
|
|
78
78
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
pam/__init__.py,sha256=
|
|
1
|
+
pam/__init__.py,sha256=Co72i2vVxc76G80upH8CH_ITsRLREFU-jn6iexa6VxQ,56
|
|
2
2
|
pam/api.py,sha256=T1plaZ1EyGFz59EdP5ibnl7n0NxduhBPN-jGYe20rCU,7844
|
|
3
|
-
pam/cli.py,sha256=
|
|
3
|
+
pam/cli.py,sha256=fCtqVfMjmxNuJWzpwc51zHdjepyW10GT38u27QdUq3o,13788
|
|
4
4
|
pam/interface_task_manager.py,sha256=V6WMifh5t0tIq9m46eH0RlXDmhbRNPc7XVs6R2rOejE,1985
|
|
5
5
|
pam/logger.py,sha256=JYPfIpaQZy6QrfVKrzEMrxOgTzWIEhoegvIZgHTGWoc,3021
|
|
6
6
|
pam/request_file_format.py,sha256=fSRlJagbvVGqdIEqhINSeqBNUTNQdm8GL5JfqgX9bxU,317
|
|
@@ -60,7 +60,7 @@ pam/templates/init/run_unit_test.ps1,sha256=4O9fciyt04j1XjwOJELPwGTv0XOd2CmZ1e7u
|
|
|
60
60
|
pam/templates/init/run_unit_test.sh,sha256=4yVDKgI3bLK6CujRViF9UBOdNGoLFwcluZvmpYyi6kg,161
|
|
61
61
|
pam/templates/project/pip/Dockerfile,sha256=VSfnPGRwuq-WoJ0ddfdnteJJM2eUlTJPdhTQfYhFWMw,382
|
|
62
62
|
pam/templates/project/pip/requirements.txt,sha256=2hwbTfQsI_AEPWdsym2q0y5uTyO6Cekth_k2RZxYGx8,56
|
|
63
|
-
pam/templates/project/uv/Dockerfile,sha256=
|
|
63
|
+
pam/templates/project/uv/Dockerfile,sha256=MTeMf2g8-gShxK7s4Iw5jvNN8uOklm8NVnK7jkS7T8M,466
|
|
64
64
|
pam/templates/project/uv/pyproject.toml,sha256=30a2hJn6oN1AGvmgEBdxLETOBlHY8L-IIpIy8637yJM,208
|
|
65
65
|
pam/templates/project/uv/python-version,sha256=e1X45ntWI8S-8_ppEojalDfXnTq6FW3kjUgdsyrH0W0,5
|
|
66
66
|
pam/templates/service/common/service.yaml,sha256=ceyFswXjTh07vB4hrJEu7pj3mjlq3NPD4GPYTmvGwmE,44
|
|
@@ -70,9 +70,9 @@ pam/templates/service/pandas/service_class.tmpl,sha256=qaq9tqRhxogWQlqi09dbX5vLu
|
|
|
70
70
|
pam/templates/service/polars/functions.tmpl,sha256=7Qlwsd5Q1vdkOvXHtlltjb2oS-i7JuNKPor2iNDSsQg,701
|
|
71
71
|
pam/templates/service/polars/service.test.tmpl,sha256=nC6VoauZMYy_UTTXxxergfWbXvUD_VWwpM7-7A3aKqE,6881
|
|
72
72
|
pam/templates/service/polars/service_class.tmpl,sha256=jMGeruXduu0eBB7FPDEkZu8b4mSIO3uRt5TiDuNq5T4,3688
|
|
73
|
-
pam_python-0.2.
|
|
74
|
-
pam_python-0.2.
|
|
75
|
-
pam_python-0.2.
|
|
76
|
-
pam_python-0.2.
|
|
77
|
-
pam_python-0.2.
|
|
78
|
-
pam_python-0.2.
|
|
73
|
+
pam_python-0.2.8.dist-info/licenses/LICENSE.txt,sha256=yeHD2-gzrkkET2ZkMe22WyUGpDjlwTrqA4POb0FoZi4,1138
|
|
74
|
+
pam_python-0.2.8.dist-info/METADATA,sha256=iAm5L2_W0DOtXW9SUCVFUUa71j1lipUKNaNQjiASZDg,10024
|
|
75
|
+
pam_python-0.2.8.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
76
|
+
pam_python-0.2.8.dist-info/entry_points.txt,sha256=xqYpsIqvNlO0j8elZc02bDwR-12dLK9FU2B1ACsLYxw,37
|
|
77
|
+
pam_python-0.2.8.dist-info/top_level.txt,sha256=0EOjbyc3hQyzjhn6iyMgsEseqA66Xz0p27iBN7G7W1w,4
|
|
78
|
+
pam_python-0.2.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|