code-loader 1.0.68a0__tar.gz → 1.0.69__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.
- {code_loader-1.0.68a0 → code_loader-1.0.69}/PKG-INFO +1 -1
- code_loader-1.0.69/code_loader/code_inegration_processes_manager.py +83 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/contract/datasetclasses.py +0 -1
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/inner_leap_binder/leapbinder.py +7 -7
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/inner_leap_binder/leapbinder_decorators.py +1 -1
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/leaploader.py +2 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/pyproject.toml +1 -1
- {code_loader-1.0.68a0 → code_loader-1.0.69}/LICENSE +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/README.md +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/__init__.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/utils.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/visualizers/default_visualizers.py +0 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
# mypy: ignore-errors
|
2
|
+
import traceback
|
3
|
+
from dataclasses import dataclass
|
4
|
+
|
5
|
+
from typing import List, Tuple, Optional
|
6
|
+
|
7
|
+
from multiprocessing import Process, Queue
|
8
|
+
|
9
|
+
from code_loader.leap_loader_parallelized_base import LeapLoaderParallelizedBase
|
10
|
+
from code_loader.leaploader import LeapLoader
|
11
|
+
from code_loader.contract.enums import DataStateEnum
|
12
|
+
from code_loader.metric_calculator_parallelized import MetricCalculatorParallelized
|
13
|
+
from code_loader.samples_generator_parallelized import SamplesGeneratorParallelized
|
14
|
+
|
15
|
+
|
16
|
+
@dataclass
|
17
|
+
class SampleSerializableError:
|
18
|
+
state: DataStateEnum
|
19
|
+
index: int
|
20
|
+
leap_script_trace: str
|
21
|
+
exception_as_str: str
|
22
|
+
|
23
|
+
|
24
|
+
class CodeIntegrationProcessesManager:
|
25
|
+
def __init__(self, code_path: str, code_entry_name: str, n_workers: Optional[int] = 2,
|
26
|
+
max_samples_in_queue: int = 128) -> None:
|
27
|
+
self.metric_calculator_parallelized = MetricCalculatorParallelized(code_path, code_entry_name)
|
28
|
+
self.samples_generator_parallelized = SamplesGeneratorParallelized(code_path, code_entry_name)
|
29
|
+
|
30
|
+
def _create_and_start_process(self) -> Process:
|
31
|
+
process = self.multiprocessing_context.Process(
|
32
|
+
target=CodeIntegrationProcessesManager._process_func,
|
33
|
+
args=(self.code_path, self.code_entry_name, self._inputs_waiting_to_be_process,
|
34
|
+
self._ready_processed_results))
|
35
|
+
process.daemon = True
|
36
|
+
process.start()
|
37
|
+
return process
|
38
|
+
|
39
|
+
def _run_and_warm_first_process(self):
|
40
|
+
process = self._create_and_start_process()
|
41
|
+
self.processes = [process]
|
42
|
+
|
43
|
+
# needed in order to make sure the preprocess func runs once in nonparallel
|
44
|
+
self._start_process_inputs([(DataStateEnum.training, 0)])
|
45
|
+
self._get_next_ready_processed_result()
|
46
|
+
|
47
|
+
def _operation_decider(self):
|
48
|
+
if self.metric_calculator_parallelized._ready_processed_results.empty() and not \
|
49
|
+
self.metric_calculator_parallelized._inputs_waiting_to_be_process.empty():
|
50
|
+
return 'metric'
|
51
|
+
|
52
|
+
if self.samples_generator_parallelized._ready_processed_results.empty() and not \
|
53
|
+
self.samples_generator_parallelized._inputs_waiting_to_be_process.empty():
|
54
|
+
return 'dataset'
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
@staticmethod
|
60
|
+
def _process_func(code_path: str, code_entry_name: str,
|
61
|
+
samples_to_process: Queue, ready_samples: Queue,
|
62
|
+
metrics_to_process: Queue, ready_metrics: Queue) -> None:
|
63
|
+
import os
|
64
|
+
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
65
|
+
|
66
|
+
leap_loader = LeapLoader(code_path, code_entry_name)
|
67
|
+
while True:
|
68
|
+
|
69
|
+
# decide on sample or metric to process
|
70
|
+
state, idx = samples_to_process.get(block=True)
|
71
|
+
leap_loader._preprocess_result()
|
72
|
+
try:
|
73
|
+
sample = leap_loader.get_sample(state, idx)
|
74
|
+
except Exception as e:
|
75
|
+
leap_script_trace = traceback.format_exc().split('File "<string>"')[-1]
|
76
|
+
ready_samples.put(SampleSerializableError(state, idx, leap_script_trace, str(e)))
|
77
|
+
continue
|
78
|
+
|
79
|
+
ready_samples.put(sample)
|
80
|
+
|
81
|
+
def generate_samples(self, sample_identities: List[Tuple[DataStateEnum, int]]):
|
82
|
+
return self.start_process_inputs(sample_identities)
|
83
|
+
|
@@ -33,7 +33,6 @@ class LeapBinder:
|
|
33
33
|
setup_container (DatasetIntegrationSetup): Container to hold setup configurations.
|
34
34
|
cache_container (Dict[str, Any]): Cache container to store intermediate data.
|
35
35
|
"""
|
36
|
-
|
37
36
|
def __init__(self) -> None:
|
38
37
|
self.setup_container = DatasetIntegrationSetup()
|
39
38
|
self.cache_container: Dict[str, Any] = {"word_to_index": {}}
|
@@ -353,8 +352,7 @@ class LeapBinder:
|
|
353
352
|
self.setup_container.metadata.append(MetadataHandler(name, function))
|
354
353
|
|
355
354
|
def set_custom_layer(self, custom_layer: Type[Any], name: str, inspect_layer: bool = False,
|
356
|
-
kernel_index: Optional[int] = None, use_custom_latent_space: bool = False
|
357
|
-
build: bool = True) -> None:
|
355
|
+
kernel_index: Optional[int] = None, use_custom_latent_space: bool = False) -> None:
|
358
356
|
"""
|
359
357
|
Set a custom layer for the model.
|
360
358
|
|
@@ -379,14 +377,12 @@ class LeapBinder:
|
|
379
377
|
custom_layer.kernel_index = kernel_index
|
380
378
|
|
381
379
|
if use_custom_latent_space and not hasattr(custom_layer, custom_latent_space_attribute):
|
382
|
-
raise Exception(
|
383
|
-
f"{custom_latent_space_attribute} function has not been set for custom layer: {custom_layer.__name__}")
|
380
|
+
raise Exception(f"{custom_latent_space_attribute} function has not been set for custom layer: {custom_layer.__name__}")
|
384
381
|
|
385
382
|
init_args = inspect.getfullargspec(custom_layer.__init__)[0][1:]
|
386
383
|
call_args = inspect.getfullargspec(custom_layer.call)[0][1:]
|
387
384
|
self.setup_container.custom_layers[name] = CustomLayerHandler(name, custom_layer, init_args, call_args,
|
388
|
-
use_custom_latent_space=use_custom_latent_space
|
389
|
-
build=build)
|
385
|
+
use_custom_latent_space=use_custom_latent_space)
|
390
386
|
|
391
387
|
def check_preprocess(self, preprocess_result: Dict[DataStateEnum, PreprocessResponse]) -> None:
|
392
388
|
preprocess_handler = self.setup_container.preprocess
|
@@ -494,3 +490,7 @@ class LeapBinder:
|
|
494
490
|
|
495
491
|
def set_batch_size_to_validate(self, batch_size: int) -> None:
|
496
492
|
self.batch_size_to_validate = batch_size
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
{code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
@@ -355,7 +355,7 @@ def tensorleap_custom_loss(name: str):
|
|
355
355
|
assert isinstance(elem, valid_types), (f'tensorleap_custom_loss validation failed: '
|
356
356
|
f'Element #{y} of list should be a numpy array. Got {type(elem)}.')
|
357
357
|
else:
|
358
|
-
assert isinstance(arg,
|
358
|
+
assert isinstance(arg, valid_types), (f'tensorleap_custom_loss validation failed: '
|
359
359
|
f'Argument #{i} should be a numpy array. Got {type(arg)}.')
|
360
360
|
for _arg_name, arg in kwargs.items():
|
361
361
|
if isinstance(arg, list):
|
@@ -270,6 +270,8 @@ class LeapLoader(LeapLoaderBase):
|
|
270
270
|
unlabeled_length = None
|
271
271
|
if global_leap_binder.setup_container.unlabeled_data_preprocess:
|
272
272
|
unlabeled_length = global_leap_binder.setup_container.unlabeled_data_preprocess.data_length
|
273
|
+
else:
|
274
|
+
unlabeled_length = setup.preprocess.data_length.get(DataStateType.unlabeled)
|
273
275
|
dataset_preprocess = DatasetPreprocess(
|
274
276
|
training_length=setup.preprocess.data_length.get(DataStateType.training, 0),
|
275
277
|
validation_length=setup.preprocess.data_length.get(DataStateType.validation, 0),
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/experiment_context.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{code_loader-1.0.68a0 → code_loader-1.0.69}/code_loader/experiment_api/workingspace_config_utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|