-
Notifications
You must be signed in to change notification settings - Fork 7
Bugfix/no repeats in batch again #750
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
Conversation
| from citrine.resources.gemd_resource import GEMDResourceCollection | ||
| gemd_collection = GEMDResourceCollection(self.project_id, self.dataset_id, self.session) | ||
| return gemd_collection.register_all( | ||
| models, | ||
| dry_run=dry_run, | ||
| status_bar=status_bar, | ||
| include_nested=include_nested | ||
| ) |
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 DataConcepts register_all calls should route through GEMDResourceCollection / storables
| def register(self, model: DataConcepts, *, dry_run=False) -> DataConcepts: | ||
| """Register a data model object to the appropriate collection.""" | ||
| return self.gemd.register(model, dry_run=dry_run) | ||
| return self.gemd._collection_for(model).register(model, dry_run=dry_run) |
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 dataset register calls should route through the particular object
| def update(self, model: DataConcepts) -> DataConcepts: | ||
| """Update a data model object using the appropriate collection.""" | ||
| return self.gemd.update(model) | ||
| return self.gemd._collection_for(model).update(model) |
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 DataConcepts update calls should route through the particular collection.
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.
why?
| if isinstance(uid, DataConcepts): | ||
| collection = self.gemd._collection_for(uid) | ||
| else: | ||
| collection = self.gemd | ||
| return collection.delete(uid, dry_run=dry_run) |
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.
dataset.delete will route through the object route if we have a type, and through storables if not.
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.
why?
| def update(self, model: DataConcepts) -> DataConcepts: | ||
| """Update a data model object using the appropriate collection.""" | ||
| return self._collection_for(model).update(model) | ||
|
|
||
| def delete(self, uid: Union[UUID, str, LinkByUID, DataConcepts], *, dry_run=False): | ||
| """ | ||
| Delete a GEMD resource from the appropriate collection. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| uid: Union[UUID, str, LinkByUID, DataConcepts] | ||
| A representation of the resource to delete (Citrine id, LinkByUID, or the object) | ||
| dry_run: bool | ||
| Whether to actually delete the item or run a dry run of the delete operation. | ||
| Dry run is intended to be used for validation. Default: false | ||
|
|
||
| """ | ||
| model = self.get(uid) # Get full object for collection lookup | ||
| return self._collection_for(model).delete(model, dry_run=dry_run) | ||
|
|
||
| def register(self, model: DataConcepts, *, dry_run=False) -> DataConcepts: | ||
| """Register a GEMD object to the appropriate collection.""" | ||
| return self._collection_for(model).register(model, dry_run=dry_run) | ||
|
|
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.
These are now naturally dispatched through DataConcepts. You get a storables route iff you ask for it.
| # But they would have dispatched differently w/ just a uid | ||
| dataset.session.set_response(updated.dump()) | ||
| dataset.delete(updated.uid) | ||
| assert dataset.session.calls[-1].path.split("/")[-3] == basename(GEMDResourceCollection._path_template) | ||
|
|
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.
Test uid v. object branching. Not actually registered, so repeat delete isn't a problem.
| assert GEMDResourceCollection(collection.project_id, collection.dataset_id, collection.session)._get_path() \ | ||
| in session.calls[0].path |
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.
Even though you asked for material_run, it was a register_all so it dispatched to storables.
|
I can verify functionality against stage & dev, but I don't have tests against local-devkit configured. |
|
https://jenkins.corp.citrine.io/job/nextgen-ITs/27027/ |
djack
left a comment
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.
passes tests, improves the state of the world.
Citrine Python PR
Description
This restores the batching corrections from #747 and updates register_all calls to go to the storables route.
PR Type:
Adherence to team decisions