code-loader 1.0.55__py3-none-any.whl → 1.0.57__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.
@@ -49,6 +49,9 @@ class PreprocessResponse:
49
49
  else:
50
50
  raise Exception("length is deprecated.")
51
51
 
52
+ def __hash__(self) -> int:
53
+ return id(self)
54
+
52
55
  def __len__(self) -> int:
53
56
  assert self.sample_ids is not None
54
57
  return len(self.sample_ids)
@@ -52,20 +52,30 @@ def tensorleap_custom_metric(name: str, direction: Optional[MetricDirection] = M
52
52
  f'Metric has returned unsupported type. Supported types are List[float], '
53
53
  f'List[List[ConfusionMatrixElement]], NDArray[np.float32]. ')
54
54
 
55
- if isinstance(result, list):
56
- if isinstance(result[0], list):
57
- assert isinstance(result[0][0], ConfusionMatrixElement), \
58
- f'{supported_types_message}Got List[List[{type(result[0][0])}]].'
55
+ def _validate_single_metric(single_metric_result):
56
+ if isinstance(single_metric_result, list):
57
+ if isinstance(single_metric_result[0], list):
58
+ assert isinstance(single_metric_result[0][0], ConfusionMatrixElement), \
59
+ f'{supported_types_message}Got List[List[{type(single_metric_result[0][0])}]].'
60
+ else:
61
+ assert isinstance(single_metric_result[0], float), f'{supported_types_message}Got List[{type(single_metric_result[0])}].'
59
62
  else:
60
- assert isinstance(result[0], float), f'{supported_types_message}Got List[{type(result[0])}].'
63
+ assert isinstance(single_metric_result, np.ndarray), f'{supported_types_message}Got {type(single_metric_result)}.'
64
+ assert len(single_metric_result.shape) == 1, (f'tensorleap_custom_metric validation failed: '
65
+ f'The return shape should be 1D. Got {len(single_metric_result.shape)}D.')
61
66
 
67
+ if leap_binder.batch_size_to_validate:
68
+ assert len(single_metric_result) == leap_binder.batch_size_to_validate, \
69
+ f'tensorleap_custom_metrix validation failed: The return len should be as the batch size.'
70
+
71
+ if isinstance(result, dict):
72
+ for key, value in result.items():
73
+ assert isinstance(key, str), \
74
+ (f'tensorleap_custom_metric validation failed: '
75
+ f'Keys in the return dict should be of type str. Got {type(key)}.')
76
+ _validate_single_metric(value)
62
77
  else:
63
- assert isinstance(result, np.ndarray), f'{supported_types_message}Got {type(result)}.'
64
- assert len(result.shape) == 1, (f'tensorleap_custom_metric validation failed: '
65
- f'The return shape should be 1D. Got {len(result.shape)}D.')
66
- if leap_binder.batch_size_to_validate:
67
- assert len(result) == leap_binder.batch_size_to_validate, \
68
- f'tensorleap_custom_metrix validation failed: The return len should be as the batch size.'
78
+ _validate_single_metric(result)
69
79
 
70
80
  def inner(*args, **kwargs):
71
81
  _validate_input_args(*args, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: code-loader
3
- Version: 1.0.55
3
+ Version: 1.0.57
4
4
  Summary:
5
5
  Home-page: https://github.com/tensorleap/code-loader
6
6
  License: MIT
@@ -2,7 +2,7 @@ LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
2
2
  code_loader/__init__.py,sha256=6MMWr0ObOU7hkqQKgOqp4Zp3I28L7joGC9iCbQYtAJg,241
3
3
  code_loader/code_inegration_processes_manager.py,sha256=XslWOPeNQk4RAFJ_f3tP5Oe3EgcIR7BE7Y8r9Ty73-o,3261
4
4
  code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- code_loader/contract/datasetclasses.py,sha256=lOIY-h9t4k9NxNsC9GrJhltmhpqRju3AuLA3WVQcCMs,6614
5
+ code_loader/contract/datasetclasses.py,sha256=lFS7_weizsjzx4_tYwYGrrRUj1sgIl010h9FON4brb8,6670
6
6
  code_loader/contract/enums.py,sha256=6Lo7p5CUog68Fd31bCozIuOgIp_IhSiPqWWph2k3OGU,1602
7
7
  code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
8
8
  code_loader/contract/responsedataclasses.py,sha256=w7xVOv2S8Hyb5lqyomMGiKAWXDTSOG-FX1YW39bXD3A,3969
@@ -19,12 +19,12 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
19
19
  code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
20
20
  code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
21
21
  code_loader/inner_leap_binder/leapbinder.py,sha256=35hyesDdmjOD9wdrTLyayb-vm9aDfmEbMA0c4EQR1LA,25090
22
- code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=bBzIPx9DvPGzVTZcjUqCRkTT5GhH6cL5PsjmTtawJhE,19054
22
+ code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=b7CTPrXpSi-rmrD9gO9vu_usSDH-SOeg25xTgzznWIk,19749
23
23
  code_loader/leaploader.py,sha256=POUgD6x1GH_iF_eDGz-VLX4DsIl2kddufKVDdrA_K-U,19491
24
24
  code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
25
25
  code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  code_loader/visualizers/default_visualizers.py,sha256=VoqO9FN84yXyMjRjHjUTOt2GdTkJRMbHbXJ1cJkREkk,2230
27
- code_loader-1.0.55.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
28
- code_loader-1.0.55.dist-info/METADATA,sha256=I2IBhfNvtdxQgrU5SLkIpEjam8s4YcwG7f8coQ1TBhk,888
29
- code_loader-1.0.55.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
30
- code_loader-1.0.55.dist-info/RECORD,,
27
+ code_loader-1.0.57.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
28
+ code_loader-1.0.57.dist-info/METADATA,sha256=EUK3flBb7tA9DKMdyLPz8rbL43UvyiHGYMduSuj4oPM,888
29
+ code_loader-1.0.57.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
30
+ code_loader-1.0.57.dist-info/RECORD,,