code-loader 1.0.118.dev1__py3-none-any.whl → 1.0.119rc0__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 code-loader might be problematic. Click here for more details.

@@ -212,11 +212,6 @@ class MetadataHandler:
212
212
  metadata_type: Optional[Union[DatasetMetadataType, Dict[str, DatasetMetadataType]]] = None
213
213
 
214
214
 
215
- @dataclass
216
- class CustomLatentSpaceHandler:
217
- function: SectionCallableInterface
218
- name: str = 'custom_latent_space'
219
-
220
215
  @dataclass
221
216
  class PredictionTypeHandler:
222
217
  name: str
@@ -246,7 +241,6 @@ class DatasetIntegrationSetup:
246
241
  custom_loss_handlers: List[CustomLossHandler] = field(default_factory=list)
247
242
  metrics: List[MetricHandler] = field(default_factory=list)
248
243
  custom_layers: Dict[str, CustomLayerHandler] = field(default_factory=dict)
249
- custom_latent_space: Optional[CustomLatentSpaceHandler] = None
250
244
 
251
245
 
252
246
  @dataclass
@@ -258,5 +252,4 @@ class DatasetSample:
258
252
  index: Union[int, str]
259
253
  state: DataStateEnum
260
254
  instance_masks: Optional[Dict[str, List[ElementInstance]]] = None
261
- custom_latent_space: Optional[npt.NDArray[np.float32]] = None
262
255
 
@@ -11,7 +11,7 @@ from code_loader.contract.datasetclasses import SectionCallableInterface, InputH
11
11
  CustomCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, LeapData, \
12
12
  CustomMultipleReturnCallableInterfaceMultiArgs, DatasetBaseHandler, custom_latent_space_attribute, \
13
13
  RawInputsForHeatmap, VisualizerHandlerData, MetricHandlerData, CustomLossHandlerData, SamplePreprocessResponse, \
14
- ElementInstanceMasksHandler, InstanceCallableInterface, CustomLatentSpaceHandler
14
+ ElementInstanceMasksHandler, InstanceCallableInterface
15
15
  from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
16
16
  from code_loader.contract.mapping import NodeConnection, NodeMapping, NodeMappingType
17
17
  from code_loader.contract.responsedataclasses import DatasetTestResultPayload
@@ -421,19 +421,6 @@ class LeapBinder:
421
421
  """
422
422
  self.setup_container.metadata.append(MetadataHandler(name, function, metadata_type))
423
423
 
424
- def set_custom_latent_space(self, function: SectionCallableInterface) -> None:
425
- """
426
- Set a custom latent space function.
427
-
428
- Args:
429
- function (SectionCallableInterface): The metadata handler function.
430
- This function receives:
431
- subset (PreprocessResponse): The subset of the data.
432
- index (int): The index of the sample within the subset.
433
- This function should numpy float32 array contains the latent space vec of the sample.
434
- """
435
- self.setup_container.custom_latent_space = CustomLatentSpaceHandler(function)
436
-
437
424
  def set_custom_layer(self, custom_layer: Type[Any], name: str, inspect_layer: bool = False,
438
425
  kernel_index: Optional[int] = None, use_custom_latent_space: bool = False) -> None:
439
426
  """
@@ -443,55 +443,6 @@ def tensorleap_metadata(
443
443
  return decorating_function
444
444
 
445
445
 
446
-
447
- def tensorleap_custom_latent_space():
448
- def decorating_function(user_function: SectionCallableInterface):
449
- def _validate_input_args(sample_id: Union[int, str], preprocess_response: PreprocessResponse):
450
- assert isinstance(sample_id, (int, str)), \
451
- (f'tensorleap_custom_latent_space validation failed: '
452
- f'Argument sample_id should be either int or str. Got {type(sample_id)}.')
453
- assert isinstance(preprocess_response, PreprocessResponse), \
454
- (f'tensorleap_custom_latent_space validation failed: '
455
- f'Argument preprocess_response should be a PreprocessResponse. Got {type(preprocess_response)}.')
456
- assert type(sample_id) == preprocess_response.sample_id_type, \
457
- (f'tensorleap_custom_latent_space validation failed: '
458
- f'Argument sample_id should be as the same type as defined in the preprocess response '
459
- f'{preprocess_response.sample_id_type}. Got {type(sample_id)}.')
460
-
461
- def _validate_result(result):
462
- assert isinstance(result, np.ndarray), \
463
- (f'tensorleap_custom_loss validation failed: '
464
- f'The return type should be a numpy array. Got {type(result)}.')
465
-
466
- def inner_without_validate(sample_id, preprocess_response):
467
- global _called_from_inside_tl_decorator
468
- _called_from_inside_tl_decorator += 1
469
-
470
- try:
471
- result = user_function(sample_id, preprocess_response)
472
- finally:
473
- _called_from_inside_tl_decorator -= 1
474
-
475
- return result
476
-
477
- leap_binder.set_custom_latent_space(inner_without_validate)
478
-
479
- def inner(sample_id, preprocess_response):
480
- if os.environ.get(mapping_runtime_mode_env_var_mame):
481
- return None
482
-
483
- _validate_input_args(sample_id, preprocess_response)
484
-
485
- result = inner_without_validate(sample_id, preprocess_response)
486
-
487
- _validate_result(result)
488
- return result
489
-
490
- return inner
491
-
492
- return decorating_function
493
-
494
-
495
446
  def tensorleap_preprocess():
496
447
  def decorating_function(user_function: Callable[[], List[PreprocessResponse]]):
497
448
  leap_binder.set_preprocess(user_function)
@@ -809,8 +760,14 @@ def tensorleap_custom_loss(name: str, connects_to=None):
809
760
  f'Please choose another')
