I have a question about the ‘root_path’ parameter in C2 W1.
The only comment to go on is from the comment in the assignment script:
"# HINT:
Use os.makedirs to create your directories with intermediate subdirectories
Don’t hardcode the paths. Use os.path.join to append the new directories to the root_path parameter"
I submitted my assignment and received the following feedback:
"Details of failed tests for create_train_test_dirs
Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
name ‘root_dir’ is not defined."
In my script, ‘root_dir’ is definately defined (at the top of the section):
root_dir = ‘/tmp/cats-v-dogs’
I had thought, based on the comment in the assignment template, that I needed to “append the new directories to the root_path parameter” So, I created it as follows:
root_path = training_dir + “;” + testing_dir + “;” +
training_cats_dir + “;” + training_dogs_dir + “;” +
testing_cats_dir + “;” + testing_dogs_dir
So, I noticed the exact same code is required for W2 assignment, so, I’ll like to know how to correct the problem.
If I am not wrong you have defined root_dir as a global variable
This has been fixed in newer version of the assignment
Please switch to the latest one and try your code out
If the error still persists,let me know
Thanks
Kind Regards,
Mayank Ghogale
Thank you for your help. The root_dir = ‘/tmp/cats-v-dogs’ was already part of the assignment template. I didn’t change it.
I didn’t get an error. It was simply that I lost marks and don’t know why.
I wouldn’t mind losing marks, however, I don’t want to lose marks again for the same code in Week 2 assignment, when I don’t know how to correct it.
Oh! If thats what the issue is I can push this to my fellow mentors and also to the git issue if needed
Please give me sometime and I shall get back to you
Thanks
Please use root_path instead of root_dir.
Function parameters should be preferred over global variables when possible.
The grader could clear global state or grab just the function code before grading. This would make global variables undefined.