code-loader 1.0.76__py3-none-any.whl → 1.0.77.1__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.
@@ -1,6 +1,6 @@
1
1
  from dataclasses import dataclass, field
2
2
  from typing import Any, Callable, List, Optional, Dict, Union, Type
3
-
3
+ import re
4
4
  import numpy as np
5
5
  import numpy.typing as npt
6
6
 
@@ -39,6 +39,9 @@ class PreprocessResponse:
39
39
  sample_id_type: Optional[Union[Type[str], Type[int]]] = None
40
40
 
41
41
  def __post_init__(self) -> None:
42
+ def is_valid_string(s: str) -> bool:
43
+ return bool(re.match(r'^[A-Za-z0-9_]+$', s))
44
+
42
45
  if self.length is not None and self.sample_ids is None:
43
46
  self.sample_ids = [i for i in range(self.length)]
44
47
  self.sample_id_type = int
@@ -46,6 +49,11 @@ class PreprocessResponse:
46
49
  self.length = len(self.sample_ids)
47
50
  if self.sample_id_type is None:
48
51
  self.sample_id_type = str
52
+ if self.sample_id_type == str:
53
+ for sample_id in self.sample_ids:
54
+ assert isinstance(sample_id, str), f"Sample id should be of type str. Got: {type(sample_id)}"
55
+ if not is_valid_string(sample_id):
56
+ raise Exception(f"Sample id should contain only letters (A-Z, a-z), numbers or '_'. Got: {sample_id}")
49
57
  else:
50
58
  raise Exception("length is deprecated.")
51
59
 
code_loader/leaploader.py CHANGED
@@ -46,7 +46,7 @@ class LeapLoader(LeapLoaderBase):
46
46
 
47
47
  def evaluate_module(self) -> None:
48
48
  def append_path_recursively(full_path: str) -> None:
49
- if '/' not in full_path or full_path == '/':
49
+ if self.code_path not in full_path or full_path == '/':
50
50
  return
51
51
 
52
52
  parent_path = str(Path(full_path).parent)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: code-loader
3
- Version: 1.0.76
3
+ Version: 1.0.77.1
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=hmPqgQcXya-8iF2mV06Nc_mJQdLoks7L22Ew9qH01d8,7221
4
+ code_loader/contract/datasetclasses.py,sha256=t1pvW68dVIbYB0bllqxHXO6jOgHCJI5NGn9rSrYC6Vw,7722
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
@@ -21,12 +21,12 @@ code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaS
21
21
  code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
22
22
  code_loader/inner_leap_binder/leapbinder.py,sha256=0l9zjlF27tZwg6SnpyqVoAAgf9QHQcKpR9lg7vho2Xw,27065
23
23
  code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=mkgQF5YBMlw5_1JXj7LnhDQpRqlq-8kvP7uFvB3DTRo,21904
24
- code_loader/leaploader.py,sha256=Gggk5vzomqVqlYo14sQTlc7RIzhONYR-11hTLDKhwsA,24972
24
+ code_loader/leaploader.py,sha256=KkAPKyzZxZYI135_67q63ICVVERu7WH60liB0pboA-c,24983
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.76.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
- code_loader-1.0.76.dist-info/METADATA,sha256=K7X-k9l0QHb4wRIc7lYXhEmXUmnudjmYbftLQIXPUwU,849
31
- code_loader-1.0.76.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- code_loader-1.0.76.dist-info/RECORD,,
29
+ code_loader-1.0.77.1.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
+ code_loader-1.0.77.1.dist-info/METADATA,sha256=ko-pD3mbQoKtxXhbVRaxEsrAOWpqYacD-791pEGkabU,851
31
+ code_loader-1.0.77.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
+ code_loader-1.0.77.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any