Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEAT-28] Extend DMS rules to lists #272

Merged
merged 6 commits into from
Feb 26, 2024
Merged

[NEAT-28] Extend DMS rules to lists #272

merged 6 commits into from
Feb 26, 2024

Conversation

doctrino
Copy link
Collaborator

@doctrino doctrino commented Feb 24, 2024

Three changes to better cover all DMS possibilities:

  1. The ValueType of the DMS rules sheet is now parsed as a ViewEntity if the relation column is set. This means we now support referring to views which are in a different space than the default set in the metadata sheet, and an arbitrary version.

The next are more esoteric, less important, but gives us a better cover of DMS rules

  1. A property can now be used in multiple indexes.
  2. A property can now be part om multiple uniqueness constraints.
  3. A container can have a required constraint on multiple other containers.

index: StrListType | None = Field(None, alias="Index")
constraint: StrListType | None = Field(None, alias="Constraint")

@field_validator("value_type", mode="before")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could not fit under _types.py ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is only used here, which is why I do not put it into the types.

return ViewEntity.from_raw(value)
return value

@field_serializer("value_type", when_used="unless-none")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same argument



class DMSContainer(SheetEntity):
class_: str | None = Field(None, alias="Class")
container: ContainerType = Field(alias="Container")
description: str | None = Field(None, alias="Description")
constraint: ContainerType | None = Field(None, alias="Constraint")
constraint: ContainerListType | None = Field(None, alias="Constraint")

def as_container(self, default_space: str) -> dm.ContainerApply:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@@ -50,7 +51,7 @@ def rules_schema_tests_cases() -> Iterable[ParameterSet]:
DMSProperty(
class_="WindFarm",
property_="WindTurbines",
value_type="WindTurbine",
value_type=ViewEntity(suffix="WindTurbine"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a before validation that auto-create ViewEntity if only string is passed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@doctrino doctrino merged commit 7eaf6e3 into main Feb 26, 2024
6 checks passed
@doctrino doctrino deleted the dms-complete branch February 26, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants