-
Notifications
You must be signed in to change notification settings - Fork 27
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
♻️Ensure parent project/node is well structured in the DB 🗃️ #5874
♻️Ensure parent project/node is well structured in the DB 🗃️ #5874
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5874 +/- ##
=========================================
+ Coverage 84.5% 87.7% +3.2%
=========================================
Files 10 1398 +1388
Lines 214 57580 +57366
Branches 25 1330 +1305
=========================================
+ Hits 181 50554 +50373
- Misses 23 6743 +6720
- Partials 10 283 +273
Flags with carried forward coverage won't be shown. Click here to find out more.
|
...src/simcore_postgres_database/migration/versions/a457d9974674_add_optional_parent_node_id.py
Outdated
Show resolved
Hide resolved
packages/postgres-database/src/simcore_postgres_database/utils_projects_nodes.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, thanks! Let's just discuss the project_node_id. I think then you would not need to deal with the ProjectNodesNonUniqueNodeFoundError case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx.
This PR extends projects_metadata
tables with structured metadata parent_project_uuid
and parent_node_id
.
Some of these values where already injected as custom metadata by S4L and compatibilyt for that case is supported.
I wonder whether this parenthood relation might also be used to map a study_id with its job_id in the new study resource in the api-server ...
packages/postgres-database/src/simcore_postgres_database/models/projects_metadata.py
Outdated
Show resolved
Hide resolved
packages/postgres-database/src/simcore_postgres_database/models/projects_metadata.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_metadata_api.py
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_metadata_db.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_metadata_db.py
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_metadata_db.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, I have some questions, since I could not figure out a few things.
packages/postgres-database/src/simcore_postgres_database/models/projects_metadata.py
Outdated
Show resolved
Hide resolved
packages/postgres-database/src/simcore_postgres_database/models/projects_metadata.py
Outdated
Show resolved
Hide resolved
packages/postgres-database/src/simcore_postgres_database/utils_projects_nodes.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_metadata_db.py
Outdated
Show resolved
Hide resolved
services/web/server/tests/unit/with_dbs/02/test_projects_metadata_handlers.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool. Thanks 🚀
I am wondering if it would make sense to put this new data into a new table because I think we will want to store much more of this type of relational data soon. But can of course also be handled later.
packages/postgres-database/src/simcore_postgres_database/models/projects_metadata.py
Show resolved
Hide resolved
packages/postgres-database/src/simcore_postgres_database/models/projects_metadata.py
Outdated
Show resolved
Hide resolved
🚨 Q: @sanderegg @bisgaard-itis @pcrespov |
services/web/server/src/simcore_service_webserver/projects/_metadata_handlers.py
Outdated
Show resolved
Hide resolved
Couldn't this be resolved by following the |
Yes, for frontend listing, filtering, and CSV export, this operation needs to be fast. Also, I cannot imagine what the query would look like, you would need to have some kind of loop with a lot of joining, which is already a red flag for me. Basically, we need to keep the |
What I imagine is something like the following: You first extract the projects which are "root projects" (meaning projects which don't have parents I guess). And then in a loop you look for their children, grandchildren, grandgrandchildren etc. So I guess the question is if that loop would be on the server or in the client. If the loop is on the client side, then the individual queries to the db would be quite fast I think 🤔 (getting all children of a given |
Not sure whether we are on the same page. I am talking about this view: I would propose for example having it as additional column in the
We will just ask for root parent project id of a parent project id when inserting a new row into this table and that's it. Lets discuss this @sanderegg. Thanks. |
for completeness of the discussion, I agreed to add the root project ID/root project Node ID |
Sounds good to me. Thanks |
77cd689
to
0047e64
Compare
c8d096a
to
b507a77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment I noticed when propagating these changes to the api-server
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some minor things
What do these changes do?
This is the first part toward structuring node parenting.
Context
In Sim4life.io currently the API client PATCHES the created computational jobs with some free form JSON metadata. Among these is a
node_id
field which contains the parent Node (e.g. the node where s4l is running). The DV-2 uses that information to define the parent project/node by looking for the presence of that field. This is currently not defined anywhere and could break very easily.Goal
Bring structure to this parenting, and allow other products to use this as easy as possible.
Idea
The oSparc API client shall automagically find out when it is running from an oSparc node by checking for some pre-defined ENV variables. For other free form API client, the usage relies on the respective authors responsibility (e.g. sim4life).
Constraint
Keep backward compatibility
Changes
POST /projects
now accept a couple of headers:X-Simcore-Parent-Project-Uuid
which optionally contains the parent project UUIDX-Simcore-Parent-Node-Id
which optionally contains the parent node IDprojects_metadata
table and used as beforenull
then nothing happensPATCH /projects/{uuid}/metadata
is called with custom_metadata containing a node_id field:The next steps will be re-arranging the DV-2 to directly get the information regarding parent project/node from the DB instead of extracting the information from the metadata, and taking care of the oSparc client (@bisgaard-itis )
Related issue/s
How to test
Dev-ops checklist