liminal-orm 2.0.0__tar.gz → 2.0.2__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 (67) hide show
  1. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/PKG-INFO +2 -2
  2. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/README.md +1 -1
  3. liminal_orm-2.0.2/liminal/base/name_template_parts.py +9 -0
  4. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/properties/base_name_template.py +1 -1
  5. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/generate_files.py +1 -1
  6. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/tag_schema_models.py +3 -3
  7. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/external/__init__.py +9 -9
  8. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/base_model.py +1 -1
  9. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/name_template.py +2 -2
  10. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/tests/test_entity_schema_compare.py +1 -1
  11. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/validation/__init__.py +56 -46
  12. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/pyproject.toml +1 -1
  13. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/LICENSE.md +0 -0
  14. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/__init__.py +0 -0
  15. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/base_dropdown.py +0 -0
  16. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/base_operation.py +0 -0
  17. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/base_validation_filters.py +0 -0
  18. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/compare_operation.py +0 -0
  19. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/properties/base_field_properties.py +0 -0
  20. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/properties/base_schema_properties.py +0 -0
  21. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/base/str_enum.py +0 -0
  22. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/cli/cli.py +0 -0
  23. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/cli/controller.py +0 -0
  24. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/cli/live_test_dropdown_migration.py +0 -0
  25. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/cli/live_test_entity_schema_migration.py +0 -0
  26. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/connection/__init__.py +0 -0
  27. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/connection/benchling_connection.py +0 -0
  28. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/connection/benchling_service.py +0 -0
  29. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/dropdowns/api.py +0 -0
  30. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/dropdowns/compare.py +0 -0
  31. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/dropdowns/generate_files.py +0 -0
  32. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/dropdowns/operations.py +0 -0
  33. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/dropdowns/utils.py +0 -0
  34. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/api.py +0 -0
  35. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/compare.py +0 -0
  36. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/entity_schema_models.py +0 -0
  37. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/operations.py +0 -0
  38. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/entity_schemas/utils.py +0 -0
  39. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/__init__.py +0 -0
  40. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/benchling_api_field_type.py +0 -0
  41. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/benchling_entity_type.py +0 -0
  42. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/benchling_field_type.py +0 -0
  43. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/benchling_folder_item_type.py +0 -0
  44. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/benchling_naming_strategy.py +0 -0
  45. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/benchling_sequence_type.py +0 -0
  46. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/enums/name_template_part_type.py +0 -0
  47. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/mappers.py +0 -0
  48. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/migrate/components.py +0 -0
  49. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/migrate/revision.py +0 -0
  50. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/migrate/revisions_timeline.py +0 -0
  51. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/migrate/utils.py +0 -0
  52. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/base.py +0 -0
  53. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/base_tables/registry_entity.py +0 -0
  54. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/base_tables/schema.py +0 -0
  55. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/base_tables/user.py +0 -0
  56. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/column.py +0 -0
  57. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/mixins.py +0 -0
  58. {liminal_orm-2.0.0/liminal/base → liminal_orm-2.0.2/liminal/orm}/name_template_parts.py +0 -0
  59. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/relationship.py +0 -0
  60. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/orm/schema_properties.py +0 -0
  61. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/py.typed +0 -0
  62. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/tests/__init__.py +0 -0
  63. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/tests/conftest.py +0 -0
  64. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/tests/from benchling_sdk.py +0 -0
  65. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/tests/test_dropdown_compare.py +0 -0
  66. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/utils.py +0 -0
  67. {liminal_orm-2.0.0 → liminal_orm-2.0.2}/liminal/validation/validation_severity.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: liminal-orm
3
- Version: 2.0.0
3
+ Version: 2.0.2
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
@@ -88,7 +88,7 @@ With your schemas defined in code, you can now take advantage of the additional
88
88
  class Pizza(BaseModel, CustomEntityMixin):
89
89
  ...
90
90
 
91
- @liminal_validator(ValidationSeverity.MED)
91
+ @liminal_validator
92
92
  def cook_time_and_temp_validator(self) -> None:
