code-loader 1.0.190__tar.gz → 1.0.191__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.
Files changed (37) hide show
  1. {code_loader-1.0.190 → code_loader-1.0.191}/PKG-INFO +3 -3
  2. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/inner_leap_binder/leapbinder_decorators.py +39 -21
  3. {code_loader-1.0.190 → code_loader-1.0.191}/pyproject.toml +1 -1
  4. {code_loader-1.0.190 → code_loader-1.0.191}/LICENSE +0 -0
  5. {code_loader-1.0.190 → code_loader-1.0.191}/README.md +0 -0
  6. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/__init__.py +0 -0
  7. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/__init__.py +0 -0
  8. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/datasetclasses.py +0 -0
  9. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/enums.py +0 -0
  10. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/exceptions.py +0 -0
  11. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/mapping.py +0 -0
  12. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/responsedataclasses.py +0 -0
  13. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/sim_config.py +0 -0
  14. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/contract/visualizer_classes.py +0 -0
  15. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/default_losses.py +0 -0
  16. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/default_metrics.py +0 -0
  17. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/__init__.py +0 -0
  18. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/api.py +0 -0
  19. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/cli_config_utils.py +0 -0
  20. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/client.py +0 -0
  21. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/epoch.py +0 -0
  22. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/experiment.py +0 -0
  23. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/experiment_context.py +0 -0
  24. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/types.py +0 -0
  25. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/utils.py +0 -0
  26. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
  27. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/inner_leap_binder/__init__.py +0 -0
  28. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/inner_leap_binder/leapbinder.py +0 -0
  29. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/leaploader.py +0 -0
  30. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/leaploaderbase.py +0 -0
  31. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/mixpanel_tracker.py +0 -0
  32. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/plot_functions/__init__.py +0 -0
  33. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/plot_functions/plot_functions.py +0 -0
  34. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/plot_functions/visualize.py +0 -0
  35. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/utils.py +0 -0
  36. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/visualizers/__init__.py +0 -0
  37. {code_loader-1.0.190 → code_loader-1.0.191}/code_loader/visualizers/default_visualizers.py +0 -0
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: code-loader
3
- Version: 1.0.190
3
+ Version: 1.0.191
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
 
@@ -26,7 +26,7 @@ from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMet
26
26
  from code_loader import leap_binder, LeapLoader
27
27
  from code_loader.contract.mapping import NodeMapping, NodeMappingType, NodeConnection
28
28
  from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, LeapTextMask, LeapText, LeapGraph, \
29
- LeapHorizontalBar, LeapImageWithBBox, LeapImageWithHeatmap, LeapVideo
29
+ LeapHorizontalBar, LeapImageWithBBox, LeapImageWithHeatmap, LeapVideo, LeapValidationError
30
30
  from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame
31
31
  from code_loader.mixpanel_tracker import clear_integration_events, AnalyticsEvent, emit_integration_event_once
32
32
 
@@ -197,11 +197,11 @@ def validate_output_structure(result, func_name: str, expected_type_name="np.nda
197
197
  def batch_warning(result, func_name):
198
198
  if len(result.shape) > 0 and result.shape[0] == 1:
199
199
  warnings.warn(
200
- f"{func_name} warning: Tensorleap will add a batch dimension at axis 0 to the output of {func_name}, "
201
- f"although the detected size of axis 0 is already 1. "
202
- f"This may lead to an extra batch dimension (e.g., shape (1, 1, ...)). "
203
- f"Please ensure that the output of '{func_name}' is not already batched "
204
- f"to avoid computation errors."
200
+ f"{func_name} warning: Tensorleap will add a batch dimension at axis 0 of "
201
+ f"{func_name}'s output, but axis 0 is already size 1 — this can produce a "
202
+ f"doubly-batched shape (e.g. (1, 1, ...)). If axis 0 is a real dimension "
203
+ f"(e.g. a single channel) and not an accidental batch, you can ignore this; "
204
+ f"only fix it if you pre-batched the output."
205
205
  )
206
206
 
207
207
 
@@ -316,16 +316,16 @@ def tensorleap_integration_test():
316
316
  first_tb = traceback.extract_tb(e.__traceback__)[-1]
317
317
  file_name = Path(first_tb.filename).name
318
318
  line_number = first_tb.lineno
319
- if isinstance(e, TypeError) and 'is not subscriptable' in str(e):
320
- update_env_params_func("code_mapping", "x")
321
- raise (f'Invalid integration code. File {file_name}, line {line_number}: '
322
- f"indexing is supported only on the model's predictions inside the integration test. Please remove this indexing operation usage from the integration test code.")
319
+ update_env_params_func("code_mapping", "x")
320
+ if isinstance(e, LeapValidationError):
321
+ raise Exception(f'Invalid integration code. File {file_name}, line {line_number}: {e}')
322
+ elif isinstance(e, TypeError) and 'is not subscriptable' in str(e):
323
+ raise Exception(f'Invalid integration code. File {file_name}, line {line_number}: '
324
+ f"indexing is supported only on the model's predictions inside the integration test. Please remove this indexing operation usage from the integration test code.")
323
325
  else:
324
- update_env_params_func("code_mapping", "x")
325
-
326
- raise (f'Invalid integration code. File {file_name}, line {line_number}: '
327
- f'Integration test is only allowed to call Tensorleap decorators. '
328
- f'Ensure any arithmetics, external library use, Python logic is placed within Tensorleap decoders')
326
+ raise Exception(f'Invalid integration code. File {file_name}, line {line_number}: '
327
+ f'Integration test is only allowed to call Tensorleap decorators. '
328
+ f'Ensure any arithmetics, external library use, Python logic is placed within Tensorleap decoders')
329
329
  finally:
330
330
  if mapping_runtime_mode_env_var_mame in os.environ:
331
331
  del os.environ[mapping_runtime_mode_env_var_mame]
@@ -349,6 +349,14 @@ def _safe_get_item(key):
349
349
 
350
350
 
351
351
  def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]] = _UNSET):
