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

Ability to clear results of some experiments #59

Open
gautams3 opened this issue Oct 19, 2020 · 1 comment
Open

Ability to clear results of some experiments #59

gautams3 opened this issue Oct 19, 2020 · 1 comment

Comments

@gautams3
Copy link

It would be good to have the ability to re-run certain experiments. I had an issue where some experiments stopped because of a bug in feature A.

I want to fix the bug rerun those experiments with A from scratch, but without deleting the whole folder that has results of experiments from feature B, C, D. They were unaffected by the bug so it doesn't make sense to clear their results and re-run them.

@gautams3
Copy link
Author

Here's a sample function to do it

import os, dill, shutil
from smallab.file_locations import get_experiment_save_directory

# del_name = expt folder name
def delete_results_from_bad_spec(del_name, bad_spec, bad_val):
    specs_to_delete = []
    for root, _, files in os.walk(get_experiment_save_directory(del_name)):
        for fname in files:
            if ".pkl" in fname:
                with open(os.path.join(root, fname), "rb") as f:
                    completed = dill.load(f)
                if completed["specification"][bad_spec] == bad_val:
                    print(f"{root}/{fname} has {bad_spec}={bad_val}. DELETE!")
                    specs_to_delete.append(root)
                    shutil.rmtree(root)
    print(specs_to_delete)
    print("Deleted specs above. make sure to remove these from completed.json")

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

No branches or pull requests

1 participant