-
Notifications
You must be signed in to change notification settings - Fork 12
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
Delete entity method and cli #44
Conversation
Cases arise where we need to delete specific entities in a dataset. While the REST API supports it, this will make it a bit easier using CLI tools and AlephAPI class in code.
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.
Generally this looks fine to me, left some minor comments/questions.
@cli.command("delete-entity") | ||
@click.argument("entity_id", required=True) | ||
@click.pass_context | ||
def delete_entity(ctx, entity_id): |
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.
Perhaps here as well (if the above works)?
def delete_entity(ctx, entity_id): | |
def delete_entity(ctx, entity_id: int): |
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.
Same as before - this isn't an integer, but a string that is a hash. How would you recommend I annotate it?
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.
perhaps as str
, that's likely the best we can do here.
res = self.api.write_entity(collection_id, entity) | ||
assert res['id'] == 24 | ||
dres = self.api.delete_entity(eid) | ||
assert dres == {} |
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.
I'm not entirely sure what our DELETE
endpoint returns, but shouldn't we (for completeness sake) try to get the entity with the same ID and expect a 404?
296bc5a
to
6d6cc0a
Compare
Sorry @brrttwrks the commit signing thing I sent you was only for the last commit, I didn't pay attention and it seems like you had more of them. But perhaps if you squash all your commits after doing the work and then sign that it should work? |
I added a delete-entity method for the AlephAPI class and a corresponding cli command to support a needed operation we are facing not infrequenlty lately and also to learn to support alephclient/tools with a seemingly straight-forward example. Let's see how this goes :).