liminal-orm 1.0.3.dev1__tar.gz → 1.0.4__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 (60) hide show
  1. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/PKG-INFO +37 -18
  2. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/README.md +32 -17
  3. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/base_dropdown.py +10 -0
  4. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/cli/cli.py +2 -2
  5. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/connection/benchling_service.py +2 -2
  6. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/dropdowns/compare.py +1 -1
  7. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/dropdowns/utils.py +25 -10
  8. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/generate_files.py +1 -1
  9. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/utils.py +4 -5
  10. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/migrate/revision.py +1 -1
  11. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/migrate/utils.py +23 -10
  12. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/column.py +9 -9
  13. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/utils.py +2 -2
  14. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/pyproject.toml +8 -2
  15. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/LICENSE.md +0 -0
  16. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/__init__.py +0 -0
  17. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/base_operation.py +0 -0
  18. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/base_validation_filters.py +0 -0
  19. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/compare_operation.py +0 -0
  20. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/properties/base_field_properties.py +0 -0
  21. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/properties/base_schema_properties.py +0 -0
  22. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/base/str_enum.py +0 -0
  23. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/cli/controller.py +0 -0
  24. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/cli/live_test_dropdown_migration.py +0 -0
  25. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/cli/live_test_entity_schema_migration.py +0 -0
  26. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/connection/__init__.py +0 -0
  27. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/connection/benchling_connection.py +0 -0
  28. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/dropdowns/api.py +0 -0
  29. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/dropdowns/generate_files.py +0 -0
  30. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/dropdowns/operations.py +0 -0
  31. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/api.py +0 -0
  32. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/compare.py +0 -0
  33. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/entity_schema_models.py +0 -0
  34. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/operations.py +0 -0
  35. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/entity_schemas/tag_schema_models.py +0 -0
  36. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/__init__.py +0 -0
  37. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_api_field_type.py +0 -0
  38. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_entity_type.py +0 -0
  39. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_field_type.py +0 -0
  40. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_folder_item_type.py +0 -0
  41. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_naming_strategy.py +0 -0
  42. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_report_level.py +0 -0
  43. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/enums/benchling_sequence_type.py +0 -0
  44. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/external/__init__.py +0 -0
  45. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/mappers.py +0 -0
  46. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/migrate/components.py +0 -0
  47. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/migrate/revisions_timeline.py +0 -0
  48. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/base.py +0 -0
  49. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/base_model.py +0 -0
  50. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/mixins.py +0 -0
  51. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/relationship.py +0 -0
  52. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/schema_properties.py +0 -0
  53. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/orm/user.py +0 -0
  54. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/py.typed +0 -0
  55. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/tests/__init__.py +0 -0
  56. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/tests/conftest.py +0 -0
  57. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/tests/from benchling_sdk.py +0 -0
  58. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/tests/test_dropdown_compare.py +0 -0
  59. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/tests/test_entity_schema_compare.py +0 -0
  60. {liminal_orm-1.0.3.dev1 → liminal_orm-1.0.4}/liminal/validation/__init__.py +0 -0
@@ -1,7 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: liminal-orm
3
- Version: 1.0.3.dev1
3
+ Version: 1.0.4
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
+ Home-page: https://github.com/dynotx/liminal-orm
5
6
  Author: DynoTx Open Source
6
7
  Author-email: opensource@dynotx.com
7
8
  Requires-Python: >=3.9,<4
@@ -19,26 +20,30 @@ Requires-Dist: rich (>=13.9.2,<14.0.0)
19
20
  Requires-Dist: sqlalchemy (<2)
20
21
  Requires-Dist: tenacity (>=8,<10)
21
22
  Requires-Dist: typer (>=0.12.5,<0.13.0)
23
+ Project-URL: Bug Tracker, https://github.com/dynotx/liminal-orm/issues
24
+ Project-URL: Documentation, https://dynotx.github.io/liminal-orm/
25
+ Project-URL: Repository, https://github.com/dynotx/liminal-orm
22
26
  Description-Content-Type: text/markdown