93
93
  if self.cook_time is not None and self.cook_temp is None:
94
94
  raise ValueError("Cook temp is required if cook time is set")
@@ -57,7 +57,7 @@ With your schemas defined in code, you can now take advantage of the additional
57
57
  class Pizza(BaseModel, CustomEntityMixin):
58
58
  ...
59
59
 
60
- @liminal_validator(ValidationSeverity.MED)
60
+ @liminal_validator
61
61
  def cook_time_and_temp_validator(self) -> None:
62
62
  if self.cook_time is not None and self.cook_temp is None:
63
63
  raise ValueError("Cook temp is required if cook time is set")
@@ -0,0 +1,9 @@
1
+ import warnings
2
+
3
+ from liminal.orm.name_template_parts import * # noqa: F403
4
+
5
+ warnings.warn(
6
+ "Importing from 'liminal.base.name_template_parts' is deprecated. Please import from 'liminal.orm.name_template_parts' instead.",
7
+ DeprecationWarning,
8
+ stacklevel=2,
9
+ )
@@ -4,7 +4,7 @@ from typing import Any
4
4
 
5
5
  from pydantic import BaseModel, ConfigDict
6
6
 
7
- from liminal.base.name_template_parts import NameTemplateParts
7
+ from liminal.orm.name_template_parts import NameTemplateParts
8
8
 
9
9
 
10
10
  class BaseNameTemplate(BaseModel):
