liminal-orm 1.0.2rc0__py3-none-any.whl → 1.0.3__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.
liminal/cli/cli.py CHANGED
@@ -78,8 +78,8 @@ def generate_files(
78
78
  benchling_tenant: str = typer.Argument(
79
79
  ..., help="Benchling tenant (or alias) to connect to."
80
80
  ),
81
- write_path: Path = typer.Argument(
82
- ..., help="The path to write the generated files to."
81
+ write_path: Path = typer.Option(
82
+ Path("."), help="The path to write the generated files to."
83
83
  ),
84
84
  ) -> None:
85
85
  current_revision_id, benchling_connection = read_local_env_file(
@@ -19,7 +19,7 @@ def compare_dropdowns(
19
19
  ) -> dict[str, list[CompareOperation]]:
20
20
  dropdown_operations: dict[str, list[CompareOperation]] = {}
21
21
  benchling_dropdowns: dict[str, Dropdown] = get_benchling_dropdowns_dict(
22
- benchling_service
22
+ benchling_service, include_archived=True
23
23
  )
24
24
  processed_benchling_names = set()
25
25
  model_dropdowns = BaseDropdown.get_all_subclasses(dropdown_names)
@@ -57,15 +57,15 @@ def get_benchling_dropdown_by_name(
57
57
 
58
58
  def get_benchling_dropdowns_dict(
59
59
  benchling_service: BenchlingService,
60
+ include_archived: bool = False,
60
61
  ) -> dict[str, Dropdown]:
61
- with requests.Session() as session:
62
- request = session.get(
63
- f"https://{benchling_service.benchling_tenant}.benchling.com/1/api/schema-field-selectors/?registryId={benchling_service.registry_id}",
64
- headers=benchling_service.custom_post_headers,
65
- cookies=benchling_service.custom_post_cookies,
66
- )
67
- return {
68
- d["name"]: Dropdown(
62
+ def _convert_dropdown_from_json(
63
+ d: dict[str, Any], include_archived: bool = False
64
+ ) -> Dropdown:
65
+ all_options = d["allSchemaFieldSelectorOptions"]
66
+ if not include_archived:
67
+ all_options = [o for o in all_options if not o["archiveRecord"]]
68
+ return Dropdown(
69
69
  id=d["id"],
70
70
  name=d["name"],
71
71
  archive_record=BenchlingArchiveRecord(reason=d["archiveRecord"]["purpose"])
@@ -81,11 +81,26 @@ def get_benchling_dropdowns_dict(
81
81
  if o["archiveRecord"]
82
82
  else None,
83
83
  )
84
- for o in d["allSchemaFieldSelectorOptions"]
84
+ for o in all_options
85
85
  ],
86
86
  )
87
- for d in request.json()["selectorsByRegistryId"][benchling_service.registry_id]
87
+
88
+ with requests.Session() as session:
89
+ request = session.get(
90
+ f"https://{benchling_service.benchling_tenant}.benchling.com/1/api/schema-field-selectors/?registryId={benchling_service.registry_id}",
91
+ headers=benchling_service.custom_post_headers,
92
+ cookies=benchling_service.custom_post_cookies,
93
+ )
94
+ all_dropdowns = request.json()["selectorsByRegistryId"][
95
+ benchling_service.registry_id
96
+ ]
97
+ if not include_archived:
98
+ all_dropdowns = [d for d in all_dropdowns if not d["archiveRecord"]]
99
+ dropdowns = {
100
+ d["name"]: _convert_dropdown_from_json(d, include_archived)
101
+ for d in all_dropdowns
88
102
  }
103
+ return dropdowns
89
104
 
90
105
 
91
106
  def dropdown_exists_in_benchling(
@@ -90,7 +90,7 @@ def generate_all_entity_schema_files(
90
90
  dropdown_classname = dropdown_name_to_classname_map[col.dropdown_link]
91
91
  dropdowns.append(dropdown_classname)
92
92
  column_strings.append(
93
- f"""{tab}{col_name}: SqlColumn = Column(name="{col.name}", type={str(col.type)}, required={col.required}{', is_multi=True' if col.is_multi else ''}{', parent_link=True' if col.parent_link else ''}{f', entity_link="{col.entity_link}"' if col.entity_link else ''}{f', dropdown={dropdown_classname}' if dropdown_classname else ''})"""
93
+ f"""{tab}{col_name}: SqlColumn = Column(name="{col.name}", type={str(col.type)}, required={col.required}{', is_multi=True' if col.is_multi else ''}{', parent_link=True' if col.parent_link else ''}{f', entity_link="{col.entity_link}"' if col.entity_link else ''}{f', dropdown={dropdown_classname}' if dropdown_classname else ''}{f', tooltip="{col.tooltip}"' if col.tooltip else ''})"""
94
94
  )
95
95
  if col.required and col.type:
96
96
  init_strings.append(
@@ -41,6 +41,9 @@ def convert_tag_schema_to_internal_schema(
41
41
  dropdowns_map: dict[str, str],
42
42
  include_archived_fields: bool = False,
43
43
  ) -> tuple[SchemaProperties, dict[str, BaseFieldProperties]]:
44
+ all_fields = tag_schema.allFields
45
+ if not include_archived_fields:
46
+ all_fields = [f for f in all_fields if not f.archiveRecord]
44
47
  return (
45
48
  SchemaProperties(
46
49
  name=tag_schema.name,
@@ -63,11 +66,7 @@ def convert_tag_schema_to_internal_schema(
63
66
  ).set_archived(tag_schema.archiveRecord is not None),
64
67
  {
65
68
  f.systemName: convert_tag_schema_field_to_field_properties(f, dropdowns_map)
66
- for f in (
67
- tag_schema.allFields
68
- if include_archived_fields
69
- else [f for f in tag_schema.allFields if not f.archiveRecord]
70
- )
69
+ for f in all_fields
71
70
  },
72
71
  )
73
72
 
liminal/utils.py CHANGED
@@ -9,14 +9,14 @@ from liminal.connection.benchling_service import BenchlingService
9
9
 
10
10
  def pascalize(input_string: str) -> str:
11
11
  return "".join(
12
- re.sub(r"[\[\]{}()]", "", word).capitalize()
12
+ re.sub(r"[\[\]{}():]", "", word).capitalize()
13
13
  for word in re.split(r"[ /_\-]", input_string)
14
14
  )
15
15
 
16
16
 
17
17
  def to_snake_case(input_string: str) -> str:
18
18
  return "_".join(
19
- re.sub(r"[\[\]{}()]", "", word).lower()
19
+ re.sub(r"[\[\]{}():]", "", word).lower()
20
20
  for word in re.split(r"[ /_\-]", input_string)
21
21
  )
22
22
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: liminal-orm
3
- Version: 1.0.2rc0
3
+ Version: 1.0.3
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
  Author: DynoTx Open Source
6
6
  Author-email: opensource@dynotx.com
@@ -12,8 +12,8 @@ Classifier: Programming Language :: Python :: 3.11
12
12
  Requires-Dist: benchling-sdk (>=1.8.0)
13
13
  Requires-Dist: bs4 (>=0.0.2,<0.0.3)
14
14
  Requires-Dist: lxml (>=5.3.0,<6.0.0)
15
- Requires-Dist: pandas (>=2.2.3,<3.0.0)
16
- Requires-Dist: pydantic (>=2,<2.7)
15
+ Requires-Dist: pandas (>=1.5.3)
16
+ Requires-Dist: pydantic (>=2,<=2.7)
17
17
  Requires-Dist: requests (>=2.32.3,<3.0.0)
18
18
  Requires-Dist: rich (>=13.9.2,<14.0.0)
19
19
  Requires-Dist: sqlalchemy (<2)
@@ -6,7 +6,7 @@ liminal/base/compare_operation.py,sha256=hkpv4ewHhxy4dlTPKgJuzBjsAqO6Km7OrrKB44p
6
6
  liminal/base/properties/base_field_properties.py,sha256=V9UlY_geSoOhx_Iwiw2eZ7kDKghYy4Xa5bbGcCOFDk8,4511
7
7
  liminal/base/properties/base_schema_properties.py,sha256=XIgTZvWYjqpSXJ-_uSew0sp-wWRb62-McmJtJ5rdNg0,3925
8
8
  liminal/base/str_enum.py,sha256=jF3d-Lo8zsHUe6GsctX2L-TSj92Y3qCYDrTD-saeJoc,210
9
- liminal/cli/cli.py,sha256=tIdepgPf3UoZcKec93rN6yc3JfOs-GA9SoIdGJs4fi8,8994
9
+ liminal/cli/cli.py,sha256=Bv0H_RWLpPxaCNmD4X9l_0wYQ8VCDbAHwALvCTUxB1g,8998
10
10
  liminal/cli/controller.py,sha256=QNj3QO9TMb9hfc6U-VhLuFa0_aohOHZUmvY4XkATPhw,10118
11
11
  liminal/cli/live_test_dropdown_migration.py,sha256=i20JkY5xmLffHrB73WOl3Tjyb4V2RPb3rt7-wh-BwME,2826
12
12
  liminal/cli/live_test_entity_schema_migration.py,sha256=X03tEYYHYDXeXHWgLc9tcwksKVvr0b7nlYQndDS4MvA,5683
@@ -14,17 +14,17 @@ liminal/connection/__init__.py,sha256=3z4pSANIOkc9mh1Xp763oYQuJZDEh4lauN901PU4vq
14
14
  liminal/connection/benchling_connection.py,sha256=ZcKmaQE6T_yjAaSPF69e2PnhoZz5yZ_0TywjVykr0TM,2358
15
15
  liminal/connection/benchling_service.py,sha256=SEydyYUV3Zm55gAWs8tL2U9feLgbZITV_hH40aXIfBU,7397
16
16
  liminal/dropdowns/api.py,sha256=n5oxi1EhkmpmPpNi1LOI4xcIQmk1C069XFaGP5XSBx8,6959
17
- liminal/dropdowns/compare.py,sha256=N2niypG547k9e-iwWMi-TmlRDEiYAPkiVYaPRDVSXhU,6806
17
+ liminal/dropdowns/compare.py,sha256=5cz8djtaStozUun_Cp8t_5PVjq-aovme2Qq5J8FXFg4,6829
18
18
  liminal/dropdowns/generate_files.py,sha256=IqnBs-IyLsIZE0NUkdB99zd5EAF-1f9CPBeblz-GzJE,2041
19
19
  liminal/dropdowns/operations.py,sha256=U1pHLVWEj4Rgms9sV4rpDuvCVm_NsQxJKLhsezx2bMw,13479
20
- liminal/dropdowns/utils.py,sha256=WGqF4WfPvk3SXg0106y7COGQep_Po8Y_mNsJI6Od-a8,3550
20
+ liminal/dropdowns/utils.py,sha256=1-H7bTszCUeqeRBpiYXjRjreDzhn1Fd1MFwIsrEI-o4,4109
21
21
  liminal/entity_schemas/api.py,sha256=Dkd44NGJ4JqRTJLJtPsZ8Qan2owbEYf446A6EuP8iL0,2786
22
22
  liminal/entity_schemas/compare.py,sha256=EL5v82FEBxMIubhlQmsmQO7a-EZeMWXRU2pBt9HmzPI,13849
23
23
  liminal/entity_schemas/entity_schema_models.py,sha256=X2ouBUWIonrWeB3hMVj0bCqchbcztrp3joaftv8yHWo,5393
24
- liminal/entity_schemas/generate_files.py,sha256=XdnyoTDitQKUrC7xrYBWzyFWw_xHQgoS4UV-dtOqUuU,8389
24
+ liminal/entity_schemas/generate_files.py,sha256=ZiTk_6wqnW_5_uW6gfCP13qUGd8uqlIh-wi7ydSk8N0,8442
25
25
  liminal/entity_schemas/operations.py,sha256=sub6rigZjro72EMqqsayOYNxPL6eDYwCCIlzMr9sNfQ,23306
26
26
  liminal/entity_schemas/tag_schema_models.py,sha256=VVqI9iC7T_p1RZJSu09AsptK7Cr-YQvXjYP5cjhpeBo,15979
27
- liminal/entity_schemas/utils.py,sha256=JkCns-RqyaGzQRYyWW0ma1yb7BBHoNxprw5MUbsspzY,4213
27
+ liminal/entity_schemas/utils.py,sha256=tJVEfpJ6CtpuYI1_LWOE5-pGzNe0bsrGluLbU8sc9EM,4192
28
28
  liminal/enums/__init__.py,sha256=jz_c-B_fifatvrYoESlHZ9ljYdz-3rNl0sBazoESiHI,523
29
29
  liminal/enums/benchling_api_field_type.py,sha256=DEMlkvKuc8kaslnKdWsdB8Z70OY3CGwOHfZNC3a1SOE,528
30
30
  liminal/enums/benchling_entity_type.py,sha256=t00mcbzbfQ9oiHt8xPrmNYs9bK7Bmk6F1dcoQubzmUs,409
@@ -52,10 +52,10 @@ liminal/tests/conftest.py,sha256=kKli52zn-J48Tsqbqejyd8Mtref5gVg3_Qex6KbLHd8,160
52
52
  liminal/tests/from benchling_sdk.py,sha256=CjRUHFB3iaa4rUPLGOqDiBq5EPKldm-Fd8aQQr92zF4,147
53
53
  liminal/tests/test_dropdown_compare.py,sha256=yHB0ovQlBLRu8-qYkqIPd8VtYEOmOft_93FQM86g_z8,8198
54
54
  liminal/tests/test_entity_schema_compare.py,sha256=FBYxqIB9oeFArWYKnbGV8I7NPzv2syziaPjEQg-wZ1o,15529
55
- liminal/utils.py,sha256=8aY7jvSBd3P1NNenHp4cRCNmjApSBC6DdMuAZMcvGvw,2564
55
+ liminal/utils.py,sha256=UT07vILwm9fu8DLgwIxMm1DxEPFIIsW-0mgBU8oNrNY,2566
56
56
  liminal/validation/__init__.py,sha256=SBd48xxBMJrBzI48G2RcK056EMlevt5YjmZMkfCWN1I,6924
57
- liminal_orm-1.0.2rc0.dist-info/LICENSE.md,sha256=oVA877F_D1AV44dpjsv4f-4k690uNGApX1EtzOo3T8U,11353
58
- liminal_orm-1.0.2rc0.dist-info/METADATA,sha256=f2riPIO-DL2a9H1AVYKssB1ZbXE3VYx4sj4OoinjxOA,11805
59
- liminal_orm-1.0.2rc0.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
60
- liminal_orm-1.0.2rc0.dist-info/entry_points.txt,sha256=atIrU63rrzH81dWC2sjUbFLlc5FWMmYRdMxXEWexIZA,47
61
- liminal_orm-1.0.2rc0.dist-info/RECORD,,
57
+ liminal_orm-1.0.3.dist-info/LICENSE.md,sha256=oVA877F_D1AV44dpjsv4f-4k690uNGApX1EtzOo3T8U,11353
58
+ liminal_orm-1.0.3.dist-info/METADATA,sha256=kZKg7zRldnulEPHB9ryLiPzSs9EnRYil6QbJSBLJT48,11796
59
+ liminal_orm-1.0.3.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
60
+ liminal_orm-1.0.3.dist-info/entry_points.txt,sha256=atIrU63rrzH81dWC2sjUbFLlc5FWMmYRdMxXEWexIZA,47
61
+ liminal_orm-1.0.3.dist-info/RECORD,,