810
761
 
811
762
  valid_types = (np.ndarray, SamplePreprocessResponse)
763
+ try:
764
+ import tensorflow as tf
765
+ valid_types = (np.ndarray, SamplePreprocessResponse, tf.Tensor)
766
+ except ImportError:
767
+ pass
812
768
 
813
769
  def _validate_input_args(*args, **kwargs):
770
+
814
771
  for i, arg in enumerate(args):
815
772
  if isinstance(arg, list):
816
773
  for y, elem in enumerate(arg):
@@ -829,11 +786,10 @@ def tensorleap_custom_loss(name: str, connects_to=None):
829
786
  f'Argument #{_arg_name} should be a numpy array. Got {type(arg)}.')
830
787
 
831
788
  def _validate_result(result):
832
- assert isinstance(result, np.ndarray), \
789
+ assert isinstance(result, valid_types), \
833
790
  (f'tensorleap_custom_loss validation failed: '
834
791
  f'The return type should be a numpy array. Got {type(result)}.')
835
792
 
836
-
837
793
  @functools.wraps(user_function)
838
794
  def inner_without_validate(*args, **kwargs):
839
795
  global _called_from_inside_tl_decorator
code_loader/leaploader.py CHANGED
@@ -16,7 +16,7 @@ from code_loader.contract.datasetclasses import DatasetSample, DatasetBaseHandle
16
16
  PreprocessResponse, VisualizerHandler, LeapData, \
17
17
  PredictionTypeHandler, MetadataHandler, CustomLayerHandler, MetricHandler, VisualizerHandlerData, MetricHandlerData, \
18
18
  MetricCallableReturnType, CustomLossHandlerData, CustomLossHandler, RawInputsForHeatmap, SamplePreprocessResponse, \
19
- ElementInstance, custom_latent_space_attribute
19
+ ElementInstance
20
20
  from code_loader.contract.enums import DataStateEnum, TestingSectionEnum, DataStateType, DatasetMetadataType
21
21
  from code_loader.contract.exceptions import DatasetScriptException
22
22
  from code_loader.contract.responsedataclasses import DatasetIntegParseResult, DatasetTestResultPayload, \
@@ -162,18 +162,12 @@ class LeapLoader(LeapLoaderBase):
162
162
  self._preprocess_result(update_unlabeled_preprocess=True)
163
163
 
164
164
  metadata, metadata_is_none = self._get_metadata(state, sample_id)
165
-
166
- custom_latent_space = None
167
- if global_leap_binder.setup_container.custom_latent_space is not None:
168
- custom_latent_space = global_leap_binder.setup_container.custom_latent_space(sample_id, preprocess_result[state])
169
-
170
165
  sample = DatasetSample(inputs=self._get_inputs(state, sample_id),
171
166
  gt=None if state == DataStateEnum.unlabeled else self._get_gt(state, sample_id),
172
167
  metadata=metadata,
173
168
  metadata_is_none=metadata_is_none,
174
169
  index=sample_id,
175
- state=state,
176
- custom_latent_space=custom_latent_space)
170
+ state=state)
177
171
  return sample
178
172
 
179
173
  def get_sample_with_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
@@ -94,6 +94,10 @@ class MixpanelTracker:
94
94
  Args:
95
95
  event_properties: Optional additional properties to include in the event
