code-loader 1.0.72.dev5__py3-none-any.whl → 1.0.73__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.
@@ -133,6 +133,7 @@ class MetricHandlerData:
133
133
  name: str
134
134
  arg_names: List[str]
135
135
  direction: Union[None, MetricDirection, Dict[str, MetricDirection]] = MetricDirection.Downward
136
+ compute_insights: Union[bool, Dict[str, bool]] = True
136
137
 
137
138
 
138
139
  @dataclass
@@ -148,7 +149,7 @@ class RawInputsForHeatmap:
148
149
 
149
150
  @dataclass
150
151
  class SamplePreprocessResponse:
151
- sample_ids: np.array
152
+ sample_ids: Union[npt.NDArray[np.float32], npt.NDArray[np.str_]]
152
153
  preprocess_response: PreprocessResponse
153
154
 
154
155
 
@@ -258,7 +258,8 @@ class LeapBinder:
258
258
  ConfusionMatrixCallableInterfaceMultiArgs],
259
259
  name: str,
260
260
  direction: Optional[
261
- Union[MetricDirection, Dict[str, MetricDirection]]] = MetricDirection.Downward) -> None:
261
+ Union[MetricDirection, Dict[str, MetricDirection]]] = MetricDirection.Downward,
262
+ compute_insights: Union[bool, Dict[str, bool]] = True) -> None:
262
263
  """
263
264
  Add a custom metric to the setup.
264
265
 
@@ -267,9 +268,11 @@ class LeapBinder:
267
268
  name (str): The name of the custom metric.
268
269
  direction (Optional[Union[MetricDirection, Dict[str, MetricDirection]]]): The direction of the metric, either
269
270
  MetricDirection.Upward or MetricDirection.Downward, in case custom metric return a dictionary of metrics we can
270
- supply a dictionary of directions correspondingly
271
+ supply a dictionary of directions correspondingly.
271
272
  - MetricDirection.Upward: Indicates that higher values of the metric are better and should be maximized.
272
273
  - MetricDirection.Downward: Indicates that lower values of the metric are better and should be minimized.
274
+ compute_insights (Union[bool, Dict[str, bool]]): Whether to compute insights or not. in case custom metric
275
+ return a dictionary of metrics we can supply a dictionary of values correspondingly
273
276
 
274
277
 
275
278
 
@@ -280,7 +283,8 @@ class LeapBinder:
280
283
  leap_binder.add_custom_metric(custom_metric_function, name='custom_metric', direction=MetricDirection.Downward)
281
284
  """
282
285
  arg_names = inspect.getfullargspec(function)[0]
283
- self.setup_container.metrics.append(MetricHandler(MetricHandlerData(name, arg_names, direction), function))
286
+ metric_handler_data = MetricHandlerData(name, arg_names, direction, compute_insights)
287
+ self.setup_container.metrics.append(MetricHandler(metric_handler_data, function))
284
288
 
285
289
  def add_prediction(self, name: str, labels: List[str], channel_dim: int = -1) -> None:
