C3 Week 2 Assignment Exercise 2 taking forever to run tests

Hello NLP community!

My lab cell in this exercise is taking forever to run “Try out your data generator” cell and tests until kernel breaks and is restarted. I’m not able to proceed further in the lab because of this issue.

Please help. :wink:

Hi @Raul,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.


1 Like

Thanks @Mubsi! :nerd_face:

here is my lab id: rankgfka

Hi @Raul,

Just in case this might be useful to you:
At some point I had a pretty dumb mistake inside my data generator - I was using “lines” instead of “data_lines” , and that lead to a behavior similar to what you were experiencing !


1 Like

Thanks for your contribution, @ioanaileana. Do you mean this chunk of code in the data generator?
my code is:

# get a line at the `lines_index[index]` position in data_lines
        line = data_lines[lines_index[index]]
        # if the length of the line is less than max_length
        if len(line) < max_length:
            # append the line to the current batch

Re @Raul, that chunk indeed; obviously you do not have the same error, however did you check (w some prints) if your current batch size properly increases to reach the desired batch size? My error lead to the batch never growing to the proper size, thus nothing was yielded by the method !


@Mubsi & @ioanaileana:

I did some debugging by myself and detected a minor mistake I did, which I can now run everything smoothly. It was in this part of the code, for others to check in the future:
before (I was comparing a list with an int): :nerd_face:

      # if the current batch is now equal to the desired batch size
        if cur_batch == batch_size:

corrected (using len()):

      # if the current batch is now equal to the desired batch size
        if len(cur_batch) == batch_size:

Anyways, thank you for your willingness to help me! :partying_face:


@Raul @ioanaileana , The comment above that line is really misleading…

Hi Folks:

I am having similar problems. I have implemented all the recommendations. I have placed a pdb.set_trace() : it is not reached. It does not seem my ‘test generator’ works.

My lab id is phpssgbp


This is incorrect: if i >= len(data_lines):
Make use of index.

1 Like

Hi @balaji.ambresh:

Thanks for the help! I changed the line to

if len(line) < max_length:

and corrected some other obvious errors.

I am having different problems but let me see if I can figure them out before asking for help.