Troubleshooting
This article helps you resolve issues you may meet using Cognite Functions.
Incorrect folder structure when deploying a function as a zip file
Cognite Functions expects handler.py
to be at the root of the zipped folder or at a path relative to the root as pointed to by the function_path
attribute.
The following errors occur when handler.py
isn't found at either of these locations.
Error messages:
When using the API to publish the function, you may see this error message in Cognite Data Fusion (CDF) if the function deployment fails:
No Python module found at location "handler.py" in zip-file.
If you use the Cognite SDK to publish the function, you may see this error message if the function deployment fails:
No file found at location.
This typically occurs when the root folder is zipped and not the folder content. Here's an example of a wrong folder structure:
func/
├── handler.py
└── requirements.txt
If you run the zip command outside the func/
folder, the folder structure becomes wrong.
# pwd: ~/tmp
> zip -r func.zip func/
adding: func/ (stored 0%)
adding: func/handler.py (stored 0%)
adding: func/requirements.txt (stored 0%)
The requirements.txt
must be at the root of the zip-file.
Solution:
cd
into the func
folder before you zip the contents:
# pwd: ~/tmp/func