2024 , this problem is back and data_dir is not the solution: TypeError("__init__() missing 2 required positional arguments: 'op' and 'message'",)

Im reposting this common error as all the other threads are closed, and simply adding data_dir (it was never missing, for me) is not the solution. After 20 grader fails, I find myself spending more time on the coursera grader fails than actually learning python and machine learning, so I am throwing in the towel and finding a better course, if it exists. Moderator, - please feedback to the course owner.

The fail:

Cell #3. Can’t compile the student’s code. Error: TypeError(“init() missing 2 required positional arguments: ‘op’ and ‘message’”,)

I have tried many many alternatives to the following code, and they all execute in jupyter but fail the grader:

according to the screenshot, where you mentioned filepath (first code line) was not required, rather the instruction before that code line mentions you to use

data_dir = filepath as the dataset is already downloaded in the lab environment you are working.

Regards
DP

i use data_dir = filepath in the argument for tfds.load() functions.
The filepath variable must first be defined. Otherwise, i would get this error:

However maybe the path is wrong? is it? The default is “~/tensorflow_datasets” apparently according to the commentd. But this doesnt work when i do not define this variable. So maybe that path does not exist.

can I know first those instructions were already given or it is you tried in different ways to read the dataset?

in both screenshot you seem to have different way.

so can you share a screenshot of how originally that cell looked.

If I follow that first # you were suppose to first recall data_dir = filepath and then use them in the train and val.

i have been able to comment out the file path line, and the code still runs as it remembers the locatino of downloaded data from previous runs. But i still get the failurein the grader:

Cell #3. Can’t compile the student’s code. Error: NameError(“name ‘filepath’ is not defined”,)

in that case clearout the kernel output restart and then run the cell.

but I wanted to see how does it when you open the assignment from classroom page. Seems like you have done editing and I cannot differentiate between course instructions or if you have commented out some of your tried code.

also confirm if you working in course provided environment

i only open it from here:

If i clear out the kernel, then i have to put back in a line such as:
filepath = f"{getcwd()}/data/tensorflow_datasets"

…in order to download the datasets again. i have had the datasets in various subfolders. Is there a particular one that they must be in, for the grader to work? The jupyter cell executes just fine as long as filepath is declared.

as per assignment the filepath code is already given and you were only suppose to write the train data and val data codes if you’re working in Coursera environment

yes i am working in the coursera environment. I am working in this URL

This is the coursera environment, right?
Thanks for your time on this :slightly_smiling_face:

i made

filepath = f"{getcwd()}/data"

and i get the original error:

Cell #3. Can’t compile the student’s code. Error: TypeError(“init() missing 2 required positional arguments: ‘op’ and ‘message’”,)

stick to this error :joy:

now please share screenshot of the complete error, or if the error you are mentioning is grader submission error, then share a screenshot of that, so we can further work upon.

Also send me the screenshot of code by personal DM of train_data and val_data

Sincerely I recommend you to get again a fresh copy first, then only write codes where it is ask to do so, then work upon. the type(init) op and message error usually means the initiation to the code given is throwing error. it can be also cell#3 doesn’t mean the cell you are looking the error into.

Also if you writing codes in vs code and then copy pasting in coursera environment, then that also could cause such issue.