code-loader 1.0.187.dev0__py3-none-any.whl → 1.0.188.dev1__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.
- code_loader/inner_leap_binder/leapbinder.py +0 -36
- code_loader/leaploader.py +17 -0
- code_loader-1.0.188.dev1.dist-info/LICENSE +21 -0
- {code_loader-1.0.187.dev0.dist-info → code_loader-1.0.188.dev1.dist-info}/METADATA +3 -3
- {code_loader-1.0.187.dev0.dist-info → code_loader-1.0.188.dev1.dist-info}/RECORD +7 -6
- {code_loader-1.0.187.dev0.dist-info → code_loader-1.0.188.dev1.dist-info}/WHEEL +1 -1
- /code_loader-1.0.187.dev0.dist-info/LICENSE → /LICENSE +0 -0
|
@@ -31,31 +31,6 @@ from code_loader.visualizers.default_visualizers import DefaultVisualizer, \
|
|
|
31
31
|
mapping_runtime_mode_env_var_mame = '__MAPPING_RUNTIME_MODE__'
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
def _stringized_annotation_type_name(annotation: Any) -> Optional[str]:
|
|
35
|
-
"""Return the bare type name when ``annotation`` is a *stringized* annotation
|
|
36
|
-
(e.g. produced by ``from __future__ import annotations`` or a quoted hint),
|
|
37
|
-
otherwise ``None``. code_loader inspects raw annotations expecting real classes,
|
|
38
|
-
so a stringized annotation silently breaks type detection."""
|
|
39
|
-
if isinstance(annotation, str):
|
|
40
|
-
return annotation.split("[")[0].strip().rsplit(".", 1)[-1]
|
|
41
|
-
return None
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def _reject_stringized_sample_preprocess_response(function: Callable, arg_name: str, annotation: Any) -> None:
|
|
45
|
-
"""Fail fast when a ``SamplePreprocessResponse`` argument was stringized. Otherwise
|
|
46
|
-
``arg_type == SamplePreprocessResponse`` silently evaluates to ``False`` and the
|
|
47
|
-
argument is mis-wired as a regular input — a bug that only surfaces on the platform.
|
|
48
|
-
Fires only on the actual damage (a stringized SamplePreprocessResponse), not merely
|
|
49
|
-
because the file uses future annotations."""
|
|
50
|
-
if _stringized_annotation_type_name(annotation) == SamplePreprocessResponse.__name__:
|
|
51
|
-
raise Exception(
|
|
52
|
-
f"Argument '{arg_name}' of function '{function.__name__}' is annotated with a string "
|
|
53
|
-
f"('{annotation}') instead of the SamplePreprocessResponse type. This usually means the "
|
|
54
|
-
f"file uses 'from __future__ import annotations' (or a quoted hint), which stringizes "
|
|
55
|
-
f"annotations and breaks Tensorleap type detection. Remove that import (or the quotes) so "
|
|
56
|
-
f"SamplePreprocessResponse is referenced as a real type.")
|
|
57
|
-
|
|
58
|
-
|
|
59
34
|
|
|
60
35
|
|
|
61
36
|
class LeapBinder:
|
|
@@ -148,7 +123,6 @@ class LeapBinder:
|
|
|
148
123
|
regular_arg_names = inspect.getfullargspec(function)[0]
|
|
149
124
|
preprocess_response_arg_name = None
|
|
150
125
|
for arg_name, arg_type in inspect.getfullargspec(function).annotations.items():
|
|
151
|
-
_reject_stringized_sample_preprocess_response(function, arg_name, arg_type)
|
|
152
126
|
if arg_type == SamplePreprocessResponse:
|
|
153
127
|
if preprocess_response_arg_name is not None:
|
|
154
128
|
raise Exception("only one argument can be of type SamplePreprocessResponse")
|
|
@@ -181,13 +155,6 @@ class LeapBinder:
|
|
|
181
155
|
f"https://docs.python.org/3/library/typing.html")
|
|
182
156
|
else:
|
|
183
157
|
return_type = func_annotations["return"]
|
|
184
|
-
if isinstance(return_type, str):
|
|
185
|
-
raise Exception(
|
|
186
|
-
f"The return type hint of function '{function.__name__}' is a string "
|
|
187
|
-
f"('{return_type}') instead of a type. This usually means the file uses "
|
|
188
|
-
f"'from __future__ import annotations' (or a quoted return hint), which stringizes "
|
|
189
|
-
f"annotations and prevents Tensorleap from detecting the visualizer type. Remove "
|
|
190
|
-
f"that import (or the quotes) so the return type is a real class.")
|
|
191
158
|
if return_type not in LeapData.__args__: # type: ignore[attr-defined]
|
|
192
159
|
raise Exception(
|
|
193
160
|
f'The return type of function {function.__name__} is invalid. current return type: {return_type}, ' # type: ignore[attr-defined]
|
|
@@ -329,7 +296,6 @@ class LeapBinder:
|
|
|
329
296
|
regular_arg_names = inspect.getfullargspec(function)[0]
|
|
330
297
|
preprocess_response_arg_name = None
|
|
331
298
|
for arg_name, arg_type in inspect.getfullargspec(function).annotations.items():
|
|
332
|
-
_reject_stringized_sample_preprocess_response(function, arg_name, arg_type)
|
|
333
299
|
if arg_type == SamplePreprocessResponse:
|
|
334
300
|
if preprocess_response_arg_name is not None:
|
|
335
301
|
raise Exception("only one argument can be of type SamplePreprocessResponse")
|
|
@@ -373,7 +339,6 @@ class LeapBinder:
|
|
|
373
339
|
regular_arg_names = inspect.getfullargspec(function)[0]
|
|
374
340
|
preprocess_response_arg_name = None
|
|
375
341
|
for arg_name, arg_type in inspect.getfullargspec(function).annotations.items():
|
|
376
|
-
_reject_stringized_sample_preprocess_response(function, arg_name, arg_type)
|
|
377
342
|
if arg_type == SamplePreprocessResponse:
|
|
378
343
|
if preprocess_response_arg_name is not None:
|
|
379
344
|
raise Exception("only one argument can be of type SamplePreprocessResponse")
|
|
@@ -415,7 +380,6 @@ class LeapBinder:
|
|
|
415
380
|
regular_arg_names = inspect.getfullargspec(function)[0]
|
|
416
381
|
preprocess_response_arg_name = None
|
|
417
382
|
for arg_name, arg_type in inspect.getfullargspec(function).annotations.items():
|
|
418
|
-
_reject_stringized_sample_preprocess_response(function, arg_name, arg_type)
|
|
419
383
|
if arg_type == SamplePreprocessResponse:
|
|
420
384
|
if preprocess_response_arg_name is not None:
|
|
421
385
|
raise Exception("only one argument can be of type SamplePreprocessResponse")
|
code_loader/leaploader.py
CHANGED
|
@@ -64,6 +64,9 @@ class LeapLoader(LeapLoaderBase):
|
|
|
64
64
|
self.evaluate_module()
|
|
65
65
|
if global_leap_binder.integration_test_func is not None:
|
|
66
66
|
global_leap_binder.integration_test_func(None, PreprocessResponse(state=DataStateType.training, length=0))
|
|
67
|
+
except DatasetScriptException:
|
|
68
|
+
global_leap_binder.setup_container = DatasetIntegrationSetup()
|
|
69
|
+
raise
|
|
67
70
|
except TypeError as e:
|
|
68
71
|
import traceback
|
|
69
72
|
global_leap_binder.setup_container = DatasetIntegrationSetup()
|
|
@@ -85,10 +88,17 @@ class LeapLoader(LeapLoaderBase):
|
|
|
85
88
|
return
|
|
86
89
|
|
|
87
90
|
parent_path = str(Path(full_path).parent)
|
|
91
|
+
if parent_path == full_path:
|
|
92
|
+
return
|
|
88
93
|
append_path_recursively(parent_path)
|
|
89
94
|
sys.path.append(parent_path)
|
|
90
95
|
|
|
91
96
|
file_path = Path(self.code_path, self.code_entry_name)
|
|
97
|
+
if not file_path.is_file():
|
|
98
|
+
raise DatasetScriptException(
|
|
99
|
+
f"Entry file not found: '{self.code_entry_name}' does not exist under '{self.code_path}'. "
|
|
100
|
+
f"Check the 'entryFile' setting in your leap.yaml."
|
|
101
|
+
)
|
|
92
102
|
append_path_recursively(str(file_path))
|
|
93
103
|
|
|
94
104
|
importlib.invalidate_caches()
|
|
@@ -103,6 +113,13 @@ class LeapLoader(LeapLoaderBase):
|
|
|
103
113
|
|
|
104
114
|
spec.loader.exec_module(file)
|
|
105
115
|
|
|
116
|
+
if global_leap_binder.setup_container.preprocess is None:
|
|
117
|
+
raise DatasetScriptException(
|
|
118
|
+
f"No Tensorleap integration found in '{self.code_entry_name}': the script never called "
|
|
119
|
+
f"leap_binder.set_preprocess(...). Check the 'entryFile' setting in your leap.yaml — "
|
|
120
|
+
f"it may be pointing to the wrong file."
|
|
121
|
+
)
|
|
122
|
+
|
|
106
123
|
@lru_cache()
|
|
107
124
|
def metric_by_name(self) -> Dict[str, MetricHandlerData]:
|
|
108
125
|
self.exec_script()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 TensorLeap
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: code-loader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.188.dev1
|
|
4
4
|
Summary:
|
|
5
|
+
Home-page: https://github.com/tensorleap/code-loader
|
|
5
6
|
License: MIT
|
|
6
7
|
Author: dorhar
|
|
7
8
|
Author-email: doron.harnoy@tensorleap.ai
|
|
@@ -19,7 +20,6 @@ Requires-Dist: numpy (>=2.3.2,<3.0.0) ; python_version >= "3.11" and python_vers
|
|
|
19
20
|
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
|
20
21
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
21
22
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
22
|
-
Project-URL: Homepage, https://github.com/tensorleap/code-loader
|
|
23
23
|
Project-URL: Repository, https://github.com/tensorleap/code-loader
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
1
2
|
code_loader/__init__.py,sha256=outxRQ0M-zMfV0QGVJmAed5qWfRmyD0TV6-goEGAzBw,406
|
|
2
3
|
code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
4
|
code_loader/contract/datasetclasses.py,sha256=RYZcnX7vLMYhyQtCbX2PscVFNAYULxgAA9U4DRRfLqA,10456
|
|
@@ -20,9 +21,9 @@ code_loader/experiment_api/types.py,sha256=MY8xFARHwdVA7p4dxyhD60ShmttgTvb4qdp1o
|
|
|
20
21
|
code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZJEqBqc,3304
|
|
21
22
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
|
22
23
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
|
23
|
-
code_loader/inner_leap_binder/leapbinder.py,sha256=
|
|
24
|
+
code_loader/inner_leap_binder/leapbinder.py,sha256=XLYYcV50qjMvoC1S6WW0tLBch_0g5gl1UyHiVSWYbvg,40491
|
|
24
25
|
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=qfKa--0kG_K_Eb8wRd5tIXEJ6rbKva3360gU8EU9eKo,118375
|
|
25
|
-
code_loader/leaploader.py,sha256=
|
|
26
|
+
code_loader/leaploader.py,sha256=ZHfYzGpmb_XrZbzBkn12Mh0CE4tDFcFK-PdrfrmJjHo,45536
|
|
26
27
|
code_loader/leaploaderbase.py,sha256=l36qDA00GhZEG5NLKpEtAXgWJA-UQQIhNFGxywK7mUA,6530
|
|
27
28
|
code_loader/mixpanel_tracker.py,sha256=rNwRmFifNbdUoqLQvvhhgpKczWpWiEmd8MfyJe27sxw,9131
|
|
28
29
|
code_loader/plot_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -31,7 +32,7 @@ code_loader/plot_functions/visualize.py,sha256=gsBAYYkwMh7jIpJeDMPS8G4CW-pxwx6Lz
|
|
|
31
32
|
code_loader/utils.py,sha256=YecipkdTA-VcE9F0RQcY9cFnY8P3AksPnHM2Db7xUSk,3972
|
|
32
33
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
34
|
code_loader/visualizers/default_visualizers.py,sha256=onRnLE_TXfgLN4o52hQIOOhUcFexGlqJ3xSpQDVLuZM,2604
|
|
34
|
-
code_loader-1.0.
|
|
35
|
-
code_loader-1.0.
|
|
36
|
-
code_loader-1.0.
|
|
37
|
-
code_loader-1.0.
|
|
35
|
+
code_loader-1.0.188.dev1.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
36
|
+
code_loader-1.0.188.dev1.dist-info/METADATA,sha256=7iylr6wh5362UPoXBVadO3qrOw-lXaaotywDkMoJqoY,1095
|
|
37
|
+
code_loader-1.0.188.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
38
|
+
code_loader-1.0.188.dev1.dist-info/RECORD,,
|
|
File without changes
|