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

Command-line tools for searching for and removing runs in bulk #169

Merged
merged 2 commits into from
Feb 1, 2022

Conversation

j-davies-astro
Copy link
Contributor

@j-davies-astro j-davies-astro commented Feb 1, 2022

Several months ago we discussed adding some extra command-line tools for searching for tangos runs, and deleting them if desired. Here they are!

This modification renames the original "grep-runs" command to "grep-run-ids" to better suit its function. The "grep-runs" command now returns the full details of each of the runs matching the given string, which may include SQL wildcards such as "%" and "_".

Finally, there is a new "grep-remove" command, which will delete any runs matching the specified string, which is very useful for deleting whole simulations and large batches of changes to the database. The command first lists all the runs that will be deleted and always asks for confirmation from the user, as this command could potentially be very destructive.

@j-davies-astro
Copy link
Contributor Author

I've just seen the new "delete halo properties" feature proposed by Andrew - I suppose this feature is a little degenerate than that. I think this feature is also useful, as "grep-remove" can also undo linking, adding trackers, and the addition of new simulations to the database.

for r, run in enumerate(matching_runs):
print('Removing run ',r+1,' of ',len(matching_runs))

run.halolinks.delete()
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be a copy/paste from rem_run -- I think they should both call a function so as not to duplicate code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It very much is a copy-paste, I will wrap it up in a function.

@apontzen
Copy link
Member

apontzen commented Feb 1, 2022

I've just seen the new "delete halo properties" feature proposed by Andrew - I suppose this feature is a little degenerate than that. I think this feature is also useful, as "grep-remove" can also undo linking, adding trackers, and the addition of new simulations to the database.

I agree it's fine to have both facilities even if there is a little overlap in possible use cases

@j-davies-astro
Copy link
Contributor Author

I wrapped the run removal code into a function and did some reordering of the functions so that all the "run removal" code was in one place.

@apontzen apontzen merged commit d634c66 into pynbody:master Feb 1, 2022
@j-davies-astro j-davies-astro deleted the grep_runs branch February 1, 2022 16:47
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.

None yet

2 participants