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

PCB: better logging for demo collection #28

Merged
merged 4 commits into from
Feb 21, 2024

Conversation

gautams3
Copy link
Contributor

No description provided.

with open(file_name, "wb") as f:
pkl.dump(transitions, f)
print(f"saved {success_needed} demos to {file_name}")
file_name = f"./pcb_insert_{success_needed}_demos_{uuid}.pkl"
Copy link
Member

Choose a reason for hiding this comment

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

Is it easier if we check the dir exists beforehand? else create the dir if it doesnt exist. something like

    if os.path.exists(DATA_DIRECTORY):
        shutil.rmtree(DATA_DIRECTORY)
    os.makedirs(DATA_DIRECTORY)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. We need to check if the dir exists, and whether we have write permission to that dir. We can start recording only after this check completes. Is that a preferable solution?

Also, I don't think we should do an shutil.rmtree on any users machine. The user might be storing demo files in the same directory as other code or files.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, just create the dir is suffice and maybe check the write permission too.

ahh yes, you are right, we shouldnt do rmtree, I copied this code snippet from another codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this logic

Copy link
Member

@youliangtan youliangtan left a comment

Choose a reason for hiding this comment

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

Thanks for the changes

@youliangtan youliangtan merged commit 85ed9be into rail-berkeley:main Feb 21, 2024
1 check passed
@gautams3 gautams3 deleted the record_demo_fallback branch February 21, 2024 22:50
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.

2 participants