I was working through assignments for Context Engineering course. But i am getting python error in compiling the code for graded assignment in Module 2. It seems to be linkage issues -
NameError Traceback (most recent call last)
Cell In[4], line 3
1 from collections import Counter
----> 3 metas = COLLECTION.get(include=[“metadatas”])[“metadatas”]
4 print(“Total chunks:”, len(metas))
5 print(dict(Counter(m[“chunk_type”] for m in metas)))
NameError: name ‘COLLECTION’ is not defined
I restarted the kernel and reran all the blocks … but to no effect… Can you pls help me what am i missing here ?
Best Regards,
Rajat
First, as Tom suggested, please make sure you post your question in the appropriate course discussion area so that the relevant course team and other learners can also assist.
Regarding the error, NameError: name 'COLLECTION' is not defined means that Python cannot find a variable named COLLECTION in the current execution environment.
A couple of things to check:
Have you modified or overwritten any of the original code in the notebook? COLLECTION should be defined in one of the earlier cells. Make sure you have executed the cell that initializes it before running the cell that accesses it.
If you have accidentally modified the original notebook code, try restoring the original version. On the DeepLearning.AI platform, you can usually do this through the three-dot menu. On Coursera, look for the reset option under the question-mark menu (usually in the top-right corner).
Restarting the kernel and rerunning all cells will not resolve the issue if the initialization code is missing or has been modified.
I would suggest first restoring the original notebook and running the cells in sequence without modifying the provided code.
First, as Tom suggested, please make sure you post your question in the appropriate course discussion area so that the relevant course team and other learners can also assist.
Regarding the error, NameError: name 'COLLECTION' is not defined means that Python cannot find a variable named COLLECTION in the current execution environment.
A couple of things to check:
Have you modified or overwritten any of the original code in the notebook? COLLECTION should be defined in one of the earlier cells. Make sure you have executed the cell that initializes it before running the cell that accesses it.
If you have accidentally modified the original notebook code, try restoring the original version. On the DeepLearning.AI platform, you can usually do this through the three-dot menu. On Coursera, look for the reset option under the question-mark menu (usually in the top-right corner).
Restarting the kernel and rerunning all cells will not resolve the issue if the initialization code is missing or has been modified.
I would suggest first restoring the original notebook and running the cells in sequence without modifying the provided code.
Gent has given you some great pointers about what to look for. Another possible mistake is changing the type of the code cell that defines COLLECTION to be “Markdown” instead of “Code”. That would mean that it becomes non-executable. Use the search function (“^F”) to find all instances of COLLECTION in the notebook. Is there a cell that defines it? Are you sure that the cell type is “Code”? Click “Cell -> Cell Type” to see …
Of course getting a fresh copy, as Gent suggested, is a good way to fix that problem, but it’s also pretty easy to fix once you find the menu item I listed above.
Gent has given you some great pointers about what to look for. Another possible mistake is changing the type of the code cell that defines COLLECTION to be “Markdown” instead of “Code”. That would mean that it becomes non-executable. Use the search function (“^F”) to find all instances of COLLECTION in the notebook. Is there a cell that defines it? Are you sure that the cell type is “Code”? Click “Cell -> Cell Type” to see …
Of course getting a fresh copy, as Gent suggested, is a good way to fix that problem, but it’s also pretty easy to fix once you find the menu item I listed above.