matrice-compute 0.1.43__tar.gz → 0.1.45__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.
Files changed (31) hide show
  1. matrice_compute-0.1.45/MANIFEST.in +5 -0
  2. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/PKG-INFO +4 -4
  3. matrice_compute-0.1.45/build-config.json +18 -0
  4. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/pyproject.toml +18 -6
  5. matrice_compute-0.1.45/setup.py +102 -0
  6. matrice_compute-0.1.45/src/matrice_compute/__init__.py +35 -0
  7. matrice_compute-0.1.45/src/matrice_compute/__init__.pyi +2056 -0
  8. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/action_instance.py +22 -6
  9. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/actions_manager.py +2 -1
  10. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/actions_scaledown_manager.py +5 -0
  11. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/instance_manager.py +26 -6
  12. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/instance_utils.py +8 -8
  13. matrice_compute-0.1.45/src/matrice_compute/k8s_scheduler.py +749 -0
  14. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/prechecks.py +5 -6
  15. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/resources_tracker.py +68 -53
  16. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/scaling.py +31 -2
  17. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/task_utils.py +51 -0
  18. {matrice_compute-0.1.43 → matrice_compute-0.1.45/src}/matrice_compute.egg-info/PKG-INFO +4 -4
  19. {matrice_compute-0.1.43 → matrice_compute-0.1.45/src}/matrice_compute.egg-info/SOURCES.txt +11 -6
  20. matrice_compute-0.1.45/stub_generation.py +549 -0
  21. matrice_compute-0.1.43/setup.py +0 -322
  22. matrice_compute-0.1.43/src/matrice_compute/__init__.py +0 -24
  23. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/LICENSE.txt +0 -0
  24. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/README.md +0 -0
  25. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/setup.cfg +0 -0
  26. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/compute_operations_handler.py +0 -0
  27. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/py.typed +0 -0
  28. {matrice_compute-0.1.43 → matrice_compute-0.1.45}/src/matrice_compute/shutdown_manager.py +0 -0
  29. {matrice_compute-0.1.43 → matrice_compute-0.1.45/src}/matrice_compute.egg-info/dependency_links.txt +0 -0
  30. {matrice_compute-0.1.43 → matrice_compute-0.1.45/src}/matrice_compute.egg-info/not-zip-safe +0 -0
  31. {matrice_compute-0.1.43 → matrice_compute-0.1.45/src}/matrice_compute.egg-info/top_level.txt +0 -0
@@ -0,0 +1,5 @@
1
+ include LICENSE.txt
2
+ include README.md
3
+ include stub_generation.py
4
+ include build-config.json
5
+ recursive-include src *.py *.pyi py.typed
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice_compute
3
- Version: 0.1.43
3
+ Version: 0.1.45
4
4
  Summary: Common server utilities for Matrice.ai services
5
5
  Author-email: "Matrice.ai" <dipendra@matrice.ai>
6
- License-Expression: MIT
7
- Keywords: matrice,common,utilities,pyarmor,obfuscated
6
+ License: MIT
7
+ Keywords: matrice,common,utilities,mypyc,compiled
8
8
  Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Intended Audience :: Developers
10
10
  Classifier: Operating System :: OS Independent
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Typing :: Typed
21
- Requires-Python: >=3.8
21
+ Requires-Python: >=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE.txt
24
24
  Dynamic: license-file
@@ -0,0 +1,18 @@
1
+ {
2
+ "versions": {
3
+ "test_pypi_dev": "1.0.83",
4
+ "test_pypi": "0.1.52",
5
+ "pypi": "0.1.45"
6
+ },
7
+ "build": {
8
+ "enable_mypyc": false,
9
+ "python_versions": ["3.8", "3.9", "3.10", "3.11", "3.12"]
10
+ },
11
+ "platforms": {
12
+ "linux_x86_64": true,
13
+ "linux_arm64": false,
14
+ "windows_x64": false,
15
+ "macos_x64": false,
16
+ "macos_arm64": false
17
+ }
18
+ }
@@ -1,5 +1,11 @@
1
1
  [build-system]
2
- requires = ["setuptools>=65.0.0", "wheel", "pyarmor>=8.0.0"]
2
+ requires = [
3
+ "setuptools>=65.0.0",
4
+ "wheel",
5
+ "mypy[mypyc]>=1.0",
6
+ "types-docker>=7.1,<7.2",
7
+ "types-psutil>=7.2,<7.3",
8
+ ]
3
9
  build-backend = "setuptools.build_meta"
4
10
 
5
11
  [project]
@@ -8,9 +14,9 @@ dynamic = ["version"]
8
14
  description = "Common server utilities for Matrice.ai services"
9
15
  readme = "README.md"
10
16
  authors = [{ name = "Matrice.ai", email = "dipendra@matrice.ai" }]