@@ -135,7 +135,7 @@ def generate_all_entity_schema_files(
135
135
  if name_template != NameTemplate():
136
136
  import_strings.append("from liminal.orm.name_template import NameTemplate")
137
137
  parts_imports = [
138
- f"from liminal.base.name_template_parts import {', '.join(set([part.__class__.__name__ for part in name_template.parts]))}"
138
+ f"from liminal.orm.name_template_parts import {', '.join(set([part.__class__.__name__ for part in name_template.parts]))}"
139
139
  ]
140
140
  import_strings.extend(parts_imports)
141
141
  for col_name, col in columns.items():
@@ -5,9 +5,6 @@ from typing import Any
5
5
  import requests
6
6
  from pydantic import BaseModel
7
7
 
8
- from liminal.base.name_template_parts import (
9
- NameTemplatePart,
10
- )
11
8
  from liminal.base.properties.base_field_properties import BaseFieldProperties
12
9
  from liminal.base.properties.base_name_template import BaseNameTemplate
13
10
  from liminal.base.properties.base_schema_properties import BaseSchemaProperties
@@ -24,6 +21,9 @@ from liminal.mappers import (
24
21
  convert_entity_type_to_api_entity_type,
25
22
  convert_field_type_to_api_field_type,
26
23
  )
24
+ from liminal.orm.name_template_parts import (
25
+ NameTemplatePart,
26
+ )
27
27
  from liminal.orm.schema_properties import MixtureSchemaConfig
28
28
 
29
29
 
@@ -1,14 +1,5 @@
1
1
  # flake8: noqa: F401
2
2
  from liminal.base.base_operation import BaseOperation
3
- from liminal.base.name_template_parts import (
4
- CreationDatePart,
5
- CreationYearPart,
6
- FieldPart,
7
- ProjectPart,
8
- RegistryIdentifierNumberPart,
9
- SeparatorPart,
10
- TextPart,
11
- )
12
3
  from liminal.base.properties.base_field_properties import BaseFieldProperties
13
4
  from liminal.base.properties.base_name_template import BaseNameTemplate
14
5
  from liminal.base.properties.base_schema_properties import BaseSchemaProperties
@@ -42,3 +33,12 @@ from liminal.enums import (
42
33
  BenchlingNamingStrategy,
43
34
  BenchlingSequenceType,
44
35
  )
36
+ from liminal.orm.name_template_parts import (
37
+ CreationDatePart,
38
+ CreationYearPart,
39
+ FieldPart,
40
+ ProjectPart,
41
+ RegistryIdentifierNumberPart,
42
+ SeparatorPart,
43
+ TextPart,
44
+ )
@@ -12,11 +12,11 @@ from sqlalchemy.orm import Query, RelationshipProperty, Session, relationship
12
12
  from sqlalchemy.orm.decl_api import declared_attr
13
13
 
14
14
  from liminal.base.base_validation_filters import BaseValidatorFilters
15
- from liminal.base.name_template_parts import FieldPart
16
15
  from liminal.enums import BenchlingNamingStrategy
17
16
  from liminal.orm.base import Base
18
17
  from liminal.orm.base_tables.user import User
19
18
  from liminal.orm.name_template import NameTemplate
19
+ from liminal.orm.name_template_parts import FieldPart
20
20
  from liminal.orm.schema_properties import SchemaProperties
21
21
  from liminal.validation import BenchlingValidatorReport
22
22
 
@@ -4,8 +4,8 @@ from typing import Any
4
4
 
5
5
  from pydantic import ConfigDict, field_validator
6
6
 
7
- from liminal.base.name_template_parts import NameTemplateParts, SeparatorPart
8
7
  from liminal.base.properties.base_name_template import BaseNameTemplate
8
+ from liminal.orm.name_template_parts import NameTemplateParts, SeparatorPart
9
9
 
10
10
 
11
11
  class NameTemplate(BaseNameTemplate):
@@ -19,7 +19,7 @@ class NameTemplate(BaseNameTemplate):
19
19
  The list of name template parts that make up the name template (order matters). Defaults to no parts, an empty list.
20
20
  order_name_parts_by_sequence : bool = False
21
21
  Whether to order the name parts by sequence. This can only be set to True for sequence enity types. If one or many part link fields are included in the name template,
22
- list parts in the order they appear on the sequence map, sorted by start position and then end position.Defaults to False.
22
+ list parts in the order they appear on the sequence map, sorted by start position and then end position. Defaults to False.
23
23
  """
24
24
 
25
25
  parts: list[NameTemplateParts] = []
@@ -1,7 +1,6 @@
1
1
  import copy
2
2
  from unittest.mock import Mock, patch
3
3
 
4
- from liminal.base.name_template_parts import TextPart
5
4
  from liminal.base.properties.base_field_properties import BaseFieldProperties
6
5
  from liminal.entity_schemas.compare import compare_entity_schemas
7
6
  from liminal.entity_schemas.operations import (
@@ -18,6 +17,7 @@ from liminal.entity_schemas.operations import (
18
17
  )
19
18
  from liminal.enums import BenchlingFieldType
20
19
  from liminal.orm.name_template import NameTemplate
20
+ from liminal.orm.name_template_parts import TextPart
21
21
 
22
22
 
23
23
  class TestCompareEntitySchemas:
@@ -1,7 +1,7 @@
1
1
  import inspect
2
2
  from datetime import datetime
3
- from functools import wraps
4
- from typing import TYPE_CHECKING, Callable
3
+ from functools import partial, wraps
4
+ from typing import TYPE_CHECKING, Any, Callable
5
5
 
6
6
  from pydantic import BaseModel, ConfigDict
7
7
 
@@ -67,6 +67,7 @@ class BenchlingValidatorReport(BaseModel):
67
67
  entity: type["BenchlingBaseModel"],
68
68
  validator_name: str,
69
69
  message: str | None = None,
70
+ **kwargs: Any,
70
71
  ) -> "BenchlingValidatorReport":
71
72
  """Creates a BenchlingValidatorReport with the given parameters.
72
73
 
@@ -96,59 +97,68 @@ class BenchlingValidatorReport(BaseModel):
96
97
  creator_email=entity.creator.email if entity.creator else None,
97
98
  updated_date=entity.modified_at,
98
99
  message=message,
100
+ **kwargs,
99
101
  )
100
102
 
101
103
 
