Skip to main content

Fixing UndefinedError: 'OneToOneConnectionField' object has no attribute 'data_class' When Using Pygen with NEAT-Generated Data Models


Andre Alves
MVP
Forum|alt.badge.img+13

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

  1. Open NEAT spreadsheet to the Data Model causing the issue.

  2. In the "Properties" tab, ensure that every row has a value filled in for the "Name" column.

  3. If any "Name" values are missing, fill them in with appropriate property identifiers.

  4. Recreate or update the data model with the corrected properties.

  5. Retry the generate_sdk_notebook command.

Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@Andre Alves great article! Is it fine with you if we move this article to the Knowledge Base → How-To Guides?


Andre Alves
MVP
Forum|alt.badge.img+13

yes, sure!


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings