Create nested associations in emodel and campaigns#545
Create nested associations in emodel and campaigns#545GianlucaFicarelli merged 2 commits intomainfrom
Conversation
| """Callable that should accept parent_id and child_id and return a valid db model instance.""" | ||
|
|
||
| def __call__(self, *, left_id: uuid.UUID, right_id: uuid.UUID) -> DeclarativeBase: ... | ||
| def __call__(self, *, parent_id: uuid.UUID, child_id: uuid.UUID) -> DeclarativeBase: ... |
There was a problem hiding this comment.
I renamed left_id to parent_id and right_id to child_id because it seems easier to understand what are the relationships: parent refers to the main entity, and child refer to one of the many children.
Please let me know if you find it clear enough.
There was a problem hiding this comment.
Yeah, I think it is more intuitive this way
| TaskConfig: { | ||
| "inputs": { | ||
| "relationship_name": "inputs", | ||
| "db_model_factory": lambda *, parent_id, child_id: TaskConfigToEntity( |
There was a problem hiding this comment.
In the name of the association table TaskConfigToEntity, the order of the entities is inverted compared to the other association tables below:
IonChannelModelToEModelIonChannelRecordingToIonChannelModelingCampaignEmCellMeshToSkeletonizationCampaign
I'm considering to rename TaskConfigToEntity to EntityToTaskConfig to use the same naming convention.
It requires a new schema migration, but the table isn't used yet.
Thoughts?
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This PR allows to create or update nested associations:
Note:
If needed, we can create a separate PR to allow:
See https://github.com/openbraininstitute/prod-human-data-and-models/issues/15#issuecomment-3983670537 and the following comments.