11
- license = "MIT"
12
- requires-python = ">=3.8, <4"
13
- keywords = ["matrice", "common", "utilities", "pyarmor", "obfuscated"]
17
+ license = {text = "MIT"}
18
+ requires-python = ">=3.8"
19
+ keywords = ["matrice", "common", "utilities", "mypyc", "compiled"]
14
20
  classifiers = [
15
21
  "Development Status :: 4 - Beta",
16
22
  "Intended Audience :: Developers",
@@ -27,6 +33,12 @@ classifiers = [
27
33
  "Typing :: Typed",
28
34
  ]
29
35
 
36
+ [tool.mypy]
37
+ follow_imports = "skip"
38
+ ignore_missing_imports = true
39
+ warn_unused_ignores = false
40
+ show_error_codes = true
30
41
 
31
- # PyArmor configuration is handled via pyarmor.yml file
32
- # The [tool.pyarmor] section is not used in PyArmor 8.x
42
+ [[tool.mypy.overrides]]
43
+ module = ["kafka", "kafka.*", "kubernetes", "kubernetes.*"]
44
+ ignore_missing_imports = true
@@ -0,0 +1,102 @@
1
+ """
2
+ Mypyc-compiled build configuration for matrice_compute.
3
+
4
+ This setup.py can build in two modes:
5
+ - With mypyc: Compiles Python to native extensions (faster, platform-specific wheels)
6
+ - Without mypyc: Pure Python package (cross-platform, slower)
7
+
8
+ Set ENABLE_MYPYC=true environment variable to enable mypyc compilation.
9
+ """
10
+ import os
11
+ import subprocess
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ from setuptools import setup, find_packages
16
+
17
+ # Package configuration
18
+ PACKAGE_NAME = "matrice_compute"
19
+ SOURCE_DIR = f"src/{PACKAGE_NAME}"
20
+
21
+ # Check if mypyc compilation is enabled
22
+ ENABLE_MYPYC = os.environ.get("ENABLE_MYPYC", "").lower() in ("true", "1", "yes")
23
+
24
+
25
+ def get_version() -> str:
26
+ """Get version from PACKAGE_VERSION environment variable."""
27
+ version = os.environ.get("PACKAGE_VERSION", "0.0.0.dev0")
28
+ print(f"Building version: {version}")
29
+ return version
30
+
31
+
32
+ def ensure_py_typed():
33
+ """Create py.typed marker file for PEP 561 compliance."""
34
+ py_typed = Path(SOURCE_DIR) / "py.typed"
35
+ if not py_typed.exists():
36
+ py_typed.write_text("")
37
+ print("Created py.typed file")
38
+
39
+
40
+ def run_stub_generator():
41
+ """Run stub generator script to create .pyi files."""
42
+ script_path = Path(__file__).parent / "stub_generation.py"
43
+ if not script_path.exists():
44
+ print(f"Warning: Stub generator not found: {script_path}")
45
+ return
46
+
47
+ print(f"Running stub generator: {script_path}")
48
+ subprocess.run([sys.executable, str(script_path)], check=True)
49
+
50
+
51
+ def discover_modules() -> list[str]:
52
+ """Discover Python modules for mypyc compilation."""
53
+ src_root = Path(SOURCE_DIR)
54
+ if not src_root.exists():
55
+ return []
56
+
57
+ exclude = {"__pycache__", "tests", "test", "docs"}
58
+ modules = []
59
+
60
+ for path in src_root.rglob("*.py"):
61
+ if any(part in exclude for part in path.parts):
62
+ continue
63
+ modules.append(str(path).replace("\\", "/"))
64
+
65
+ print(f"Discovered {len(modules)} Python files for mypyc compilation")
66
+ return modules
67
+
68
+
69
+ def get_ext_modules():
70
+ """Get extension modules - mypyc compiled or empty for pure Python."""
71
+ if not ENABLE_MYPYC:
72
+ print("Building PURE PYTHON package (mypyc disabled)")
73
+ return []
74
+
75
+ print("Building MYPYC COMPILED package")
76
+ from mypyc.build import mypycify
77
+
78
+ mypyc_options = [
79
+ "--follow-imports=skip",
80
+ "--ignore-missing-imports",
81
+ ]
82
+ return mypycify(mypyc_options + discover_modules(), opt_level="3")
83
+
84
+
85
+ # Build preparation
86
+ ensure_py_typed()
87
+ run_stub_generator()
88
+
89
+ # Setup
90
+ setup(
91
+ name=PACKAGE_NAME,
92
+ version=get_version(),
93
+ package_dir={"": "src"},
94
+ packages=find_packages(where="src"),
95
+ include_package_data=True,
96
+ package_data={
97
+ PACKAGE_NAME: ["py.typed", "*.pyi", "**/*.pyi"],
98
+ },
99
+ ext_modules=get_ext_modules(),
100
+ zip_safe=False,
101
+ python_requires=">=3.10",
102
+ )
@@ -0,0 +1,35 @@
1
+ """Module providing __init__ functionality."""
2
+
3
+ import os
4
+ import subprocess
5
+ import logging
6
+
7
+ from matrice_common.utils import dependencies_check
8
+
9
+ # Check execution mode to determine which dependencies to verify
10
+ execution_mode = os.environ.get("EXECUTION_MODE", "vm").lower()
11
+
12
+ if execution_mode == "kubernetes":
13
+ # Kubernetes mode - only check K8s-related dependencies
14
+ dependencies_check(
15
+ ["kubernetes", "psutil", "cryptography"]
16
+ )
17
+ else:
18
+ # VM mode - check docker and other VM-specific dependencies
19
+ dependencies_check(
20
+ ["docker", "psutil", "cryptography", "notebook", "aiohttp", "kafka-python"]
21
+ )
22
+
23
+ subprocess.run( # Re-upgrade docker to avoid missing DOCKER_HOST connection error
24
+ ["pip", "install", "--upgrade", "docker"],
25
+ check=True,
26
+ stdout=subprocess.DEVNULL, # suppress normal output
27
+ stderr=subprocess.DEVNULL # suppress warnings/progress
28
+ )
29
+
30
+ from matrice_compute.instance_manager import InstanceManager # noqa: E402
31
+
32
+ logging.getLogger("kafka").setLevel(logging.INFO)
33
+ logging.getLogger("confluent_kafka").setLevel(logging.INFO)
34
+
35
+ __all__ = ["InstanceManager"]