Problem Overview:
When generating a Python SDK notebook using pygen
with a NEAT-created data model, you might encounter the following error:
UndefinedError: 'cognite.pygen._core.models.fields.connections.OneToOneConnectionField object' has no attribute 'data_class'
Root Cause
This error typically occurs when one or more properties in your data model are missing the "Name" field in the NEAT spreadsheet under the "Properties" tab.
Although NEAT allows you to create and save a data model without filling in the property name, this leads to missing metadata when pygen
tries to generate code — specifically, it fails when trying to reference data_class
on an incomplete field definition.
When It Happens
You’ll see the error when calling:
pygen = generate_sdk_notebook(data_model_id, client)
✅ How to Fix It
-
Open NEAT spreadsheet to the Data Model causing the issue.
-
In the "Properties" tab, ensure that every row has a value filled in for the "Name" column.
-
If any "Name" values are missing, fill them in with appropriate property identifiers.
-
Recreate or update the data model with the corrected properties.
-
Retry the
generate_sdk_notebook
command.