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.
stchris
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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 :).