Solved

Python Code


Badge +3

Hi Team,

I am trying to do the Python SDK Transformations course and got stuck here when running the code, can you please help me what I am missing here?

 

Thanks,

Navyasri Indupalli

icon

Best answer by Sofie Haug 9 April 2024, 13:09

View original

13 replies

Userlevel 3
Badge +6

Hi @Navyasri Indupalli 

We would need some more info to be able to help. The entire error message (or at least the last lines of it) would be helpful

Badge +3

Hi Sofie,

Thanks for replying back, I am getting this error message

 

Userlevel 3
Badge +6

One thing I notice is that in one place you use “api” (in the scope) and in the CDF_CLUSTER you have westeurope-1. 

I will also need to take a closer look into this myself. 

Userlevel 3
Badge +6

I also see that you are trying to use the “publidata” cdf project, while the courses uses a different one. The client secret you generated in the course can only be used to access that specific project. 

Badge +3

Should I need to change the CDF_CLUSTER value, I have given that value from some of the discussions in the communtiy hub

Badge +3

credentials = OAuthClientCredentials(

    token_url=os.environ["COGNITE_TOKEN_URL"],

    client_id=os.environ["COGNITE_CLIENT_ID"],

    client_secret=os.environ["COGNITE_CLIENT_SECRET"],

    scopes=os.environ["COGNITE_TOKEN_SCOPES"],

 )

cnf = ClientConfig(

    client_name="my-special-client",

    project=os.environ["COGNITE_PROJECT"],

    base_url=os.environ["COGNITE_BASE_URL"],

    credentials=credentials,

    )

 

Can you suggest what values shoud be given in this piece of code for the particular variables?

Userlevel 3
Badge +6

If you do the Python SDK Transformations course I recommend using the notebook linked in the course, where you have already some authentications set up

Badge +3

I have used the notebook suggested in the course but they mentioned the same code where the variables are declared like this in that notebook.

 

Userlevel 3
Badge +6

@Navyasri Indupalli I see, the notebook you show a screenshot from now is for the Entity Matching course, while you wrote in your initial post that you were doing Python SDK Transformations. So when I checked the Python SDK Transformations notebook, it didn’t match with the code in your screenshots. But then I’ll take a look into the Entity Matching course. 

Userlevel 3
Badge +6

The Match Entities with Python SDK course is a demonstration and doesn’t have any hands-on to it. The notebook attached can be used, but you would need access to a cdf project (your own/ your company’s). We unfortunately don’t have an environment for this. 

Badge +3

Yes, Sofie.

I am also rechecking the course for the notebook and found another notebook, I am going through that notebook now. Will reach out again if I stuck anywhere.

Thanks for replying back to me patiently.

Badge +3

Sofie, Have you send any notebook to me?

If yes, I am not able to find that!

Userlevel 3
Badge +6

You find the link to the notebook here: https://learn.cognite.com/python-sdk-transformations/1469463
the link in the lesson takes you to a GitHub repository. You need to clone the repository. If you are unsure of how, please check this documentation from GitHub: https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository

Reply