Skip to main content
Solved

Could not find data model


Forum|alt.badge.img+2

Hi,

I have a datamodel in CDF and I want to run a GraphQL query through the SDK to retrieve specific data from the model. When I try to run 

response = client.data_modeling.graphql.query(
    id = ('sp_watercourse_data_model', 'Watercourse', 'v1'),
    query = query
    )

I receive the following error message:

CogniteGraphQLError: [GraphQLErrorSpec(message=Could not find data model with space=sp_watercourse_data_model, externalId=Watercourse and version=v1, locations=[], extensions={'classification': 'DataFetchingException'})]

However, when I list my models using

models = client.data_modeling.data_models.list(limit=100).to_pandas()

the model is in the dataframe as expected.

 

What causes this problem and how can I fix it?

 

thanks

Best answer by Mithila Jayalath

@Jørgen Aarstad can you please check whether the version of the data model is v1 or 1?

Try again using the below code and let me know whether you are able to run it?

response = client.data_modeling.graphql.query(
    id = ('sp_watercourse_data_model', 'Watercourse', '1'),
    query = query
    )

 

View original
Did this topic help you find an answer to your question?

5 replies

Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@Jørgen Aarstad can you please let me know the SDK version that you are currenly using? Have you checked whether data_modeling.graphql.query is working for other models?


Forum|alt.badge.img+2

I’m using v7.73.6. It doesn’t work for any other models, either


Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

I tried from my end with the SDK version 7.73.6. It worked as expected. I was not able to reproduce the issue that you are observing. I’ll further investigate and get back to you with an update.


Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 394 replies
  • Answer
  • March 14, 2025

@Jørgen Aarstad can you please check whether the version of the data model is v1 or 1?

Try again using the below code and let me know whether you are able to run it?

response = client.data_modeling.graphql.query(
    id = ('sp_watercourse_data_model', 'Watercourse', '1'),
    query = query
    )

 


Arild  Eide
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 39 replies
  • March 14, 2025

@Jørgen Aarstad I also tested this function now and had no isuses.

When you define the data model to query against, the tuple is (space, external_id, version) of the model, can you please verify that the middle parameter is the external_id and not the name of the data model? This are often similar but still not equal.

If you still experience problems there is a debug flag in the SDK (doc) that will print the API request. From this you can obtain the path and compare against against what you see in the query explorer in the Fusion UI.

 

Let us know how things go.

 

Regards,

Arild Eide

 


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