23
27
 
24
28
  # [Liminal ORM](#liminal-orm)
25
29
 
26
- Liminal ORM<sup>1</sup> is a Python package that builds on top of [Benchling](https://www.benchling.com/)'s LIMS<sup>2</sup> platform to keep your Benchling schemas and downstream code dependencies in sync. Liminal provides an ORM framework using [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy) that allows you to define all your Benchling schemas in code. This creates a single source of truth that Benchling managers can use to keep multiple tenants in sync. This enables a code-first approach for managing Benchling tenants and accessing Benchling data. With the schemas defined in code, you can now take advantage of the additional capabilities that the Liminal toolkit provides. This includes:
30
+ Liminal ORM<sup>1</sup> is an open-source Python package that builds on [Benchling's](https://www.benchling.com/) LIMS<sup>2</sup> platform and provides a simple framework to keep your upstream Benchling schemas and downstream dependencies in sync. Liminal provides an ORM framework using [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy) along with a schema migration service inspired by [Alembic](https://alembic.sqlalchemy.org/en/latest/). This allows you to define your Benchling schemas in code and create a *single source of truth* that synchronizes with your upstream Benchling tenant(s) and downstream dependencies. Through one line CLI commands, Liminal enables a code-first approach for managing Benchling tenants and accessing Benchling data. With the schemas defined in code, you can also take advantage of the additional capabilities that the Liminal toolkit provides. This includes:
27
31
 
28
- - The ability to run migrations to your Benchling tenant(s) through an easy to use CLI<sup>3</sup>.
32
+ - The ability to run migrations to your Benchling tenant(s) through an easy to use CLI.
29
33
  - One source of truth defined in code for your Benchling schema model that your many Benchling tenants can stay in sync with.
30
34
  - Easy to implement validation rules to reflect business logic for all of your Benchling entities.
31
35
  - Strongly typed queries for all your Benchling entities.
32
36
  - CI/CD integration with GitHub Actions to ensure that your Benchling schemas and code are always in sync.
33
- - And more!
37
+ - And more based on community contributions/feedback :)
34
38
 
35
39
  Benchling is an industry standard cloud platform for life sciences R&D. Liminal builds on top of Benchling's platform and assumes that you already have a Benchling tenant set up and have (or have access to) an admin user account. If not, learn more about getting started with Benchling [here](https://www.benchling.com/explore-benchling)!
36
40
 
37
- For a full and in-depth overview of Liminal, please refer to our [full documentation](https://dynotx.github.io/liminal-orm/). Below is a [quickstart guide](#getting-started) to get you Liminal set up in your project.
41
+ If you are a Benchling user, try out Liminal by following the [quickstart guide](./getting-started/prerequisites.md)! Reach out in the [Discussions](https://github.com/dynotx/liminal-orm/discussions) forum with any questions or to simply introduce yourself! If there is something blocking you from using Liminal or you're having trouble setting Liminal up, please share in [Issues](https://github.com/dynotx/liminal-orm/issues) or reach out directly (contact information below). You can expect responses within 48 hours :)
38
42
 
39
- Reach out in the [Discussions](https://github.com/dynotx/liminal-orm/discussions) forum with any questions or to simply introduce yourself! If you run into any issues, during setup or usage, don't hesitate to post in [Issues](https://github.com/dynotx/liminal-orm/issues) or reach out directly at <opensource@dynotx.com>. You can expect responses within 48 hours :)
43
+ Nirmit Damania is the creator and current maintainer of Liminal (I post Liminal updates to [Discussions](https://github.com/dynotx/liminal-orm/discussions) and my [LinkedIn](https://www.linkedin.com/in/nirmit-damania/)). Most importantly, **you** have the ability to influence the future of Liminal! Any feedback, positive or negative, is highly encouraged and will be used to steer the direction of Liminal. Refer to the [Contributing guide](https://github.com/dynotx/liminal-orm/blob/main/CONTRIBUTING.md) to learn more about how you can contribute to Liminal.
40
44
 
41
45
  ⭐️ Leave a star on the repo to spread the word!
46
+ If you or your organization use Liminal, please consider adding yourself or your organization to the [Users](https://github.com/dynotx/liminal-orm/blob/main/USERS.md) list.
42
47
 
43
48
  <img width="793" alt="liminal_simple_graph" src="https://github.com/user-attachments/assets/52e32cd0-3407-49f5-b100-5763bee3830c">
44
49
 
@@ -50,6 +55,7 @@ Reach out in the [Discussions](https://github.com/dynotx/liminal-orm/discussions
50
55
  - [Setup](#setup)
51
56
  - [Migration](#migration)
52
57
  - [Toolkit](#toolkit)
58
+ - [Mission](#mission)
53
59
  - [Community](#community)
54
60
  - [Contributing](#contributing)
55
61
  - [License](#license)
@@ -141,18 +147,22 @@ With your schemas defined in code, you can now take advantage of the additional
141
147
  1. Entity validation: Easily create custom validation rules for your Benchling entities.
142
148
 
143
149
  ```python
144
- from dyno.liminal.orm.base_model import BaseModel
145
- from dyno.liminal.orm.mixins import CustomEntityMixin
146
-
147
- class Pizza(BaseModel, CustomEntityMixin):
148
- ...
149
-
150
- @validator(BenchlingReportLevel.HIGH)
151
- def cook_temp_time(self):
152
- if self.cook_time is not None and self.cook_temp is None:
153
- raise ValueError("Cook temp is required if cook time is set")
154
- if self.cook_time is None and self.cook_temp is not None:
155
- raise ValueError("Cook time is required if cook temp is set")
150
+ from liminal.validation import BenchlingValidator, BenchlingValidatorReport, BenchlingReportLevel
151
+ from liminal.orm.base_model import BaseModel
152
+
153
+ class CookTempValidator(BenchlingValidator):
154
+ """Validates that a field value is a valid enum value for a Benchling entity"""
155
+
156
+ def validate(self, entity: type[BaseModel]) -> BenchlingValidatorReport:
157
+ valid = True
158
+ message = None
159
+ if entity.cook_time is not None and entity.cook_temp is None:
160
+ valid = False
161
+ message = "Cook temp is required if cook time is set"
162
+ if entity.cook_time is None and entity.cook_temp is not None:
163
+ valid = False
164
+ message = "Cook time is required if cook temp is set"
165
+ return self.create_report(valid, BenchlingReportLevel.MED, entity, message)
156
166
  ```
157
167
 
158
168
  2. Strongly typed queries: Write type-safe queries using SQLAlchemy to access your Benchling entities.
@@ -167,6 +177,10 @@ With your schemas defined in code, you can now take advantage of the additional
167
177
 
168
178
  4. And more to come!
169
179
 
180
+ ## [Mission](#mission)
181
+
182
+ The democratization of software in Biotech is crucial. By building a community around complex, yet common, problems and creating open-source solutions, we can work together to tackle these challenges together and enable faster innovation in the industry. By breaking down the silos between private platforms, we can enable a more dynamic and open ecosystem. This was the motivation for Liminal's creation. Liminal's goal is to create an open-source software product that enables a standard, code-first approach to configuration and change management for LIMS systems. We started with Benchling, but the goal is to make Liminal the go-to solution for any LIMS system.
183
+
170
184
  ## [Community](#community)
171
185
 
172
186
  We're excited to hear from you! Feel free to introduce yourself on the [Liminal GitHub Discussions page](https://github.com/dynotx/liminal-orm/discussions/categories/intros)
@@ -184,6 +198,11 @@ Please refer to [CONTRIBUTING.md](./CONTRIBUTING.md) to learn how to contribute
184
198
 
185
199
  Liminal ORM is distributed under the [Apache License, Version 2.0](./LICENSE.md).
186
200
 
201
+ ## [Direct Contact](#direct-contact)
202
+
203
+ - Email: <opensource@dynotx.com>
204
+ - LinkedIn: [Nirmit Damania](https://www.linkedin.com/in/nirmit-damania/)
205
+
187
206
  ## [Acknowledgements](#acknowledgements)
188
207
 
189
208
  This project could not have been started without the support of Dyno Therapeutics and the help of the following people.
@@ -1,21 +1,22 @@
1
1
  # [Liminal ORM](#liminal-orm)
2
2
 
3
- Liminal ORM<sup>1</sup> is a Python package that builds on top of [Benchling](https://www.benchling.com/)'s LIMS<sup>2</sup> platform to keep your Benchling schemas and downstream code dependencies in sync. Liminal provides an ORM framework using [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy) that allows you to define all your Benchling schemas in code. This creates a single source of truth that Benchling managers can use to keep multiple tenants in sync. This enables a code-first approach for managing Benchling tenants and accessing Benchling data. With the schemas defined in code, you can now take advantage of the additional capabilities that the Liminal toolkit provides. This includes:
3
+ Liminal ORM<sup>1</sup> is an open-source Python package that builds on [Benchling's](https://www.benchling.com/) LIMS<sup>2</sup> platform and provides a simple framework to keep your upstream Benchling schemas and downstream dependencies in sync. Liminal provides an ORM framework using [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy) along with a schema migration service inspired by [Alembic](https://alembic.sqlalchemy.org/en/latest/). This allows you to define your Benchling schemas in code and create a *single source of truth* that synchronizes with your upstream Benchling tenant(s) and downstream dependencies. Through one line CLI commands, Liminal enables a code-first approach for managing Benchling tenants and accessing Benchling data. With the schemas defined in code, you can also take advantage of the additional capabilities that the Liminal toolkit provides. This includes:
4
4
 
5
- - The ability to run migrations to your Benchling tenant(s) through an easy to use CLI<sup>3</sup>.
5
+ - The ability to run migrations to your Benchling tenant(s) through an easy to use CLI.
6
6
  - One source of truth defined in code for your Benchling schema model that your many Benchling tenants can stay in sync with.
7
7
  - Easy to implement validation rules to reflect business logic for all of your Benchling entities.
8
8
  - Strongly typed queries for all your Benchling entities.
9
9
  - CI/CD integration with GitHub Actions to ensure that your Benchling schemas and code are always in sync.
10
- - And more!
10
+ - And more based on community contributions/feedback :)
11
11
 
12
12
  Benchling is an industry standard cloud platform for life sciences R&D. Liminal builds on top of Benchling's platform and assumes that you already have a Benchling tenant set up and have (or have access to) an admin user account. If not, learn more about getting started with Benchling [here](https://www.benchling.com/explore-benchling)!
13
13
 
14
- For a full and in-depth overview of Liminal, please refer to our [full documentation](https://dynotx.github.io/liminal-orm/). Below is a [quickstart guide](#getting-started) to get you Liminal set up in your project.
14
+ If you are a Benchling user, try out Liminal by following the [quickstart guide](./getting-started/prerequisites.md)! Reach out in the [Discussions](https://github.com/dynotx/liminal-orm/discussions) forum with any questions or to simply introduce yourself! If there is something blocking you from using Liminal or you're having trouble setting Liminal up, please share in [Issues](https://github.com/dynotx/liminal-orm/issues) or reach out directly (contact information below). You can expect responses within 48 hours :)
15
15
 
16
- Reach out in the [Discussions](https://github.com/dynotx/liminal-orm/discussions) forum with any questions or to simply introduce yourself! If you run into any issues, during setup or usage, don't hesitate to post in [Issues](https://github.com/dynotx/liminal-orm/issues) or reach out directly at <opensource@dynotx.com>. You can expect responses within 48 hours :)
16
+ Nirmit Damania is the creator and current maintainer of Liminal (I post Liminal updates to [Discussions](https://github.com/dynotx/liminal-orm/discussions) and my [LinkedIn](https://www.linkedin.com/in/nirmit-damania/)). Most importantly, **you** have the ability to influence the future of Liminal! Any feedback, positive or negative, is highly encouraged and will be used to steer the direction of Liminal. Refer to the [Contributing guide](https://github.com/dynotx/liminal-orm/blob/main/CONTRIBUTING.md) to learn more about how you can contribute to Liminal.
17
17
 
18
18
  ⭐️ Leave a star on the repo to spread the word!
19
+ If you or your organization use Liminal, please consider adding yourself or your organization to the [Users](https://github.com/dynotx/liminal-orm/blob/main/USERS.md) list.
19
20
 
20
21
  <img width="793" alt="liminal_simple_graph" src="https://github.com/user-attachments/assets/52e32cd0-3407-49f5-b100-5763bee3830c">
21
22
 
@@ -27,6 +28,7 @@ Reach out in the [Discussions](https://github.com/dynotx/liminal-orm/discussions
27
28
  - [Setup](#setup)
28
29
  - [Migration](#migration)
29
30
  - [Toolkit](#toolkit)
31
+ - [Mission](#mission)
30
32
  - [Community](#community)
31
33
  - [Contributing](#contributing)
32
34
  - [License](#license)
@@ -118,18 +120,22 @@ With your schemas defined in code, you can now take advantage of the additional
118
120
  1. Entity validation: Easily create custom validation rules for your Benchling entities.
119
121
 
120
122
  ```python
121
- from dyno.liminal.orm.base_model import BaseModel
122
- from dyno.liminal.orm.mixins import CustomEntityMixin
123
-
124
- class Pizza(BaseModel, CustomEntityMixin):
125
- ...
126
-
127
- @validator(BenchlingReportLevel.HIGH)
128
- def cook_temp_time(self):
129
- if self.cook_time is not None and self.cook_temp is None:
130
- raise ValueError("Cook temp is required if cook time is set")
131
- if self.cook_time is None and self.cook_temp is not None:
132
- raise ValueError("Cook time is required if cook temp is set")
123
+ from liminal.validation import BenchlingValidator, BenchlingValidatorReport, BenchlingReportLevel
124
+ from liminal.orm.base_model import BaseModel
125
+
126
+ class CookTempValidator(BenchlingValidator):
127
+ """Validates that a field value is a valid enum value for a Benchling entity"""
128
+
129
+ def validate(self, entity: type[BaseModel]) -> BenchlingValidatorReport:
130
+ valid = True
131
+ message = None
132
+ if entity.cook_time is not None and entity.cook_temp is None:
133
+ valid = False
134
+ message = "Cook temp is required if cook time is set"
135
+ if entity.cook_time is None and entity.cook_temp is not None:
136
+ valid = False
137
+ message = "Cook time is required if cook temp is set"
138
+ return self.create_report(valid, BenchlingReportLevel.MED, entity, message)
133
139
  ```
134
140
 
135
141
  2. Strongly typed queries: Write type-safe queries using SQLAlchemy to access your Benchling entities.
@@ -144,6 +150,10 @@ With your schemas defined in code, you can now take advantage of the additional
144
150
 
145
151
  4. And more to come!
146
152
 
153
+ ## [Mission](#mission)
154
+
155
+ The democratization of software in Biotech is crucial. By building a community around complex, yet common, problems and creating open-source solutions, we can work together to tackle these challenges together and enable faster innovation in the industry. By breaking down the silos between private platforms, we can enable a more dynamic and open ecosystem. This was the motivation for Liminal's creation. Liminal's goal is to create an open-source software product that enables a standard, code-first approach to configuration and change management for LIMS systems. We started with Benchling, but the goal is to make Liminal the go-to solution for any LIMS system.
156
+
147
157
  ## [Community](#community)
148
158
 
149
159
  We're excited to hear from you! Feel free to introduce yourself on the [Liminal GitHub Discussions page](https://github.com/dynotx/liminal-orm/discussions/categories/intros)
@@ -161,6 +171,11 @@ Please refer to [CONTRIBUTING.md](./CONTRIBUTING.md) to learn how to contribute
161
171
 
162
172
  Liminal ORM is distributed under the [Apache License, Version 2.0](./LICENSE.md).
163
173
 
174
+ ## [Direct Contact](#direct-contact)
175
+
176
+ - Email: <opensource@dynotx.com>
177
+ - LinkedIn: [Nirmit Damania](https://www.linkedin.com/in/nirmit-damania/)
178
+
164
179
  ## [Acknowledgements](#acknowledgements)
165
180
 
166
181
  This project could not have been started without the support of Dyno Therapeutics and the help of the following people.
@@ -3,6 +3,16 @@ from typing import Any
3
3
 
4
4
 
5
5
  class BaseDropdown(ABC):
6
+ """_summary_
7
+
8
+ Parameters
9
+ ----------
10
+ __benchling_name__: str
11
+ The name of the dropdown in Benchling. There can be no duplicate dropdown names in Benchling.
12
+ __allowed_values__: list[str]
13
+ The list of values for the dropdown. Order matters and reflects the order of the dropdown in Benchling. Values must be unique.
14
+ """
15
+
6
16
  __benchling_name__: str
7
17
  __allowed_values__: list[str]
8
18
 
@@ -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(
@@ -27,9 +27,9 @@ class BenchlingService(Benchling):
27
27
  The connection object that contains the credentials for the Benchling tenant.
28
28
  use_api: bool
29
29
  Whether to connect to the Benchling SDK. Requires api_client_id and api_client_secret from the connection object.
30
- use_db: bool
30
+ use_db: bool = False
31
31
  Whether to connect to the Benchling Postgres database. Requires warehouse_connection_string from the connection object.
32
- use_internal_api: bool
32
+ use_internal_api: bool = False
33
33
  Whether to connect to the Benchling internal API. Requires internal_api_admin_email and internal_api_admin_password from the connection object.
34
34
  """
35
35
 
@@ -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
 
@@ -165,7 +165,7 @@ class Revision(BaseModel):
165
165
  Path
166
166
  The path to the revision file that was written.
167
167
  """
168
- created_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
168
+ created_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
169
169
  upgrade_operation_strings = [
170
170
  o.revision_file_string() for o in self.upgrade_operations
171
171
  ]
@@ -15,8 +15,9 @@ def _check_env_file(env_file_path: Path) -> None:
15
15
  def read_local_env_file(
16
16
  env_file_path: Path, benchling_tenant: str
17
17
  ) -> tuple[str, BenchlingConnection]:
18
- """Imports the env.py file from the current working directory and returns the CURRENT_REVISION_ID variable.
18
+ """Imports the env.py file from the current working directory and returns the CURRENT_REVISION_ID variable along with the BenchlingConnection object.
19
19
  The env.py file is expected to have the CURRENT_REVISION_ID variable set to the revision id you are currently on.
20
+ The BenchlingConnection object is expected to be defined and have connection information for the Benchling API client and internal API.
20
21
  """
21
22
  _check_env_file(env_file_path)
22
23
  module_path = Path.cwd() / env_file_path
@@ -26,22 +27,34 @@ def read_local_env_file(
26
27
  module = importlib.util.module_from_spec(spec)
27
28
  spec.loader.exec_module(module)
28
29
  for attr_name in dir(module):
29
- attr = getattr(module, attr_name)
30
- if isinstance(attr, BenchlingConnection) and (
31
- benchling_tenant == attr.tenant_name
32
- or benchling_tenant == attr.tenant_alias
33
- ):
30
+ bc = getattr(module, attr_name)
31
+ if isinstance(bc, BenchlingConnection):
32
+ if not (
33
+ benchling_tenant == bc.tenant_name
34
+ or benchling_tenant == bc.tenant_alias
35
+ ):
36
+ raise Exception(
37
+ f"tenant name {benchling_tenant} does not match tenant name {bc.tenant_name} or alias {bc.tenant_alias} in liminal/env.py."
38
+ )
39
+ if not bc.api_client_id or not bc.api_client_secret:
40
+ raise Exception(
41
+ "api_client_id and api_client_secret must be provided in BenchlingConnection in liminal/env.py. This is necessary for the migration service."
42
+ )
43
+ if not bc.internal_api_admin_email or not bc.internal_api_admin_password:
44
+ raise Exception(
45
+ "internal_api_admin_email and internal_api_admin_password must be provided in BenchlingConnection in liminal/env.py. This is necessary for the migration service."
46
+ )
34
47
  try:
35
48
  current_revision_id: str = getattr(
36
- module, attr.current_revision_id_var_name
49
+ module, bc.current_revision_id_var_name
37
50
  )
38
- return current_revision_id, attr
51
+ return current_revision_id, bc
39
52
  except Exception as e:
40
53
  raise Exception(
41
- f"CURRENT_REVISION_ID variable not found in liminal/env.py. Given variable name: {attr.current_revision_id_var_name}"
54
+ f"CURRENT_REVISION_ID variable not found in liminal/env.py. Given variable name: {bc.current_revision_id_var_name}"
42
55
  ) from e
43
56
  raise Exception(
44
- f"BenchlingConnection with tenant_name {benchling_tenant} not found in liminal/env.py. Please update the env.py file with the correctly defined BenchlingConnection."
57
+ "BenchlingConnection not found in liminal/env.py. Please update the env.py file with a correctly defined BenchlingConnection."
45
58
  )
46
59
 
47
60
 
@@ -15,21 +15,21 @@ class Column(SqlColumn):
15
15
 
16
16
  Parameters
17
17
  ----------
18
- name : str | None
18
+ name : str
19
19
  The external facing name of the field.
20
- type : BenchlingFieldType | None
20
+ type : BenchlingFieldType
21
21
  The type of the field.
22
- required : bool | None
22
+ required : bool
23
23
  Whether the field is required.
24
- is_multi : bool | None
24
+ is_multi : bool = False
25
25
  Whether the field is a multi-value field.
26
- parent_link : bool | None
26
+ parent_link : bool = False
27
27
  Whether the entity link field is a parent of the entity schema.
28
- dropdown : str | None
29
- The name of the dropdown for the field.
30
- entity_link : str | None
28
+ dropdown : Type[BaseDropdown] | None = None
29
+ The dropdown for the field.
30
+ entity_link : str | None = None
31
31
  The warehouse name of the entity the field links to.
32
- tooltip : str | None
32
+ tooltip : str | None = None
33
33
  The tooltip text for the field.
34
34
  """
35
35
 
@@ -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,11 +1,17 @@
1
1
  [tool.poetry]
2
2
  name = "liminal-orm"
3
- version = "1.0.3.dev1"
3
+ version = "1.0.4"
4
4
  description = "An ORM and toolkit that builds on top of Benchling's platform to keep your schemas and downstream code dependencies in sync."
5
5
  authors = ["DynoTx Open Source <opensource@dynotx.com>"]
6
6
  readme = "README.md"
7
+ homepage = "https://github.com/dynotx/liminal-orm"
8
+ repository = "https://github.com/dynotx/liminal-orm"
9
+ documentation = "https://dynotx.github.io/liminal-orm/"
7
10
  packages = [{include = "liminal"}]
8
11
 
12
+ [tool.poetry.urls]
13
+ "Bug Tracker" = "https://github.com/dynotx/liminal-orm/issues"
14
+
9
15
  [tool.poetry.dependencies]
10
16
  python = ">=3.9,<4"
11
17
  benchling-sdk = ">=1.8.0"
@@ -22,7 +28,7 @@ lxml = "^5.3.0"
22
28
  [tool.poetry.group.dev.dependencies]
23
29
  ipykernel = "^6.29.5"
24
30
  mkdocs-material = "^9.5.41"
25
- mypy = "^1.11.2"
31
+ mypy = "^1.1.1"
26
32
  pre-commit = "^4.0.1"
27
33
  pytest = "^8.3.3"
28
34
  ruff = "^0.6.9"
File without changes