liminal-orm 3.1.0__py3-none-any.whl → 3.1.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.
@@ -4,7 +4,7 @@ from rich import print
4
4
 
5
5
  from liminal.connection import BenchlingService
6
6
  from liminal.dropdowns.utils import get_benchling_dropdowns_dict
7
- from liminal.utils import pascalize, to_snake_case
7
+ from liminal.utils import to_pascal_case, to_snake_case
8
8
 
9
9
 
10
10
  def generate_all_dropdown_files(
@@ -24,7 +24,7 @@ def generate_all_dropdown_files(
24
24
  for dropdown_name, dropdown_options in dropdowns.items():
25
25
  dropdown_values = [option.name for option in dropdown_options.options]
26
26
  options_list = str(dropdown_values).replace("'", '"')
27
- classname = pascalize(dropdown_name)
27
+ classname = to_pascal_case(dropdown_name)
28
28
  dropdown_content = f"""
29
29
  from liminal.base.base_dropdown import BaseDropdown
30
30
 
@@ -8,7 +8,7 @@ from liminal.entity_schemas.utils import get_converted_tag_schemas
8
8
  from liminal.enums import BenchlingEntityType, BenchlingFieldType
9
9
  from liminal.mappers import convert_benchling_type_to_python_type
10
10
  from liminal.orm.name_template import NameTemplate
11
- from liminal.utils import pascalize, to_snake_case
11
+ from liminal.utils import to_pascal_case, to_snake_case
12
12
 
13
13
 
14
14
  def get_entity_mixin(entity_type: BenchlingEntityType) -> str:
@@ -59,18 +59,18 @@ def generate_all_entity_schema_files(
59
59
  subdirectory_map: dict[str, list[tuple[str, str]]] = {}
60
60
  benchling_dropdowns = get_benchling_dropdowns_dict(benchling_service)
61
61
  dropdown_name_to_classname_map: dict[str, str] = {
62
- dropdown_name: pascalize(dropdown_name)
62
+ dropdown_name: to_pascal_case(dropdown_name)
63
63
  for dropdown_name in benchling_dropdowns.keys()
64
64
  }
65
65
  wh_name_to_classname: dict[str, str] = {
66
- sp.warehouse_name: pascalize(sp.name) for sp, _, _ in models
66
+ sp.warehouse_name: to_pascal_case(sp.name) for sp, _, _ in models
67
67
  }
68
68
 
69
69
  for schema_properties, name_template, columns in models:
70
- classname = pascalize(schema_properties.name)
70
+ classname = to_pascal_case(schema_properties.name)
71
71
 
72
72
  for schema_properties, name_template, columns in models:
73
- classname = pascalize(schema_properties.name)
73
+ classname = to_pascal_case(schema_properties.name)
74
74
  filename = to_snake_case(schema_properties.name) + ".py"
75
75
  columns = {key: columns[key] for key in columns}
76
76
  import_strings = [
@@ -313,10 +313,15 @@ class CreateEntitySchemaField(BaseOperation):
313
313
  self.index = index
314
314
 
315
315
  self._wh_field_name: str
316
+ self._field_name: str
316
317
  if field_props.warehouse_name:
317
318
  self._wh_field_name = field_props.warehouse_name
318
319
  else:
319
320
  raise ValueError("Field warehouse name is required.")
321
+ if field_props.name:
322
+ self._field_name = field_props.name
323
+ else:
324
+ raise ValueError("Field name is required.")
320
325
 
321
326
  def execute(self, benchling_service: BenchlingService) -> dict[str, Any]:
322
327
  try:
@@ -385,10 +390,10 @@ class CreateEntitySchemaField(BaseOperation):
385
390
  if (
386
391
  benchling_service.connection.config_flags.schemas_enable_change_warehouse_name
387
392
  is False
388
- and self.field_props.warehouse_name != to_snake_case(self.field_props.name)
393
+ and self.field_props.warehouse_name != to_snake_case(self._field_name)
389
394
  ):
390
395
  raise ValueError(
391
- f"{self.wh_schema_name}: Tenant config flag SCHEMAS_ENABLE_CHANGE_WAREHOUSE_NAME is required to set a custom field warehouse name. Reach out to Benchling support to turn this config flag to True and then set the flag to True in BenchlingConnection.config_flags. Otherwise, define the field warehouse_name in code to be the given Benchling warehouse name: {to_snake_case(self.field_props.name)}."
396
+ f"{self.wh_schema_name}: Tenant config flag SCHEMAS_ENABLE_CHANGE_WAREHOUSE_NAME is required to set a custom field warehouse name. Reach out to Benchling support to turn this config flag to True and then set the flag to True in BenchlingConnection.config_flags. Otherwise, define the field warehouse_name in code to be the given Benchling warehouse name: {to_snake_case(self._field_name)}."
392
397
  )
393
398
  if (
394
399
  self.field_props.unit_name
liminal/utils.py CHANGED
@@ -10,30 +10,25 @@ from liminal.connection.benchling_service import BenchlingService
10
10
 
11
11
 
12
12
  def generate_random_id(length: int = 8) -> str:
13
- """Generate a random ID with only lowercase letters."""
13
+ """Generate a pseudo-random ID with only lowercase letters."""
14
14
  return "".join(random.choices(string.ascii_lowercase, k=length))
15
15
 
16
16
 
17
- def pascalize(input_string: str) -> str:
17
+ def to_pascal_case(input_string: str) -> str:
18
18
  """
19
- Convert a string to PascalCase.
19
+ Convert a string to PascalCase. Filters out any non-alphanumeric characters.
20
20
  """
21
- return "".join(
22
- re.sub(r"[\[\]{}():]", "", word).capitalize()
23
- for word in re.split(r"[ /_\-]", input_string)
24
- )
21
+ words = re.split(r"[ /_\-]", input_string)
22
+ # Then remove any non-alphanumeric characters and capitalize each word
23
+ return "".join(re.sub(r"[^a-zA-Z0-9]", "", word).capitalize() for word in words)
25
24
 
26
25
 
27
- def to_snake_case(input_string: str | None) -> str:
26
+ def to_snake_case(input_string: str) -> str:
28
27
  """
29
- Convert a string to snake_case.
28
+ Convert a string to snake_case. Filters out any non-alphanumeric characters.
30
29
  """
31
- if input_string is None:
32
- return ""
33
- return "_".join(
34
- re.sub(r"[\[\]{}():]", "", word).lower()
35
- for word in re.split(r"[ /_\-]", input_string)
36
- )
30
+ words = re.split(r"[ /_\-]", input_string)
31
+ return "_".join(re.sub(r"[^a-zA-Z0-9]", "", word).lower() for word in words)
37
32
 
38
33
 
39
34
  def to_string_val(input_val: Any) -> str:
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Callable
4
4
 
5
5
  from pydantic import BaseModel, ConfigDict
6
6
 
7
- from liminal.utils import pascalize
7
+ from liminal.utils import to_pascal_case
8
8
  from liminal.validation.validation_severity import ValidationSeverity
9
9
 
10
10
  if TYPE_CHECKING:
@@ -137,14 +137,14 @@ def liminal_validator(
137
137
  valid=False,
138
138
  level=validator_level,
139
139
  entity=self,
140
- validator_name=validator_name or pascalize(func.__name__),
140
+ validator_name=validator_name or to_pascal_case(func.__name__),
141
141
  message=str(e),
142
142
  )
143
143
  return BenchlingValidatorReport.create_validation_report(
144
144
  valid=True,
145
145
  level=validator_level,
146
146
  entity=self,
147
- validator_name=validator_name or pascalize(func.__name__),
147
+ validator_name=validator_name or to_pascal_case(func.__name__),
148
148
  )
149
149
 
150
150
  setattr(wrapper, "_is_liminal_validator", True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: liminal-orm
3
- Version: 3.1.0
3
+ Version: 3.1.1
4
4
  Summary: An ORM and toolkit that builds on top of Benchling's platform to keep your schemas and downstream code dependencies in sync.
5
5
  Home-page: https://github.com/dynotx/liminal-orm
6
6
  Author: DynoTx Open Source
@@ -18,14 +18,14 @@ liminal/connection/benchling_connection.py,sha256=PLiaI4v9EcJDNBEO5ZF3jERuI6AYo8
18
18
  liminal/connection/benchling_service.py,sha256=lEYCHF1U8nII8Rn3rMBPTffTFiVFjoFeNmX2Kq36-qE,7170
19
19
  liminal/dropdowns/api.py,sha256=n5oxi1EhkmpmPpNi1LOI4xcIQmk1C069XFaGP5XSBx8,6959
20
20
  liminal/dropdowns/compare.py,sha256=-UbCkeTKx3THwvjMTUubyYVXBkhmvyhEKzwrIzBkthY,7141
21
- liminal/dropdowns/generate_files.py,sha256=IqnBs-IyLsIZE0NUkdB99zd5EAF-1f9CPBeblz-GzJE,2041
21
+ liminal/dropdowns/generate_files.py,sha256=Y6biJOrt1XtWcTMoIV_eC2Yqwg6JYQxyF85U78s6M7U,2051
22
22
  liminal/dropdowns/operations.py,sha256=-TRIsxqnUtrIUjhrt5k_PdiBCDUXsXDzsOUmznJE-6Q,13516
23
23
  liminal/dropdowns/utils.py,sha256=1-H7bTszCUeqeRBpiYXjRjreDzhn1Fd1MFwIsrEI-o4,4109
24
24
  liminal/entity_schemas/api.py,sha256=Emn_Y95cAG9Wis6tpchw6QBVKQh4If86LOdgKk0Ndjw,3575
25
25
  liminal/entity_schemas/compare.py,sha256=t6tl67GWaMoNNcPxyLpCuNAlN3OWNqURTo3EUEMtETE,17549
26
26
  liminal/entity_schemas/entity_schema_models.py,sha256=v5A1ELaiuBnUSl1HkUNAeMuIRQeQnIKzfpFxmsiKWh0,8349
27
- liminal/entity_schemas/generate_files.py,sha256=u9SoDO9f4qL2nZaddln__2J0zJ3QMFBQhiUabn22aUY,9032
28
- liminal/entity_schemas/operations.py,sha256=cMJ5P1drs-Gv9E3YbsT3jTe48wJswxgPWYdV1qSawq0,26952
27
+ liminal/entity_schemas/generate_files.py,sha256=AwthMaPLG9DA7sb_mrQcDag3XxMOEZqTkj5DWFMEy98,9057
28
+ liminal/entity_schemas/operations.py,sha256=N58H8LP1fuRCjRecG6G43ZdAX7MEL2lxPLQPmc23Wlw,27119
29
29
  liminal/entity_schemas/tag_schema_models.py,sha256=DZQYzlxt3aEHbLy00qEyDZC_mRyi9I325ggkfcNgR1I,24153
30
30
  liminal/entity_schemas/utils.py,sha256=2ZHyLxnYITVEuyAWxNdsq5hcNSgvN7pN3-uUzyocYSk,6161
31
31
  liminal/enums/__init__.py,sha256=-szuqAwMED4ai0NaPVUfgihQJAJ27wPu_nDnj4cEgTk,518
@@ -60,11 +60,11 @@ liminal/tests/from benchling_sdk.py,sha256=CjRUHFB3iaa4rUPLGOqDiBq5EPKldm-Fd8aQQ
60
60
  liminal/tests/test_dropdown_compare.py,sha256=yHB0ovQlBLRu8-qYkqIPd8VtYEOmOft_93FQM86g_z8,8198
61
61
  liminal/tests/test_entity_schema_compare.py,sha256=-26Bu5eYIuHRswB5kYjGDo5Wed5LUWjm1e6IRI1Q-lE,18952
62
62
  liminal/unit_dictionary/utils.py,sha256=o3K06Yyt33iIUSMHPT8f1vSuUSgWjZLf51p78lx4SZs,1817
63
- liminal/utils.py,sha256=radRtRsZmCiNblMvxOX1DH0rcO5TR09kFlp6OONIPBU,2951
64
- liminal/validation/__init__.py,sha256=TVaHrSF3GnSd4mbZrPn8TBHscGWkAPKAUUPq7-symC8,5275
63
+ liminal/utils.py,sha256=ZiehcgE0We5i9Ry6tQO_f8QoQEOaiO4SFOQnFbq-29o,3068
64
+ liminal/validation/__init__.py,sha256=NsjzmivSRwGki1k9ykJgjtcYNcILR_PHSf6RkI1w2n0,5290
65
65
  liminal/validation/validation_severity.py,sha256=ib03PTZCQHcbBDc01v4gJF53YtA-ANY6QSFnhTV-FbU,259
66
- liminal_orm-3.1.0.dist-info/LICENSE.md,sha256=oVA877F_D1AV44dpjsv4f-4k690uNGApX1EtzOo3T8U,11353
67
- liminal_orm-3.1.0.dist-info/METADATA,sha256=jC90ZQqaPXCKH8dvJ4oyA5HjPG-dAX3gnPDCEWLfsIk,11032
68
- liminal_orm-3.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
69
- liminal_orm-3.1.0.dist-info/entry_points.txt,sha256=atIrU63rrzH81dWC2sjUbFLlc5FWMmYRdMxXEWexIZA,47
70
- liminal_orm-3.1.0.dist-info/RECORD,,
66
+ liminal_orm-3.1.1.dist-info/LICENSE.md,sha256=oVA877F_D1AV44dpjsv4f-4k690uNGApX1EtzOo3T8U,11353
67
+ liminal_orm-3.1.1.dist-info/METADATA,sha256=u4jC_Fbe5Idl6MDpUMbIauCIhmgFEQiXMZyNkUv_QmE,11032
68
+ liminal_orm-3.1.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
69
+ liminal_orm-3.1.1.dist-info/entry_points.txt,sha256=atIrU63rrzH81dWC2sjUbFLlc5FWMmYRdMxXEWexIZA,47
70
+ liminal_orm-3.1.1.dist-info/RECORD,,