pythagoras 0.24.0__tar.gz → 0.24.2__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.
- {pythagoras-0.24.0 → pythagoras-0.24.2}/PKG-INFO +3 -3
- {pythagoras-0.24.0 → pythagoras-0.24.2}/pyproject.toml +3 -3
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/basic_portal_core_classes.py +11 -14
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_030_data_portals/data_portal_core_classes.py +13 -13
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/logging_portal_core_classes.py +5 -5
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_050_safe_code_portals/safe_portal_core_classes.py +2 -2
- pythagoras-0.24.2/src/pythagoras/_090_swarming_portals/output_suppressor.py +18 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_090_swarming_portals/swarming_portals.py +42 -26
- pythagoras-0.24.0/src/pythagoras/_090_swarming_portals/output_suppressor.py +0 -23
- {pythagoras-0.24.0 → pythagoras-0.24.2}/README.md +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/.DS_Store +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/exceptions.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/long_infoname.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/not_picklable_class.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/portal_tester.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/post_init_metaclass.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/code_normalizer.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/function_processing.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/ordinary_decorator.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/ordinary_portal_core_classes.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_030_data_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_030_data_portals/ready_and_get.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_030_data_portals/storable_decorator.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/exception_processing_tracking.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/execution_environment_summary.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/kw_args.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/logging_decorator.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/notebook_checker.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/output_capturer.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/uncaught_exceptions.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_050_safe_code_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_050_safe_code_portals/safe_decorator.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_060_autonomous_code_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_060_autonomous_code_portals/autonomous_decorators.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_060_autonomous_code_portals/autonomous_portal_core_classes.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_060_autonomous_code_portals/names_usage_analyzer.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/basic_pre_validators.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/fn_arg_names_checker.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/list_flattener.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/package_manager.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/protected_decorators.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/protected_portal_core_classes.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/system_utils.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/validation_succesful_const.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_080_pure_code_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_080_pure_code_portals/pure_core_classes.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_080_pure_code_portals/pure_decorator.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_080_pure_code_portals/recursion_pre_validator.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_090_swarming_portals/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_100_top_level_API/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_100_top_level_API/default_local_portal.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_100_top_level_API/top_level_API.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/base_16_32_convertors.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/current_date_gmt_str.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/hash_signatures.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/node_signature.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/random_signatures.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_900_project_stats_collector/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_900_project_stats_collector/project_analyzer.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/__init__.py +0 -0
- {pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/core/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pythagoras
|
|
3
|
-
Version: 0.24.
|
|
3
|
+
Version: 0.24.2
|
|
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
|
|
@@ -16,8 +16,7 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
16
16
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
17
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist: persidict
|
|
19
|
+
Requires-Dist: persidict==0.104.1
|
|
21
20
|
Requires-Dist: lz4
|
|
22
21
|
Requires-Dist: joblib
|
|
23
22
|
Requires-Dist: scikit-learn
|
|
@@ -32,6 +31,7 @@ Requires-Dist: boto3
|
|
|
32
31
|
Requires-Dist: moto
|
|
33
32
|
Requires-Dist: uv
|
|
34
33
|
Requires-Dist: nvidia-ml-py
|
|
34
|
+
Requires-Dist: parameterizable==0.100.0
|
|
35
35
|
Requires-Dist: persidict[aws] ; extra == 'aws'
|
|
36
36
|
Requires-Dist: boto3 ; extra == 'aws'
|
|
37
37
|
Requires-Dist: moto ; extra == 'aws'
|
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pythagoras"
|
|
7
|
-
version = "0.24.
|
|
7
|
+
version = "0.24.2"
|
|
8
8
|
authors = [
|
|
9
9
|
{name = "Volodymyr (Vlad) Pavlov", email = "vlpavlov@ieee.org"},
|
|
10
10
|
]
|
|
@@ -26,8 +26,7 @@ classifiers = [
|
|
|
26
26
|
]
|
|
27
27
|
keywords = ["cloud", "ML", "AI", "serverless", "distributed", "parallel", "machine-learning", "deep-learning", "pythagoras"]
|
|
28
28
|
dependencies = [
|
|
29
|
-
"
|
|
30
|
-
"persidict",
|
|
29
|
+
"persidict==0.104.1",
|
|
31
30
|
"lz4",
|
|
32
31
|
"joblib",
|
|
33
32
|
"scikit-learn",
|
|
@@ -42,6 +41,7 @@ dependencies = [
|
|
|
42
41
|
"moto",
|
|
43
42
|
"uv",
|
|
44
43
|
"nvidia-ml-py",
|
|
44
|
+
"parameterizable==0.100.0",
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
[project.urls]
|
|
@@ -14,6 +14,7 @@ from abc import abstractmethod
|
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
from typing import TypeVar, Type, Any, NewType
|
|
16
16
|
import pandas as pd
|
|
17
|
+
import parameterizable
|
|
17
18
|
from parameterizable import ParameterizableClass, sort_dict_by_keys
|
|
18
19
|
|
|
19
20
|
from persidict import PersiDict, FileDirDict, SafeStrTuple
|
|
@@ -358,15 +359,15 @@ class BasicPortal(NotPicklable,ParameterizableClass, metaclass = PostInitMeta):
|
|
|
358
359
|
return sorted_params
|
|
359
360
|
|
|
360
361
|
|
|
361
|
-
@property
|
|
362
|
-
def
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
362
|
+
# @property
|
|
363
|
+
# def auxiliary_param_names(self) -> set[str]:
|
|
364
|
+
# """Get the names of the portal's ephemeral parameters.
|
|
365
|
+
#
|
|
366
|
+
# Portal's ephemeral parameters are not stored persistently.
|
|
367
|
+
# They affect behaviour of a portal object in an application session,
|
|
368
|
+
# but they do not affect behaviour of the actual portal across multiple runs.
|
|
369
|
+
# """
|
|
370
|
+
# return set()
|
|
370
371
|
|
|
371
372
|
|
|
372
373
|
@property
|
|
@@ -376,12 +377,8 @@ class BasicPortal(NotPicklable,ParameterizableClass, metaclass = PostInitMeta):
|
|
|
376
377
|
It's an internal hash used by Pythagoras and is different from .__hash__()
|
|
377
378
|
"""
|
|
378
379
|
if not hasattr(self,"_str_id_cache"):
|
|
379
|
-
params = self.get_portable_params()
|
|
380
|
-
ephemeral_names = self._ephemeral_param_names
|
|
381
|
-
nonephemeral_params = {k:params[k] for k in params
|
|
382
|
-
if k not in ephemeral_names}
|
|
383
380
|
self._str_id_cache = PortalStrID(
|
|
384
|
-
get_hash_signature(
|
|
381
|
+
get_hash_signature(self.get_essential_jsparams()))
|
|
385
382
|
return self._str_id_cache
|
|
386
383
|
|
|
387
384
|
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_030_data_portals/data_portal_core_classes.py
RENAMED
|
@@ -61,7 +61,7 @@ class DataPortal(OrdinaryCodePortal):
|
|
|
61
61
|
_config_settings: PersiDict | None
|
|
62
62
|
_config_settings_cache: dict
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
_auxiliary_config_params_at_init: dict[str, Any] | None
|
|
65
65
|
|
|
66
66
|
def __init__(self
|
|
67
67
|
, root_dict: PersiDict|str|None = None
|
|
@@ -69,7 +69,7 @@ class DataPortal(OrdinaryCodePortal):
|
|
|
69
69
|
):
|
|
70
70
|
OrdinaryCodePortal.__init__(self, root_dict = root_dict)
|
|
71
71
|
del root_dict
|
|
72
|
-
self.
|
|
72
|
+
self._auxiliary_config_params_at_init = dict()
|
|
73
73
|
self._config_settings_cache = dict()
|
|
74
74
|
|
|
75
75
|
config_settings_prototype = self._root_dict.get_subdict("config_settings")
|
|
@@ -84,7 +84,7 @@ class DataPortal(OrdinaryCodePortal):
|
|
|
84
84
|
raise ValueError("p_consistency_checks must be a float in [0,1] "
|
|
85
85
|
+f"or a Joker, but got {p_consistency_checks}")
|
|
86
86
|
|
|
87
|
-
self.
|
|
87
|
+
self._auxiliary_config_params_at_init["p_consistency_checks"
|
|
88
88
|
] = p_consistency_checks
|
|
89
89
|
|
|
90
90
|
value_store_prototype = self._root_dict.get_subdict("value_store")
|
|
@@ -97,7 +97,7 @@ class DataPortal(OrdinaryCodePortal):
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def _persist_initial_config_params(self) -> None:
|
|
100
|
-
for key, value in self.
|
|
100
|
+
for key, value in self._auxiliary_config_params_at_init.items():
|
|
101
101
|
self._set_config_setting(key, value)
|
|
102
102
|
|
|
103
103
|
|
|
@@ -111,15 +111,15 @@ class DataPortal(OrdinaryCodePortal):
|
|
|
111
111
|
def get_params(self) -> dict:
|
|
112
112
|
"""Get the portal's configuration parameters"""
|
|
113
113
|
params = super().get_params()
|
|
114
|
-
params.update(self.
|
|
114
|
+
params.update(self._auxiliary_config_params_at_init)
|
|
115
115
|
sorted_params = sort_dict_by_keys(params)
|
|
116
116
|
return sorted_params
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
@property
|
|
120
|
-
def
|
|
121
|
-
names = super().
|
|
122
|
-
names.update(self.
|
|
120
|
+
def auxiliary_param_names(self) -> set[str]:
|
|
121
|
+
names = super().auxiliary_param_names
|
|
122
|
+
names.update(self._auxiliary_config_params_at_init)
|
|
123
123
|
return names
|
|
124
124
|
|
|
125
125
|
|
|
@@ -186,7 +186,7 @@ class DataPortal(OrdinaryCodePortal):
|
|
|
186
186
|
"""Clear the portal's state"""
|
|
187
187
|
self._value_store = None
|
|
188
188
|
self._config_settings = None
|
|
189
|
-
self.
|
|
189
|
+
self._auxiliary_config_params_at_init = None
|
|
190
190
|
self._invalidate_cache()
|
|
191
191
|
super()._clear()
|
|
192
192
|
|
|
@@ -195,14 +195,14 @@ class StorableFn(OrdinaryFn):
|
|
|
195
195
|
"""An ordinary function that can be persistently stored in a DataPortal."""
|
|
196
196
|
|
|
197
197
|
_addr_cache: ValueAddr
|
|
198
|
-
|
|
198
|
+
_auxiliary_config_params_at_init: dict[str, Any] | None
|
|
199
199
|
|
|
200
200
|
def __init__(self
|
|
201
201
|
, fn: Callable | str
|
|
202
202
|
, portal: DataPortal | None = None
|
|
203
203
|
):
|
|
204
204
|
OrdinaryFn.__init__(self, fn=fn, portal=portal)
|
|
205
|
-
self.
|
|
205
|
+
self._auxiliary_config_params_at_init = dict()
|
|
206
206
|
|
|
207
207
|
|
|
208
208
|
def _first_visit_to_portal(self, portal: DataPortal) -> None:
|
|
@@ -213,7 +213,7 @@ class StorableFn(OrdinaryFn):
|
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
def _persist_initial_config_params(self, portal:DataPortal) -> None:
|
|
216
|
-
for key, value in self.
|
|
216
|
+
for key, value in self._auxiliary_config_params_at_init.items():
|
|
217
217
|
self._set_config_setting(key, value, portal)
|
|
218
218
|
|
|
219
219
|
|
|
@@ -268,7 +268,7 @@ class StorableFn(OrdinaryFn):
|
|
|
268
268
|
def __setstate__(self, state):
|
|
269
269
|
"""This method is called when the object is unpickled."""
|
|
270
270
|
super().__setstate__(state)
|
|
271
|
-
self.
|
|
271
|
+
self._auxiliary_config_params_at_init = dict()
|
|
272
272
|
|
|
273
273
|
|
|
274
274
|
def __getstate__(self):
|
|
@@ -5,7 +5,7 @@ import traceback
|
|
|
5
5
|
from typing import Callable, Any
|
|
6
6
|
|
|
7
7
|
import pandas as pd
|
|
8
|
-
from parameterizable import register_parameterizable_class
|
|
8
|
+
# from parameterizable import register_parameterizable_class
|
|
9
9
|
from persidict import PersiDict, KEEP_CURRENT, Joker
|
|
10
10
|
|
|
11
11
|
from .._010_basic_portals import NotPicklable, get_active_portal
|
|
@@ -48,9 +48,9 @@ class LoggingFn(StorableFn):
|
|
|
48
48
|
f"got {type(excessive_logging)}")
|
|
49
49
|
|
|
50
50
|
if excessive_logging is KEEP_CURRENT and isinstance(fn, LoggingFn):
|
|
51
|
-
excessive_logging = fn.
|
|
51
|
+
excessive_logging = fn._auxiliary_config_params_at_init["excessive_logging"]
|
|
52
52
|
|
|
53
|
-
self.
|
|
53
|
+
self._auxiliary_config_params_at_init[
|
|
54
54
|
"excessive_logging"] = excessive_logging
|
|
55
55
|
|
|
56
56
|
|
|
@@ -545,7 +545,7 @@ class LoggingCodePortal(DataPortal):
|
|
|
545
545
|
"excessive_logging must be a boolean or Joker, "
|
|
546
546
|
f"got {type(excessive_logging)}")
|
|
547
547
|
|
|
548
|
-
self.
|
|
548
|
+
self._auxiliary_config_params_at_init["excessive_logging"
|
|
549
549
|
] = excessive_logging
|
|
550
550
|
|
|
551
551
|
crash_history_prototype = self._root_dict.get_subdict("crash_history")
|
|
@@ -611,7 +611,7 @@ class LoggingCodePortal(DataPortal):
|
|
|
611
611
|
super()._clear()
|
|
612
612
|
|
|
613
613
|
|
|
614
|
-
register_parameterizable_class(LoggingCodePortal)
|
|
614
|
+
# register_parameterizable_class(LoggingCodePortal)
|
|
615
615
|
|
|
616
616
|
|
|
617
617
|
def log_exception() -> None:
|
|
@@ -15,7 +15,7 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
from typing import Callable
|
|
17
17
|
|
|
18
|
-
from parameterizable import register_parameterizable_class
|
|
18
|
+
# from parameterizable import register_parameterizable_class
|
|
19
19
|
from persidict import PersiDict, Joker, KEEP_CURRENT
|
|
20
20
|
|
|
21
21
|
from .._040_logging_code_portals.logging_portal_core_classes import *
|
|
@@ -80,4 +80,4 @@ class SafeFn(LoggingFn):
|
|
|
80
80
|
return SafeFnCallSignature(fn=self, arguments=arguments)
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
register_parameterizable_class(SafeCodePortal)
|
|
83
|
+
# register_parameterizable_class(SafeCodePortal)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from contextlib import ExitStack, redirect_stderr, redirect_stdout
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class OutputSuppressor:
|
|
7
|
+
"""A context manager that suppresses stdout and stderr output."""
|
|
8
|
+
|
|
9
|
+
def __enter__(self):
|
|
10
|
+
"""Redirect stdout and stderr to os.devnull."""
|
|
11
|
+
self._stack = ExitStack()
|
|
12
|
+
devnull = self._stack.enter_context(open(os.devnull, "w"))
|
|
13
|
+
self._stack.enter_context(redirect_stdout(devnull))
|
|
14
|
+
self._stack.enter_context(redirect_stderr(devnull))
|
|
15
|
+
return self
|
|
16
|
+
|
|
17
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
18
|
+
return self._stack.__exit__(exc_type, exc_val, exc_tb)
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_090_swarming_portals/swarming_portals.py
RENAMED
|
@@ -12,13 +12,19 @@ at least once but does not offer any further guarantees.
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
import atexit
|
|
15
|
+
import json
|
|
15
16
|
from time import sleep
|
|
16
17
|
|
|
17
18
|
import pandas as pd
|
|
18
19
|
import parameterizable
|
|
19
|
-
from parameterizable import
|
|
20
|
+
from parameterizable import (
|
|
21
|
+
sort_dict_by_keys,
|
|
22
|
+
update_jsparams,
|
|
23
|
+
access_jsparams)
|
|
20
24
|
from persidict import PersiDict, Joker, KEEP_CURRENT
|
|
21
25
|
|
|
26
|
+
from parameterizable.json_processor import _Markers
|
|
27
|
+
|
|
22
28
|
from .. import VALIDATION_SUCCESSFUL
|
|
23
29
|
from .._010_basic_portals import get_all_known_portals
|
|
24
30
|
from .._070_protected_code_portals.system_utils import get_unused_ram_mb, get_unused_cpu_cores, process_is_active, \
|
|
@@ -66,7 +72,7 @@ class SwarmingPortal(PureCodePortal):
|
|
|
66
72
|
if parent_process_id is None or parent_process_start_time is None:
|
|
67
73
|
assert parent_process_id is None
|
|
68
74
|
assert parent_process_start_time is None
|
|
69
|
-
self.
|
|
75
|
+
self._auxiliary_config_params_at_init["max_n_workers"
|
|
70
76
|
] = max_n_workers
|
|
71
77
|
else:
|
|
72
78
|
assert max_n_workers == 0
|
|
@@ -88,6 +94,14 @@ class SwarmingPortal(PureCodePortal):
|
|
|
88
94
|
self._child_process = None
|
|
89
95
|
|
|
90
96
|
|
|
97
|
+
def get_params(self) -> dict:
|
|
98
|
+
params = super().get_params()
|
|
99
|
+
params["parent_process_id"] = self._parent_process_id
|
|
100
|
+
params["parent_process_start_time"] = self._parent_process_start_time
|
|
101
|
+
sorted_params = sort_dict_by_keys(params)
|
|
102
|
+
return sorted_params
|
|
103
|
+
|
|
104
|
+
|
|
91
105
|
@property
|
|
92
106
|
def is_parent(self) -> bool:
|
|
93
107
|
"""Check if this portal is the parent process."""
|
|
@@ -106,14 +120,14 @@ class SwarmingPortal(PureCodePortal):
|
|
|
106
120
|
if self.is_parent:
|
|
107
121
|
if self.max_n_workers > 0:
|
|
108
122
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
portal_init_jsparams = parameterizable.dumpjs(self)
|
|
124
|
+
portal_init_jsparams = update_jsparams(portal_init_jsparams,
|
|
125
|
+
max_n_workers = self.max_n_workers)
|
|
112
126
|
|
|
113
127
|
ctx = get_context("spawn")
|
|
114
128
|
self._child_process = ctx.Process(
|
|
115
129
|
target=_launch_many_background_workers
|
|
116
|
-
,
|
|
130
|
+
, args=(portal_init_jsparams,))
|
|
117
131
|
self._child_process.start()
|
|
118
132
|
|
|
119
133
|
|
|
@@ -198,22 +212,22 @@ class SwarmingPortal(PureCodePortal):
|
|
|
198
212
|
del self._max_n_workers_cache
|
|
199
213
|
super()._invalidate_cache()
|
|
200
214
|
|
|
201
|
-
parameterizable.register_parameterizable_class(SwarmingPortal)
|
|
215
|
+
# parameterizable.register_parameterizable_class(SwarmingPortal)
|
|
202
216
|
|
|
203
217
|
|
|
204
|
-
def _launch_many_background_workers(
|
|
218
|
+
def _launch_many_background_workers(portal_init_jsparams:JsonSerializedParams) -> None:
|
|
205
219
|
"""Launch many background worker processes."""
|
|
206
|
-
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
n_workers_to_launch = access_jsparams(portal_init_jsparams
|
|
223
|
+
, "max_n_workers")["max_n_workers"]
|
|
207
224
|
n_workers_to_launch = int(n_workers_to_launch)
|
|
208
225
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
portal_init_params = sort_dict_by_keys(portal_init_params)
|
|
215
|
-
portal = parameterizable.get_object_from_portable_params(
|
|
216
|
-
portal_init_params)
|
|
226
|
+
portal_init_jsparams = update_jsparams(portal_init_jsparams,
|
|
227
|
+
max_n_workers=0, parent_process_id = get_current_process_id(),
|
|
228
|
+
parent_process_start_time = get_current_process_start_time())
|
|
229
|
+
|
|
230
|
+
portal = parameterizable.loadjs(portal_init_jsparams)
|
|
217
231
|
assert isinstance(portal, SwarmingPortal)
|
|
218
232
|
|
|
219
233
|
summary = build_execution_environment_summary()
|
|
@@ -226,7 +240,7 @@ def _launch_many_background_workers(**portal_init_params) -> None:
|
|
|
226
240
|
portal._randomly_delay_execution(p=1)
|
|
227
241
|
ctx = get_context("spawn")
|
|
228
242
|
try:
|
|
229
|
-
p = ctx.Process(target=_background_worker,
|
|
243
|
+
p = ctx.Process(target=_background_worker, args=(portal_init_jsparams,))
|
|
230
244
|
p.start()
|
|
231
245
|
list_of_all_workers.append(p)
|
|
232
246
|
except Exception as e:
|
|
@@ -243,7 +257,7 @@ def _launch_many_background_workers(**portal_init_params) -> None:
|
|
|
243
257
|
portal._randomly_delay_execution(p=1)
|
|
244
258
|
ctx = get_context("spawn")
|
|
245
259
|
try:
|
|
246
|
-
p = ctx.Process(target=_background_worker,
|
|
260
|
+
p = ctx.Process(target=_background_worker, args=(portal_init_jsparams,))
|
|
247
261
|
p.start()
|
|
248
262
|
new_list_of_all_workers.append(p)
|
|
249
263
|
except Exception as e:
|
|
@@ -251,10 +265,9 @@ def _launch_many_background_workers(**portal_init_params) -> None:
|
|
|
251
265
|
list_of_all_workers = new_list_of_all_workers
|
|
252
266
|
|
|
253
267
|
|
|
254
|
-
def _background_worker(
|
|
268
|
+
def _background_worker(portal_init_jsparams:JsonSerializedParams) -> None:
|
|
255
269
|
"""Background worker that keeps processing random execution requests."""
|
|
256
|
-
portal = parameterizable.
|
|
257
|
-
portal_init_params)
|
|
270
|
+
portal = parameterizable.loadjs(portal_init_jsparams)
|
|
258
271
|
assert isinstance(portal, SwarmingPortal)
|
|
259
272
|
with portal:
|
|
260
273
|
ctx = get_context("spawn")
|
|
@@ -264,16 +277,19 @@ def _background_worker(**portal_init_params) -> None:
|
|
|
264
277
|
return
|
|
265
278
|
p = ctx.Process(
|
|
266
279
|
target=_process_random_execution_request
|
|
267
|
-
,
|
|
280
|
+
, args=(portal_init_jsparams,))
|
|
268
281
|
p.start()
|
|
269
282
|
p.join()
|
|
270
283
|
portal._randomly_delay_execution()
|
|
271
284
|
|
|
272
285
|
|
|
273
|
-
def _process_random_execution_request(
|
|
286
|
+
def _process_random_execution_request(portal_init_jsparams:JsonSerializedParams):
|
|
274
287
|
"""Process one random execution request."""
|
|
275
|
-
portal = parameterizable.get_object_from_portable_params(
|
|
276
|
-
|
|
288
|
+
# portal = parameterizable.get_object_from_portable_params(
|
|
289
|
+
# portal_init_params)
|
|
290
|
+
portal_init_jsparams = update_jsparams(
|
|
291
|
+
portal_init_jsparams, max_n_workers=0)
|
|
292
|
+
portal = parameterizable.loadjs(portal_init_jsparams)
|
|
277
293
|
assert isinstance(portal, SwarmingPortal)
|
|
278
294
|
with portal:
|
|
279
295
|
call_signature:PureFnCallSignature|None = None
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class OutputSuppressor:
|
|
6
|
-
"""A context manager that suppresses stdout and stderr output."""
|
|
7
|
-
def __init__(self):
|
|
8
|
-
pass
|
|
9
|
-
|
|
10
|
-
def __enter__(self):
|
|
11
|
-
"""Redirect stdout and stderr to os.devnull."""
|
|
12
|
-
self.old_stdout = sys.stdout
|
|
13
|
-
self.old_stderr = sys.stderr
|
|
14
|
-
self.devnull = open(os.devnull, 'w')
|
|
15
|
-
sys.stdout = self.devnull
|
|
16
|
-
sys.stderr = self.devnull
|
|
17
|
-
return self
|
|
18
|
-
|
|
19
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
20
|
-
sys.stdout = self.old_stdout
|
|
21
|
-
sys.stderr = self.old_stderr
|
|
22
|
-
if self.devnull:
|
|
23
|
-
self.devnull.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/not_picklable_class.py
RENAMED
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_010_basic_portals/post_init_metaclass.py
RENAMED
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/__init__.py
RENAMED
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_020_ordinary_code_portals/code_normalizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_030_data_portals/storable_decorator.py
RENAMED
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/notebook_checker.py
RENAMED
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_040_logging_code_portals/output_capturer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_050_safe_code_portals/safe_decorator.py
RENAMED
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_060_autonomous_code_portals/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/list_flattener.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_070_protected_code_portals/system_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_080_pure_code_portals/pure_core_classes.py
RENAMED
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_080_pure_code_portals/pure_decorator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_100_top_level_API/default_local_portal.py
RENAMED
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_800_signatures_and_converters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythagoras-0.24.0 → pythagoras-0.24.2}/src/pythagoras/_900_project_stats_collector/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|