96
96
  """
97
+
98
+ if os.environ.get('IS_TENSORLEAP_PLATFORM') == 'true':
99
+ return
100
+
97
101
  try:
98
102
  distinct_id = self._get_distinct_id()
99
103
 
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: code-loader
3
- Version: 1.0.118.dev1
3
+ Version: 1.0.119rc0
4
4
  Summary:
5
- Home-page: https://github.com/tensorleap/code-loader
6
5
  License: MIT
7
6
  Author: dorhar
8
7
  Author-email: doron.harnoy@tensorleap.ai
@@ -20,6 +19,7 @@ Requires-Dist: numpy (>=2.3.2,<3.0.0) ; python_version >= "3.11" and python_vers
20
19
  Requires-Dist: psutil (>=5.9.5,<6.0.0)
21
20
  Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
22
21
  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,7 +1,6 @@
1
- LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
2
1
  code_loader/__init__.py,sha256=outxRQ0M-zMfV0QGVJmAed5qWfRmyD0TV6-goEGAzBw,406
3
2
  code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- code_loader/contract/datasetclasses.py,sha256=dzEzQY5F-uTNB28omGcdZp4cIXWn7NJhNyL0_Y04Yyo,9092
3
+ code_loader/contract/datasetclasses.py,sha256=gJsXu4zVAaiBlq6GJwPxfTD2e0gICTtI_6Ir61MRL48,8838
5
4
  code_loader/contract/enums.py,sha256=GEFkvUMXnCNt-GOoz7NJ9ecQZ2PPDettJNOsxsiM0wk,1622
6
5
  code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
7
6
  code_loader/contract/mapping.py,sha256=e11h_sprwOyE32PcqgRq9JvyahQrPzwqgkhmbQLKLQY,1165
@@ -20,18 +19,18 @@ code_loader/experiment_api/types.py,sha256=MY8xFARHwdVA7p4dxyhD60ShmttgTvb4qdp1o
20
19
  code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZJEqBqc,3304
21
20
  code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
22
21
  code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
23
- code_loader/inner_leap_binder/leapbinder.py,sha256=Q3D9yVM-GNEJfYRFvMV__BoZbcWOgnWKhrZXAv6Tu7o,33232
24
- code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=QpM0gx8ZplGp2XykZXBk0QBh2_5fqW9cgLNOoM4Sacs,42948
25
- code_loader/leaploader.py,sha256=CvVDuQlyl4anlmIaaJri5bgLXibAGGqfgNvmE1K7H48,30054
22
+ code_loader/inner_leap_binder/leapbinder.py,sha256=0iHVHxC2NjfH7F0vQFVGy1e0llgKEyUHUHh3DdtqL70,32602
23
+ code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=wjtk3TflrjJ8Y-OeuedVBD-09ZuOjIKGUjL7sMBU0fQ,41017
24
+ code_loader/leaploader.py,sha256=rQRK1lyUPSpZiRs6lKUUxVJBCe3grEY_UxEMxSIpuxI,29709
26
25
  code_loader/leaploaderbase.py,sha256=lKdw2pd6H9hFsxVmc7jJMoZd_vlG5He1ooqT-cR_yq8,4496
27
- code_loader/mixpanel_tracker.py,sha256=U20vQXH8G7XIVXxcpQcVEZSuIwwGnyH5RMHXWZZG8HI,4639
26
+ code_loader/mixpanel_tracker.py,sha256=UwTObCiVuXQ53xJo6HjOQr4DfvYuZ7cRVJDaCo9l6tg,4743
28
27
  code_loader/plot_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
28
  code_loader/plot_functions/plot_functions.py,sha256=xg6Gi4myTN9crq6JtyrhYI38HLXjPVJcbnI7CIy8f7w,14625
30
29
  code_loader/plot_functions/visualize.py,sha256=gsBAYYkwMh7jIpJeDMPS8G4CW-pxwx6LznoQIvi4vpo,657
31
30
  code_loader/utils.py,sha256=_j8b60pimoNAvWMRj7hEkkT6C76qES6cZoBFHpXHMxA,2698
32
31
  code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
32
  code_loader/visualizers/default_visualizers.py,sha256=onRnLE_TXfgLN4o52hQIOOhUcFexGlqJ3xSpQDVLuZM,2604
34
- code_loader-1.0.118.dev1.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
35
- code_loader-1.0.118.dev1.dist-info/METADATA,sha256=uAG-E0GkPcwnS69zCksWM4s6kQANK46DrDlKgjhE3s8,1095
36
- code_loader-1.0.118.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
37
- code_loader-1.0.118.dev1.dist-info/RECORD,,
33
+ code_loader-1.0.119rc0.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
34
+ code_loader-1.0.119rc0.dist-info/METADATA,sha256=-EP6HCTEsqHrBeEwJTBqRey4dgNc7hHsflA5zXA7qFg,1105
35
+ code_loader-1.0.119rc0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
36
+ code_loader-1.0.119rc0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,21 +0,0 @@
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.
File without changes