Skip to content

Commit

Permalink
patch for fieldsets (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndamania00 authored Dec 13, 2024
1 parent 4b29247 commit 13bf1d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions liminal/connection/benchling_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class BenchlingConnection(BaseModel):
warehouse_access: bool = False
Whether your Benchling tenant has access to the warehouse. If warehouse_connection_string is provided, this will default to True.
warehouse_access is required to set a custom warehouse names on entity schemas and their fields.
fieldsets: bool = False
Whether your Benchling tenant has access to fieldsets.
"""

tenant_name: str
Expand All @@ -41,6 +43,7 @@ class BenchlingConnection(BaseModel):
internal_api_admin_email: str | None = None
internal_api_admin_password: str | None = None
warehouse_access: bool = False
fieldsets: bool = False

@model_validator(mode="before")
@classmethod
Expand Down
16 changes: 10 additions & 6 deletions liminal/entity_schemas/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def _validate_create(self, benchling_service: BenchlingService) -> None:
raise ValueError(
f"Entity schema warehouse name {self._validated_schema_properties.warehouse_name} already exists in Benchling."
)
if self._validated_schema_properties.prefix in [
schema["prefix"] for schema in all_schemas
]:
if (
not benchling_service.connection.fieldsets
and self._validated_schema_properties.prefix
in [schema["prefix"] for schema in all_schemas]
):
raise ValueError(
f"Entity schema prefix {self._validated_schema_properties.prefix} already exists in Benchling."
)
Expand Down Expand Up @@ -235,9 +237,11 @@ def _validate(self, benchling_service: BenchlingService) -> TagSchemaModel:
raise ValueError(
f"Entity schema warehouse name {self.update_props.warehouse_name} already exists in Benchling."
)
if self.update_props.prefix and self.update_props.prefix in [
schema["prefix"] for schema in all_schemas
]:
if (
not benchling_service.connection.fieldsets
and self.update_props.prefix
and self.update_props.prefix in [schema["prefix"] for schema in all_schemas]
):
raise ValueError(
f"Entity schema prefix {self.update_props.prefix} already exists in Benchling."
)
Expand Down

0 comments on commit 13bf1d6

Please sign in to comment.