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

bugfix: fix bug for mkdir command #231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bryantanwz
Copy link

In Tutorial 6, the following error message occurs when trying to run the tutorial more than once:

Cell In[10], line 14
11 index = femr.index.PatientIndex(dataset, num_proc=4)
12 main_split = femr.splits.generate_hash_split(index.get_patient_ids(), 97, frac_test=0.15)
---> 14 os.mkdir(os.path.join(TARGET_DIR, 'motor_model'))
15 # Note that we want to save this to the target directory since this is important information
17 main_split.save_to_csv(os.path.join(TARGET_DIR, "motor_model", "main_split.csv"))

FileExistsError: [Errno 17] File exists: 'trash/tutorial_6/motor_model'

The error occurs because the directory 'trash/tutorial_6/motor_model' already exists when the code tries to create it. To fix this, use os.makedirs() instead of os.mkdir() with a exist_ok=True parameter so a FileExistsError is not raised if the directory already exists. This allows for the tutorial code to be run more than once.

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.

1 participant