352
+ """Register the model-loading function.
353
+
354
+ ``prediction_types``: declare one ``PredictionTypeHandler`` per model output, in
355
+ output order. Multi-output models must declare an entry for EVERY output — the
356
+ count is validated against the model's outputs — so for an output you don't consume
357
+ as a prediction, pass a throwaway handler to satisfy the count. Omit the argument
358
+ only when the model has a single prediction output.
359
+ """
352
360
  prediction_types_was_provided = prediction_types is not _UNSET
353
361
 
354
362
  if not prediction_types_was_provided:
@@ -603,7 +611,9 @@ def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]
603
611
 
604
612
  # onnx runtime interface
605
613
  def run(self, output_names, input_dict):
606
- assert output_names is None
614
+ if output_names is not None:
615
+ raise LeapValidationError("Tensorleap doesn't support selecting outputs by name — "
616
+ "use model.run(None, inputs) to return all outputs.")
607
617
  assert isinstance(input_dict, dict), \
608
618
  f'Expected input_dict to be a dict, got {type(input_dict)} instead.'
609
619
  for i, (input_key, elem) in enumerate(input_dict.items()):
@@ -2427,12 +2437,12 @@ def tensorleap_status_table():
2427
2437
  ready = False
2428
2438
  next_step = row["name"]
2429
2439
 
2430
- if _crashed["value"]:
2431
- print(f"\nScript crashed before completing all steps. crashed at function '{_current_func['name']}'.")
2440
+ if code_mapping_failure[0]:
2441
+ print(f"\n{CROSS} {code_mapping_failure_mes}")
2432
2442
  return
2433
2443
 
2434
- if code_mapping_failure[0]:
2435
- print(f"\n{CROSS + code_mapping_failure_mes}.")
2444
+ if _crashed["value"]:
2445
+ print(f"\nScript crashed before completing all steps. crashed at function '{_current_func['name']}'.")
2436
2446
  return
2437
2447
 
2438
2448
  print(ready_mess) if ready else print(
@@ -2447,6 +2457,10 @@ def tensorleap_status_table():
2447
2457
  code_mapping_failure[0] = 1
2448
2458
  if status == "v":
2449
2459
  _set_status(name, CHECK)
2460
+ # A decorator that reports success is no longer the "currently running"
2461
+ # one, so clear the pointer. This keeps a later body-level raise from
2462
+ # being blamed on the last decorator that actually succeeded.
2463
+ _current_func["name"] = None
2450
2464
  else:
2451
2465
  _set_status(name, CROSS)
2452
2466
 
@@ -2493,10 +2507,14 @@ def tensorleap_status_table():
2493
2507
  def handle_exception(exc_type, exc_value, exc_traceback):
2494
2508
  _crashed["value"] = True
2495
2509
  crashed_name = _current_func["name"]
2496
- if crashed_name:
2510
+ if crashed_name and not code_mapping_failure[0]:
2497
2511
  row = _find_row(crashed_name)
2498
2512
  if row:
2499
2513
  row["Added to integration"] = CROSS
2514
+ elif not crashed_name:
2515
+ # Crash with no decorator currently running = the integration-test body /
2516
+ # code flow itself failed; report that rather than blaming a decorator.
2517
+ code_mapping_failure[0] = 1
2500
2518
 
2501
2519
  traceback.print_exception(exc_type, exc_value, exc_traceback)
2502
2520
  run_on_exit()
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "code-loader"
3
3
 
4
- version = "1.0.190"
4
+ version = "1.0.191"
5
5
  description = ""
6
6
  authors = ["dorhar <doron.harnoy@tensorleap.ai>"]
7
7
  license = "MIT"
File without changes
File without changes