102
- def liminal_validator(
103
- validator_level: ValidationSeverity = ValidationSeverity.LOW,
104
- validator_name: str | None = None,
104
+ def _liminal_decorator(
105
+ func: Callable[[type["BenchlingBaseModel"]], BenchlingValidatorReport | None],
106
+ validator_level: ValidationSeverity,
107
+ validator_name: str | None,
105
108
  ) -> Callable:
106
- """A decorator that validates a function that takes a Benchling entity as an argument and returns None.
107
-
108
- Parameters:
109
- validator_level: ValidationSeverity
110
- The level of the validator.
111
- validator_name: str | None
112
- The name of the validator. Defaults to the pascalized name of the function.
113
- """
114
-
115
- def decorator(func: Callable[[type["BenchlingBaseModel"]], None]) -> Callable:
116
- """Decorator that validates a function that takes a Benchling entity as an argument and returns None."""
117
- sig = inspect.signature(func)
118
- params = list(sig.parameters.values())
119
- if not params or params[0].name != "self" or len(params) > 1:
120
- raise TypeError(
121
- "Validator must defined in a schema class, where the only argument to this validator must be 'self'."
122
- )
109
+ """Core decorator logic for liminal_validator."""
110
+ sig = inspect.signature(func)
111
+ params = list(sig.parameters.values())
112
+ if not params or params[0].name != "self" or len(params) > 1:
113
+ raise TypeError(
114
+ "Validator must be defined in a schema class, where the only argument to this validator must be 'self'."
115
+ )
123
116
 
124
- if sig.return_annotation is not None:
125
- raise TypeError("The return type must be None.")
126
-
127
- nonlocal validator_name
128
- if validator_name is None:
129
- validator_name = pascalize(func.__name__)
130
-
131
- @wraps(func)
132
- def wrapper(self: type["BenchlingBaseModel"]) -> BenchlingValidatorReport:
133
- """Wrapper that runs the validator function and returns a BenchlingValidatorReport."""
134
- try:
135
- func(self)
136
- except Exception as e:
137
- return BenchlingValidatorReport.create_validation_report(
138
- valid=False,
139
- level=validator_level,
140
- entity=self,
141
- validator_name=validator_name,
142
- message=str(e),
143
- )
117
+ if validator_name is None:
118
+ validator_name = pascalize(func.__name__)
119
+
120
+ @wraps(func)
121
+ def wrapper(self: type["BenchlingBaseModel"]) -> BenchlingValidatorReport:
122
+ """Wrapper that runs the validator function and returns a BenchlingValidatorReport."""
123
+ try:
124
+ ret_val = func(self)
125
+ if type(ret_val) is BenchlingValidatorReport:
126
+ return ret_val
127
+ except Exception as e:
144
128
  return BenchlingValidatorReport.create_validation_report(
145
- valid=True,
129
+ valid=False,
146
130
  level=validator_level,
147
131
  entity=self,
148
132
  validator_name=validator_name,
133
+ message=str(e),
149
134
  )
135
+ return BenchlingValidatorReport.create_validation_report(
136
+ valid=True,
137
+ level=validator_level,
138
+ entity=self,
139
+ validator_name=validator_name,
140
+ )
141
+
142
+ setattr(wrapper, "_is_liminal_validator", True)
143
+ return wrapper
150
144
 
151
- setattr(wrapper, "_is_liminal_validator", True)
152
- return wrapper
153
145
 
154
- return decorator
146
+ def liminal_validator(
147
+ validator_level: ValidationSeverity = ValidationSeverity.LOW,
148
+ validator_name: str | None = None,
149
+ ) -> Callable:
150
+ """A decorator for a function that validates a Benchling entity, defined on a schema class.
151
+ Wraps around any exceptions raised by the validator function, and returns a BenchlingValidatorReport.
152
+
153
+ Parameters
154
+ ----------
155
+ validator_level: ValidationSeverity
156
+ The severity level of the validation report. Defaults to ValidationSeverity.LOW.
157
+ validator_name: str | None =
158
+ The name of the validator. Defaults to the PascalCase version of the function name.
159
+ """
160
+ return partial(
161
+ _liminal_decorator,
162
+ validator_level=validator_level,
163
+ validator_name=validator_name,
164
+ )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "liminal-orm"
3
- version = "2.0.0"
3
+ version = "2.0.2"
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"
File without changes