machineconfig 6.29__py3-none-any.whl → 6.31__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.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/cluster/sessions_managers/utils/maker.py +4 -3
- machineconfig/utils/scheduler.py +24 -38
- {machineconfig-6.29.dist-info → machineconfig-6.31.dist-info}/METADATA +1 -1
- {machineconfig-6.29.dist-info → machineconfig-6.31.dist-info}/RECORD +7 -7
- {machineconfig-6.29.dist-info → machineconfig-6.31.dist-info}/WHEEL +0 -0
- {machineconfig-6.29.dist-info → machineconfig-6.31.dist-info}/entry_points.txt +0 -0
- {machineconfig-6.29.dist-info → machineconfig-6.31.dist-info}/top_level.txt +0 -0
|
@@ -20,11 +20,12 @@ def get_fire_command_and_artifact_files(func: FunctionType):
|
|
|
20
20
|
}
|
|
21
21
|
return tab_config, py_script_path
|
|
22
22
|
def get_fire_command_and_artifact_files_v2(func: FunctionType):
|
|
23
|
-
import
|
|
24
|
-
|
|
23
|
+
import inspect
|
|
24
|
+
path = inspect.getfile(func)
|
|
25
|
+
command_to_run = f"""$HOME/.local/bin/fire {path} {func.__name__} """
|
|
25
26
|
tab_config: TabConfig = {
|
|
26
27
|
"command": command_to_run,
|
|
27
|
-
"startDir":
|
|
28
|
+
"startDir": "$HOME",
|
|
28
29
|
"tabName": func.__name__
|
|
29
30
|
}
|
|
30
31
|
return tab_config
|
machineconfig/utils/scheduler.py
CHANGED
|
@@ -146,8 +146,6 @@ class Scheduler:
|
|
|
146
146
|
|
|
147
147
|
# T = TypeVar("T")
|
|
148
148
|
T2 = TypeVar("T2")
|
|
149
|
-
|
|
150
|
-
|
|
151
149
|
def to_pickle(obj: Any, path: Path) -> None:
|
|
152
150
|
import pickle
|
|
153
151
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -156,11 +154,11 @@ def to_pickle(obj: Any, path: Path) -> None:
|
|
|
156
154
|
|
|
157
155
|
class Cache[T](): # This class helps to accelrate access to latest data coming from expensive function. The class has two flavours, memory-based and disk-based variants."""
|
|
158
156
|
def __init__(
|
|
159
|
-
self, source_func: Callable[[], T], expire: timedelta, logger: LoggerTemplate, path:
|
|
157
|
+
self, source_func: Callable[[], T], expire: timedelta, logger: LoggerTemplate, path: Path, saver: Callable[[T, Path], Any] = to_pickle, reader: Callable[[Path], T] = from_pickle, name: Optional[str] = None
|
|
160
158
|
) -> None:
|
|
161
159
|
self.cache: T
|
|
162
160
|
self.source_func = source_func # function which when called returns a fresh object to be frozen.
|
|
163
|
-
self.path:
|
|
161
|
+
self.path: PathExtended = PathExtended(path)
|
|
164
162
|
self.time_produced = datetime.now() # if path is None else
|
|
165
163
|
self.save = saver
|
|
166
164
|
self.reader = reader
|
|
@@ -172,21 +170,11 @@ class Cache[T](): # This class helps to accelrate access to latest data coming
|
|
|
172
170
|
@property
|
|
173
171
|
def age(self):
|
|
174
172
|
"""Throws AttributeError if called before cache is populated and path doesn't exists"""
|
|
175
|
-
|
|
176
|
-
return datetime.now() - self.time_produced
|
|
177
|
-
return datetime.now() - datetime.fromtimestamp(self.path.stat().st_mtime)
|
|
178
|
-
|
|
179
|
-
# def __setstate__(self, state: dict[str, Any]) -> None:
|
|
180
|
-
# self.__dict__.update(state)
|
|
181
|
-
# self.path = P.home() / self.path if self.path is not None else self.path
|
|
182
|
-
# def __getstate__(self) -> dict[str, Any]:
|
|
183
|
-
# state = self.__dict__.copy()
|
|
184
|
-
# state["path"] = self.path.rel2home() if self.path is not None else state["path"]
|
|
185
|
-
# return state # With this implementation, instances can be pickled and loaded up in different machine and still works.
|
|
173
|
+
return datetime.now() - self.time_produced
|
|
186
174
|
def __call__(self, fresh: bool = False) -> T:
|
|
187
175
|
self.last_call_is_fresh = False
|
|
188
176
|
if fresh or not hasattr(self, "cache"): # populate cache for the first time
|
|
189
|
-
if not fresh and self.path
|
|
177
|
+
if not fresh and self.path.exists():
|
|
190
178
|
age = datetime.now() - datetime.fromtimestamp(self.path.stat().st_mtime)
|
|
191
179
|
msg1 = f"""
|
|
192
180
|
📦 ════════════════════ CACHE OPERATION ════════════════════
|
|
@@ -225,8 +213,7 @@ class Cache[T](): # This class helps to accelrate access to latest data coming
|
|
|
225
213
|
self.cache = self.source_func() # fresh data.
|
|
226
214
|
self.last_call_is_fresh = True
|
|
227
215
|
self.time_produced = datetime.now()
|
|
228
|
-
|
|
229
|
-
self.save(self.cache, self.path)
|
|
216
|
+
self.save(self.cache, self.path)
|
|
230
217
|
else: # cache exists
|
|
231
218
|
try:
|
|
232
219
|
age = self.age
|
|
@@ -242,8 +229,7 @@ class Cache[T](): # This class helps to accelrate access to latest data coming
|
|
|
242
229
|
self.cache = self.source_func()
|
|
243
230
|
self.last_call_is_fresh = True
|
|
244
231
|
self.time_produced = datetime.now()
|
|
245
|
-
|
|
246
|
-
self.save(self.cache, self.path)
|
|
232
|
+
self.save(self.cache, self.path)
|
|
247
233
|
else:
|
|
248
234
|
if self.logger:
|
|
249
235
|
self.logger.warning(f"""
|
|
@@ -255,7 +241,7 @@ class Cache[T](): # This class helps to accelrate access to latest data coming
|
|
|
255
241
|
|
|
256
242
|
@staticmethod
|
|
257
243
|
def as_decorator(
|
|
258
|
-
expire: timedelta, logger: LoggerTemplate, path:
|
|
244
|
+
expire: timedelta, logger: LoggerTemplate, path: Path, saver: Callable[[T2, Path], Any] = to_pickle, reader: Callable[[Path], T2] = from_pickle, name: Optional[str] = None
|
|
259
245
|
): # -> Callable[..., 'Cache[T2]']:
|
|
260
246
|
def decorator(source_func: Callable[[], T2]) -> Cache["T2"]:
|
|
261
247
|
res = Cache(source_func=source_func, expire=expire, logger=logger, path=path, name=name, reader=reader, saver=saver)
|
|
@@ -263,20 +249,20 @@ class Cache[T](): # This class helps to accelrate access to latest data coming
|
|
|
263
249
|
|
|
264
250
|
return decorator
|
|
265
251
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
⚠️ ════════════════════ CLOUD FETCH WARNING ════════════════════
|
|
277
|
-
🔄 Failed to get fresh data from cloud
|
|
278
|
-
📦 Using old cache @ {self.path}
|
|
279
|
-
════════════════════════════════════════════════════════════════""")
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
252
|
+
# def from_cloud(self, cloud: str, rel2home: bool = True, root: Optional[str] = None):
|
|
253
|
+
# assert self.path is not None
|
|
254
|
+
# exists = self.path.exists()
|
|
255
|
+
# exists_but_old = exists and ((datetime.now() - datetime.fromtimestamp(self.path.stat().st_mtime)) > self.expire)
|
|
256
|
+
# if not exists or exists_but_old:
|
|
257
|
+
# returned_path = self.path.from_cloud(cloud=cloud, rel2home=rel2home, root=root)
|
|
258
|
+
# if returned_path is None and not exists:
|
|
259
|
+
# raise FileNotFoundError(f"❌ Failed to get @ {self.path}. Build the cache first with signed API.")
|
|
260
|
+
# elif returned_path is None and exists:
|
|
261
|
+
# self.logger.warning(f"""
|
|
262
|
+
# ⚠️ ════════════════════ CLOUD FETCH WARNING ════════════════════
|
|
263
|
+
# 🔄 Failed to get fresh data from cloud
|
|
264
|
+
# 📦 Using old cache @ {self.path}
|
|
265
|
+
# ════════════════════════════════════════════════════════════════""")
|
|
266
|
+
# else:
|
|
267
|
+
# pass # maybe we don't need to fetch it from cloud, if its too hot
|
|
268
|
+
# return self.reader(self.path)
|
|
@@ -25,7 +25,7 @@ machineconfig/cluster/sessions_managers/zellij_remote_manager.py,sha256=xzih0y8_
|
|
|
25
25
|
machineconfig/cluster/sessions_managers/helpers/enhanced_command_runner.py,sha256=3vcQVg-HHa_WTxBGPtKMAdoSqJVa2EO5KAtrY8a6I3c,5264
|
|
26
26
|
machineconfig/cluster/sessions_managers/helpers/load_balancer_helper.py,sha256=i5TRittC1IWTgMZNyG8AR5qq-3WrGp3xgIx2m5ktT7g,7526
|
|
27
27
|
machineconfig/cluster/sessions_managers/utils/load_balancer.py,sha256=Y4RQmhROY6o7JXSJXRrBTkoAuEmu1gvmvN_7JKPw5sc,3178
|
|
28
|
-
machineconfig/cluster/sessions_managers/utils/maker.py,sha256=
|
|
28
|
+
machineconfig/cluster/sessions_managers/utils/maker.py,sha256=HlMAWB0z8iMR-VRjvEHpjE8-Q5Wt7Bl86fBWvYLk-Cs,2074
|
|
29
29
|
machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py,sha256=OA50j16uUS9ZTjL38TLuR3jufIOln_EszMZpbWyejTo,6972
|
|
30
30
|
machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py,sha256=Mitm7mKiKl5lT0OiEUHAqVg2Q21RjsKO1-hpJTHJ5lM,15196
|
|
31
31
|
machineconfig/cluster/sessions_managers/wt_utils/remote_executor.py,sha256=lApUy67_WhfaBXqt0meZSx_QvwiXjN0YLdyE3c7kP_s,6744
|
|
@@ -394,7 +394,7 @@ machineconfig/utils/options.py,sha256=vUO4Kej-vDOv64wHr2HNDyu6PATURpjd7xp6N8OOoJ
|
|
|
394
394
|
machineconfig/utils/path_extended.py,sha256=WyJwoHnXdvSQQJ-yrxTX78FpqYmgVeKDYpNEB9UsRck,53223
|
|
395
395
|
machineconfig/utils/path_helper.py,sha256=0e3Xh3BAEv27oqcezNeVLHJllGmLEgLH4T1l90m-650,8014
|
|
396
396
|
machineconfig/utils/procs.py,sha256=rw8LR8MjGgvtrpcgxb3hudq2B9fkkpYUXe9x5-FgHuc,10694
|
|
397
|
-
machineconfig/utils/scheduler.py,sha256=
|
|
397
|
+
machineconfig/utils/scheduler.py,sha256=u56Y0UOIq-0WcwzScwjoiKFzBV47Lx--4lR52UD3y0M,14089
|
|
398
398
|
machineconfig/utils/scheduling.py,sha256=RF1iXJpqf4Dg18jdZWtBixz97KAHC6VKYqTFSpdLWuc,11188
|
|
399
399
|
machineconfig/utils/source_of_truth.py,sha256=ZAnCRltiM07ig--P6g9_6nEAvNFC4X4ERFTVcvpIYsE,764
|
|
400
400
|
machineconfig/utils/ssh.py,sha256=dO-FereJBh5mB4zmL_fDIfQ6VVCWpJ3Y8IoAJ5SA4zQ,39079
|
|
@@ -422,8 +422,8 @@ machineconfig/utils/schemas/installer/installer_types.py,sha256=QClRY61QaduBPJoS
|
|
|
422
422
|
machineconfig/utils/schemas/layouts/layout_types.py,sha256=TcqlZdGVoH8htG5fHn1KWXhRdPueAcoyApppZsPAPto,2020
|
|
423
423
|
machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
|
|
424
424
|
machineconfig/utils/ssh_utils/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
425
|
-
machineconfig-6.
|
|
426
|
-
machineconfig-6.
|
|
427
|
-
machineconfig-6.
|
|
428
|
-
machineconfig-6.
|
|
429
|
-
machineconfig-6.
|
|
425
|
+
machineconfig-6.31.dist-info/METADATA,sha256=T8RD3gAr2SEH8yUy18IfZE73l3rSWo7yGTh25b8VHrc,3012
|
|
426
|
+
machineconfig-6.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
427
|
+
machineconfig-6.31.dist-info/entry_points.txt,sha256=M0jwN_brZdXWhmNVeXLvdKxfkv8WhhXFZYcuKBA9qnk,418
|
|
428
|
+
machineconfig-6.31.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
|
|
429
|
+
machineconfig-6.31.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|