pythagoras 0.20.2__py3-none-any.whl → 0.20.4__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.
@@ -1,3 +1,5 @@
1
+ import sys
2
+
1
3
  from .._010_basic_portals.exceptions import NonCompliantFunction
2
4
  import ast
3
5
  import inspect
@@ -7,8 +9,8 @@ import autopep8
7
9
  from .function_processing import get_function_name_from_source
8
10
  from .._010_basic_portals.long_infoname import get_long_infoname
9
11
  from .function_processing import assert_ordinarity
10
- from ... import pythagoras as pth
11
12
 
13
+ import pythagoras as pth
12
14
 
13
15
  def _get_normalized_function_source_impl(
14
16
  a_func: Callable | str
@@ -227,7 +227,7 @@ class OrdinaryFn(PortalAwareClass):
227
227
 
228
228
  def _available_names(self):
229
229
  """Returns a dictionary with the names, available inside the function."""
230
- from ... import pythagoras as pth
230
+ import pythagoras as pth
231
231
  names= dict(globals())
232
232
  names[self.name] = self
233
233
  names["self"] = self
@@ -13,7 +13,7 @@ from .._060_autonomous_code_portals.names_usage_analyzer import (
13
13
  from .._050_safe_code_portals.safe_portal_core_classes import (
14
14
  SafeFn, SafeCodePortal)
15
15
 
16
- from ... import pythagoras as pth
16
+ import pythagoras as pth
17
17
 
18
18
 
19
19
  class AutonomousCodePortal(SafeCodePortal):
@@ -1,12 +1,12 @@
1
1
  from .._060_autonomous_code_portals import AutonomousFn, autonomous
2
- from ... import pythagoras as pth
2
+ from .OK_const import OK
3
3
 
4
4
 
5
5
  def free_ram_bytes(packed_kwargs, fn_addr, required_memory):
6
6
  import psutil
7
7
  mem_info = psutil.virtual_memory()
8
8
  if mem_info.available >= required_memory:
9
- return pth.OK
9
+ return OK
10
10
 
11
11
 
12
12
  def RAM_K(limit:int) -> AutonomousFn:
@@ -3,12 +3,43 @@ import importlib
3
3
  import sys
4
4
  from typing import Optional
5
5
 
6
+ _uv_and_pip_installation_needed:bool = True
7
+
8
+ def _install_uv_and_pip() -> None:
9
+ global _uv_and_pip_installation_needed
10
+ if not _uv_and_pip_installation_needed:
11
+ return
12
+ _uv_pip_installation_attempted = False
13
+
14
+ try:
15
+ importlib.import_module("uv")
16
+ except:
17
+ install_package("uv", use_uv=False)
18
+
19
+ try:
20
+ importlib.import_module("pip")
21
+ except:
22
+ install_package("pip", use_uv=True)
23
+
24
+
6
25
  def install_package(package_name:str
7
26
  , upgrade:bool=False
8
27
  , version:Optional[str]=None
28
+ , use_uv:bool = True
9
29
  ) -> None:
10
30
  """Install package using pip."""
11
- command = [sys.executable, "-m", "uv", "pip", "install"]
31
+
32
+ if package_name == "pip":
33
+ assert use_uv
34
+ elif package_name == "uv":
35
+ assert not use_uv
36
+ else:
37
+ _install_uv_and_pip()
38
+
39
+ if use_uv:
40
+ command = [sys.executable, "-m", "uv", "pip", "install"]
41
+ else:
42
+ command = [sys.executable, "-m", "pip", "install"]
12
43
 
13
44
  if upgrade:
14
45
  command += ["--upgrade"]
@@ -21,10 +52,17 @@ def install_package(package_name:str
21
52
 
22
53
  importlib.import_module(package_name)
23
54
 
24
- def uninstall_package(package_name:str)->None:
25
- """Uninstall package using pip."""
26
55
 
27
- command = [sys.executable, "-m", "uv", "pip", "uninstall", package_name]
56
+ def uninstall_package(package_name:str, use_uv:bool=True)->None:
57
+ """Uninstall package using uv or pip."""
58
+
59
+ assert package_name not in ["pip", "uv"]
60
+
61
+ if use_uv:
62
+ command = [sys.executable, "-m", "uv", "pip", "uninstall", package_name]
63
+ else:
64
+ command = [sys.executable, "-m", "pip", "uninstall", "-y", package_name]
65
+
28
66
  subprocess.run(command, check=True, stdout=subprocess.PIPE
29
67
  , stderr=subprocess.STDOUT, text=True)
30
68
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pythagoras
3
- Version: 0.20.2
3
+ Version: 0.20.4
4
4
  Summary: Planet-scale distributed computing in Python.
5
5
  Keywords: cloud,ML,AI,serverless,distributed,parallel,machine-learning,deep-learning,pythagoras
6
6
  Author: Volodymyr (Vlad) Pavlov
@@ -6,10 +6,10 @@ pythagoras/_010_basic_portals/not_picklable_class.py,sha256=6c9374e4e54c7b7532b6
6
6
  pythagoras/_010_basic_portals/portal_tester.py,sha256=cefdbf60bfc7697934ef8fd653303ac5295014884af780351baf84d859ec6de0,1817
7
7
  pythagoras/_010_basic_portals/post_init_metaclass.py,sha256=6dbe6856e4e46627bc0ae64d4220274b1147d4d2a74f6440f2454f8a93485c7e,583
8
8
  pythagoras/_020_ordinary_code_portals/__init__.py,sha256=a77912a9a4188f4c65864f41c29b45800d5449d4db7c790007943d307f80348d,1295
9
- pythagoras/_020_ordinary_code_portals/code_normalizer.py,sha256=0eb83754c6b6e85b21a9efeb90160215aa7b81d1075847bfa0d54cccc20317e9,4866
9
+ pythagoras/_020_ordinary_code_portals/code_normalizer.py,sha256=2e2e4273add19a526273756ec8d8d0f33ea8aa0ef2cd15e0ce8c4c2b0d15f928,4869
10
10
  pythagoras/_020_ordinary_code_portals/function_processing.py,sha256=ae5841d1da5a533b6fe92336c2551d6947444dc576a55508098b9f56b40245c7,3623
11
11
  pythagoras/_020_ordinary_code_portals/ordinary_decorator.py,sha256=078c2e6e194ffab6bc8477b15b72198ccb34b57a935813ba2318ccf2d5c01a28,898
12
- pythagoras/_020_ordinary_code_portals/ordinary_portal_core_classes.py,sha256=82cf800d3574724487b71fde07ea496840edcb6807fff0b6221cfbd72ea895ed,9191
12
+ pythagoras/_020_ordinary_code_portals/ordinary_portal_core_classes.py,sha256=bfe25e1911c9859c369a6dfeea8c8126c2b04058ad7b711994a99532e5c11b54,9182
13
13
  pythagoras/_030_data_portals/__init__.py,sha256=8edbde910ded4fa56091492d7f8443d0980adedcab25f4b9308cfed05074c7f2,1237
14
14
  pythagoras/_030_data_portals/data_portal_core_classes.py,sha256=50bcbd71705be6287573ba7b2f12a1523bc97976608537d71da31befe27196aa,18492
15
15
  pythagoras/_030_data_portals/ready_and_get.py,sha256=d87d16a6747239f4ed6c30c2be95eab9ae58bc5b2742f0fd924fd2a3ace71382,1571
@@ -28,15 +28,15 @@ pythagoras/_050_safe_code_portals/safe_decorator.py,sha256=085bb05724d02a3ff4f51
28
28
  pythagoras/_050_safe_code_portals/safe_portal_core_classes.py,sha256=517b5252c55433681433fceec6a2141486b0bc453797119bedf2fc37e408ae30,1678
29
29
  pythagoras/_060_autonomous_code_portals/__init__.py,sha256=6c19fffb24a93aef9587f0abe9ef24732ef5971c94e9a0fa2c36f4d7a3664e35,2232
30
30
  pythagoras/_060_autonomous_code_portals/autonomous_decorators.py,sha256=c315b37cbc30e3929f18e29bda409aad39b6d5d840dcdb8b70c737817d346af6,3947
31
- pythagoras/_060_autonomous_code_portals/autonomous_portal_core_classes.py,sha256=7c2571c9fe48f64428461596103ca2fe33d845a231936e6c15d502e2c3b2aca7,4415
31
+ pythagoras/_060_autonomous_code_portals/autonomous_portal_core_classes.py,sha256=f0ba893c6bbc9a5557ff9f5d204a5c8e88ff499d2e8edb51daab4302bae7ea14,4406
32
32
  pythagoras/_060_autonomous_code_portals/names_usage_analyzer.py,sha256=1e0e84854ac630b204878fecde48a16739fd2663709fcee2ec0a8844f4fd4f13,7470
33
33
  pythagoras/_070_protected_code_portals/GPU_guards.py,sha256=75a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb070,2
34
34
  pythagoras/_070_protected_code_portals/OK_const.py,sha256=17ea314496f44b422f9936585c3bb3749c960bc779b4f74962ec04e3fa4d2494,186
35
- pythagoras/_070_protected_code_portals/RAM_guards.py,sha256=6cf51665bf8d21c373adf1b21fcde341ec311deda7d688dd9aa2702129174ddc,850
35
+ pythagoras/_070_protected_code_portals/RAM_guards.py,sha256=cd439db72375ad0c2c624d0fb7edf8d49dd2396a284929e0bfdfd42970ed4b28,837
36
36
  pythagoras/_070_protected_code_portals/__init__.py,sha256=1e1a4ccccede6cd416d172967fb766ba91bbafddff078187799f044ed71677b3,195
37
37
  pythagoras/_070_protected_code_portals/fn_arg_names_checker.py,sha256=2000ba3cab7d5828eba5b096358249c3ed460f7b82d41aaabcad945fd5e48a74,1215
38
38
  pythagoras/_070_protected_code_portals/list_flattener.py,sha256=9a54b512ad9dc201db348e7908f5ca5f36d171ae3da433511d38023a6ba8d4b5,331
39
- pythagoras/_070_protected_code_portals/package_manager.py,sha256=004cdd409843efd5a252ff829edbf8e21234ab468eaa104daa0f7d6ff8d49baa,1122
39
+ pythagoras/_070_protected_code_portals/package_manager.py,sha256=30adf8d75f55b9b2c587dc95f4aa1c2154fa9354d668af6f0d586bb42f0d5b17,2008
40
40
  pythagoras/_070_protected_code_portals/protected_decorators.py,sha256=9cede3734b0235e15a9534fcf393454f9107073f90cf9bd5a532696d277e35da,1412
41
41
  pythagoras/_070_protected_code_portals/protected_portal_core_classes.py,sha256=58e66f14598a23d6d4bfa4dd3d510971ce272a11ea73a22d11b72487df112968,6616
42
42
  pythagoras/_070_protected_code_portals/python_packages_guards.py,sha256=a4ff97c250cbc94ad379edcab510fe10d4d590de9733bbff437bed71c025cecb,1025
@@ -60,6 +60,6 @@ pythagoras/_900_project_stats_collector/__init__.py,sha256=e3b0c44298fc1c149afbf
60
60
  pythagoras/_900_project_stats_collector/project_analyzer.py,sha256=d06e9d7b516cb7424ef777e70abe9d5220e09b0b19476326b8974b4dc3917f89,3506
61
61
  pythagoras/__init__.py,sha256=94303c01a7bde4078fdbd90c0b142807a023fa352c473c3a544a2180b7254ae9,1062
62
62
  pythagoras/core/__init__.py,sha256=26640880921763e8801b74da28fccf1cd47ac0ba0d40ee8fcaf7d748410406bf,189
63
- pythagoras-0.20.2.dist-info/WHEEL,sha256=7de84e261f5edc1201bd668234a371ec3eb94db037d1f75c0139430c1319ab31,79
64
- pythagoras-0.20.2.dist-info/METADATA,sha256=4177c1259f5cad84c9617531d6b8a54da63a6908f1484557c4a1aa87883fa3ee,4177
65
- pythagoras-0.20.2.dist-info/RECORD,,
63
+ pythagoras-0.20.4.dist-info/WHEEL,sha256=7de84e261f5edc1201bd668234a371ec3eb94db037d1f75c0139430c1319ab31,79
64
+ pythagoras-0.20.4.dist-info/METADATA,sha256=85100495f6fdc9536d83f64d0fee2ec62b5613c9b38edd80ef564e67f1ee348b,4177
65
+ pythagoras-0.20.4.dist-info/RECORD,,