Skip to main content
Practitioner ⭐️⭐️⭐️
January 5, 2024

Set parameter 'name' as required (as required in UI) for DataModelApply in cognite-sdk

  • January 5, 2024
  • 3 replies
  • 66 views

1. Field ‘name’ is required during creating data model in CDF.  But it is not required if create through SDK:

data_models = [DataModelApply(space="mySpace",external_id="myDataModel",version="v1")] c.data_modeling.data_models.apply(data_models)

 

2.  For data models have values in ‘name’ and ‘description’ fields these fields would be cleared up if these parameters are not specified in DataModelApply. 

These code will clear name and description values (if ‘myDataModel’ had them):

data_models = [DataModelApply(space="mySpace",external_id="myDataModel",version="v1")] c.data_modeling.data_models.apply(data_models)

These code won’t clear name and description values (if ‘myDataModel’ had them):

data_models = [DataModelApply(space="mySpace",external_id="myDataModel",version="v1", name=”myDataModel”, description=”My Description”)]

c.data_modeling.data_models.apply(data_models)

To fix make changes in cognite-sdk:

  1. Set ‘name’ as required for DataModelApply.
  2. Fix clearing values from name and description in DataModelApply when these parameters are not specified.

3 replies

Lead Product Manager
February 13, 2024

Hi @almir.mavliutov and apologies for the late reply. I didn’t realize we hadn’t posted a follow up to you!

I’ve cross-posted your content as an issue (bug) in the public Cognite Python SDK repository.

Lead Product Manager
February 13, 2024

If you’re comfortable with Python, you _can_ also submit a fix directly, as a pull request, in the GitHub repository.

Anders  Albert
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
April 12, 2024

Hi Amir, thanks for your report and suggestions.

 

  1. Name is not a required field for data models, if you check the API specs, you can see that only space, external_id and version are required when creating a new data model.
  2. I cannot recreate what you are reporting here. If you have a data model, set the description and name these will be updated, including if you set them to None.

I will thus close the issue above.