lim-mm-cli 0.1.0__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.
- lim_mm_cli-0.1.0.dist-info/METADATA +14 -0
- lim_mm_cli-0.1.0.dist-info/RECORD +10 -0
- lim_mm_cli-0.1.0.dist-info/WHEEL +5 -0
- lim_mm_cli-0.1.0.dist-info/entry_points.txt +2 -0
- lim_mm_cli-0.1.0.dist-info/licenses/LICENSE +0 -0
- lim_mm_cli-0.1.0.dist-info/top_level.txt +1 -0
- mm/__init__.py +0 -0
- mm/cli.py +26 -0
- mm/core.py +49 -0
- mm/validator.py +53 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lim-mm-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI tool for LIM-compatible micro model project scaffolding
|
|
5
|
+
Author-email: Solution Eden <solutionedencom@gmail.com>
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: typer[all]
|
|
10
|
+
Requires-Dist: jsonschema
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# LIM CLI: CLI Project to create MM
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
lim_mm_cli-0.1.0.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
mm/cli.py,sha256=zHSE42Lf4LcoiQsjHaVUcRiDSUF4z3uksO5ZZ0fZuR0,489
|
|
4
|
+
mm/core.py,sha256=5Mz4lz1wp6z_RNeaIELdXybuK02KRRurgX6BxhkT1vk,1269
|
|
5
|
+
mm/validator.py,sha256=DkdY4Q-jjuoH9hVOdqpxtRPCZZC7qbhQmtQapHLMz5k,1587
|
|
6
|
+
lim_mm_cli-0.1.0.dist-info/METADATA,sha256=b0oarDVqekkX3_EFZvtX7s0E9N0Yxu2ma3IkbvYy8e0,399
|
|
7
|
+
lim_mm_cli-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
lim_mm_cli-0.1.0.dist-info/entry_points.txt,sha256=A61U1E9usaOGcoxXde_bHPpfEymklJuDWLSuiNJ3D_I,34
|
|
9
|
+
lim_mm_cli-0.1.0.dist-info/top_level.txt,sha256=PWyq3MAmNdoLEw5PE1HUeurLnCXAbUs0_GoIY4VLgTI,3
|
|
10
|
+
lim_mm_cli-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mm
|
mm/__init__.py
ADDED
|
File without changes
|
mm/cli.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from mm.core import init_project, push_project, validate_project
|
|
3
|
+
|
|
4
|
+
app = typer.Typer()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@app.command()
|
|
8
|
+
def init(name: str):
|
|
9
|
+
"""Initialize a LIM-compatible project."""
|
|
10
|
+
init_project(name)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.command()
|
|
14
|
+
def validate():
|
|
15
|
+
"""Validate mms/meta.json structure and content."""
|
|
16
|
+
validate_project()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@app.command()
|
|
20
|
+
def push():
|
|
21
|
+
"""Run start.py, validate /meta output, and prepare project for deployment."""
|
|
22
|
+
push_project()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
app()
|
mm/core.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
import subprocess
|
|
4
|
+
import time
|
|
5
|
+
import requests
|
|
6
|
+
import json
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from mm.validator import validate_meta, validate_meta_consistency
|
|
9
|
+
|
|
10
|
+
TEMPLATE_DIR = Path(__file__).parent.parent / "template"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def init_project(name: str):
|
|
14
|
+
dest = Path(name)
|
|
15
|
+
if dest.exists():
|
|
16
|
+
raise FileExistsError(f"Project directory '{name}' already exists.")
|
|
17
|
+
|
|
18
|
+
shutil.copytree(TEMPLATE_DIR, dest)
|
|
19
|
+
print(f"✅ Project '{name}' created at {dest.resolve()}")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def validate_project():
|
|
23
|
+
meta_path = Path("mms/meta.json")
|
|
24
|
+
validate_meta(meta_path)
|
|
25
|
+
print("✅ meta.json validated.")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def push_project():
|
|
29
|
+
validate_project()
|
|
30
|
+
|
|
31
|
+
print("🚀 Starting mms service via run/start.py ...")
|
|
32
|
+
process = subprocess.Popen(["python", "run/start.py"])
|
|
33
|
+
|
|
34
|
+
time.sleep(3)
|
|
35
|
+
try:
|
|
36
|
+
resp = requests.get("http://localhost:8000/meta", timeout=5)
|
|
37
|
+
resp.raise_for_status()
|
|
38
|
+
remote_meta = resp.json()
|
|
39
|
+
|
|
40
|
+
with open("mms/meta.json") as f:
|
|
41
|
+
local_meta = json.load(f)
|
|
42
|
+
|
|
43
|
+
validate_meta_consistency(local_meta, remote_meta)
|
|
44
|
+
print("✅ /meta response matches mms/meta.json")
|
|
45
|
+
|
|
46
|
+
except Exception as e:
|
|
47
|
+
print("❌ Error verifying /meta endpoint:", e)
|
|
48
|
+
finally:
|
|
49
|
+
process.terminate()
|
mm/validator.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import jsonschema
|
|
3
|
+
from jsonschema import ValidationError
|
|
4
|
+
|
|
5
|
+
META_SCHEMA = {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name", "version", "description", "endpoint", "input", "output"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {"type": "string"},
|
|
10
|
+
"version": {"type": "string", "pattern": r"^\\d+\\.\\d+\\.\\d+$"},
|
|
11
|
+
"description": {"type": "string"},
|
|
12
|
+
"endpoint": {"type": "string", "pattern": r"^/.*"},
|
|
13
|
+
"input": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"required": ["type", "format"],
|
|
16
|
+
"properties": {
|
|
17
|
+
"type": {"type": "string"},
|
|
18
|
+
"format": {"type": "string"}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"output": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"required": ["type", "format"],
|
|
24
|
+
"properties": {
|
|
25
|
+
"type": {"type": "string"},
|
|
26
|
+
"format": {"type": "string"}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"config": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"required": ["type", "format"],
|
|
32
|
+
"properties": {
|
|
33
|
+
"type": {"type": "string"},
|
|
34
|
+
"format": {"type": "string"}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def validate_meta(meta_path):
|
|
42
|
+
with open(meta_path) as f:
|
|
43
|
+
meta = json.load(f)
|
|
44
|
+
try:
|
|
45
|
+
jsonschema.validate(instance=meta, schema=META_SCHEMA)
|
|
46
|
+
except ValidationError as e:
|
|
47
|
+
raise ValueError(f"meta.json validation failed: {e.message}")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def validate_meta_consistency(local: dict, remote: dict):
|
|
51
|
+
if local != remote:
|
|
52
|
+
raise ValueError(
|
|
53
|
+
"meta.json content does not match /meta endpoint response")
|