Skip to content
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

Fix bug in delete_nodes when passing pks of non-existing nodes #2440

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Feb 1, 2019

Fixes #2439

The aiida.manage.database.delete.nodes.delete_nodes function was not
checking whether the pks that were passed correspond to existing nodes
which would cause the line that fetches the repository folders, after
the graph traversal queries had been completed, to except. To fix this
we first verify that the passed pks exist and if not print a warning and
discard them.

@coveralls
Copy link

coveralls commented Feb 1, 2019

Coverage Status

Coverage increased (+0.02%) to 69.777% when pulling 802f5ba on sphuber:fix_2439_delete_nodes_not_existing into 4378d52 on aiidateam:provenance_redesign.

@sphuber sphuber force-pushed the fix_2439_delete_nodes_not_existing branch from eb8d826 to 1ecefe6 Compare February 8, 2019 08:09
@sphuber sphuber requested a review from giovannipizzi February 8, 2019 08:11
try:
load_node(pk)
except exceptions.NotExistent:
print('warning: node with pk<{}> does not exist, skipping'.format(pk))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use click.echo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't touch that part, but might as well, you are right

The `aiida.manage.database.delete.nodes.delete_nodes` function was not
checking whether the pks that were passed correspond to existing nodes
which would cause the line that fetches the repository folders, after
the graph traversal queries had been completed, to except. To fix this
we first verify that the passed pks exist and if not print a warning and
discard them.
@sphuber sphuber force-pushed the fix_2439_delete_nodes_not_existing branch from 1ecefe6 to 802f5ba Compare February 8, 2019 10:48
@sphuber
Copy link
Contributor Author

sphuber commented Feb 8, 2019

@giovannipizzi Changed print to use echo or echo_warning where applicable and also replaced input with click.confirm.

@sphuber sphuber merged commit bdb7983 into aiidateam:provenance_redesign Feb 8, 2019
@sphuber sphuber deleted the fix_2439_delete_nodes_not_existing branch February 8, 2019 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants