Skip to main content
Solved

Python Code


Forum|alt.badge.img+7

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

Best answer by Sofie Haug

@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. 

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

13 replies

Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 8, 2024

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


Forum|alt.badge.img+7

Hi Sofie,

Thanks for replying back, I am getting this error message

 


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 8, 2024

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. 


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 8, 2024

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. 


Forum|alt.badge.img+7

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


Forum|alt.badge.img+7

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?


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 9, 2024

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


Forum|alt.badge.img+7

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.

 


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • Answer
  • April 9, 2024

@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. 


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 9, 2024

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. 


Forum|alt.badge.img+7

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.


Forum|alt.badge.img+7

Sofie, Have you send any notebook to me?

If yes, I am not able to find that!


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 10, 2024

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


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