286
290
  """
@@ -16,7 +16,8 @@ from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, Le
16
16
 
17
17
 
18
18
  def tensorleap_custom_metric(name: str,
19
- direction: Union[MetricDirection, Dict[str, MetricDirection]] = MetricDirection.Downward):
19
+ direction: Union[MetricDirection, Dict[str, MetricDirection]] = MetricDirection.Downward,
20
+ compute_insights: Union[bool, Dict[str, bool]] = True):
20
21
  def decorating_function(user_function: Union[CustomCallableInterfaceMultiArgs,
21
22
  CustomMultipleReturnCallableInterfaceMultiArgs,
22
23
  ConfusionMatrixCallableInterfaceMultiArgs]):
@@ -25,7 +26,7 @@ def tensorleap_custom_metric(name: str,
25
26
  raise Exception(f'Metric with name {name} already exists. '
26
27
  f'Please choose another')
27
28
 
28
- leap_binder.add_custom_metric(user_function, name, direction)
29
+ leap_binder.add_custom_metric(user_function, name, direction, compute_insights)
29
30
 
30
31
  def _validate_input_args(*args, **kwargs) -> None:
31
32
  for i, arg in enumerate(args):
@@ -75,6 +76,19 @@ def tensorleap_custom_metric(name: str,
75
76
  (f'tensorleap_custom_metric validation failed: '
76
77
  f'Keys in the return dict should be of type str. Got {type(key)}.')
77
78
  _validate_single_metric(value)
79
+
80
+ if isinstance(direction, dict):
81
+ for direction_key in direction:
82
+ assert direction_key in result, \
83
+ (f'tensorleap_custom_metric validation failed: '
84
+ f'Keys in the direction mapping should be part of result keys. Got key {direction_key}.')
85
+
86
+ if isinstance(compute_insights, dict):
87
+ for ci_key in compute_insights:
88
+ assert ci_key in result, \
89
+ (f'tensorleap_custom_metric validation failed: '
90
+ f'Keys in the compute_insights mapping should be part of result keys. Got key {ci_key}.')
91
+
78
92
  else:
79
93
  _validate_single_metric(result)
80
94
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: code-loader
3
- Version: 1.0.72.dev5
3
+ Version: 1.0.73
4
4
  Summary:
5
5
  Home-page: https://github.com/tensorleap/code-loader
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
2
2
  code_loader/__init__.py,sha256=6MMWr0ObOU7hkqQKgOqp4Zp3I28L7joGC9iCbQYtAJg,241
3
3
  code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- code_loader/contract/datasetclasses.py,sha256=2m9wyF_SO_q3kfrrAELS8rseMX-veeaP-Aof0ZhG_7g,7119
4
+ code_loader/contract/datasetclasses.py,sha256=hmPqgQcXya-8iF2mV06Nc_mJQdLoks7L22Ew9qH01d8,7221
5
5
  code_loader/contract/enums.py,sha256=6Lo7p5CUog68Fd31bCozIuOgIp_IhSiPqWWph2k3OGU,1602
6
6
  code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
7
7
  code_loader/contract/responsedataclasses.py,sha256=RSx9m_R3LawhK5o1nAcO3hfp2F9oJYtxZr_bpP3bTmw,4005
@@ -19,14 +19,14 @@ code_loader/experiment_api/types.py,sha256=MY8xFARHwdVA7p4dxyhD60ShmttgTvb4qdp1o
19
19
  code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZJEqBqc,3304
20
20
  code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
21
21
  code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
22
- code_loader/inner_leap_binder/leapbinder.py,sha256=-fryKzD8T8K2EgrOsR5NryabP8_1k_m3POLwhYIA_8I,26708
23
- code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=ebMxknpKMW-dE8Erq0fFq4RrE5E_Jfx9IvmRRZSdhlc,20813
22
+ code_loader/inner_leap_binder/leapbinder.py,sha256=0l9zjlF27tZwg6SnpyqVoAAgf9QHQcKpR9lg7vho2Xw,27065
23
+ code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=B-XSw4xYF39kMPnMTRNKMYFg09whnfl7VSbcx195VG8,21626
24
24
  code_loader/leaploader.py,sha256=he1c46jQNrCBEBq03gQDS0WVxiX7nlGAE9_9hLagxQc,24973
25
25
  code_loader/leaploaderbase.py,sha256=VH0vddRmkqLtcDlYPCO7hfz1_VbKo43lUdHDAbd4iJc,4198
26
26
  code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
27
27
  code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  code_loader/visualizers/default_visualizers.py,sha256=Ffx5VHVOe5ujBOsjBSxN_aIEVwFSQ6gbhTMG5aUS-po,2305
29
- code_loader-1.0.72.dev5.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
- code_loader-1.0.72.dev5.dist-info/METADATA,sha256=IuNmOiTSxEC2A_-cCOc06mXUHiZPaf-Wg71eT28YGJE,854
31
- code_loader-1.0.72.dev5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- code_loader-1.0.72.dev5.dist-info/RECORD,,
29
+ code_loader-1.0.73.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
+ code_loader-1.0.73.dist-info/METADATA,sha256=d7-FSiS0YvfmoWlJZyqlf644v1SuNGf-_MfunY5KYcA,849
31
+ code_loader-1.0.73.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
+ code_loader-1.0.73.dist-info/RECORD,,