Hi,
In the course “match entities with python sdk ” https://learn.cognite.com/match-entities-with-python-sdk, when running the notebook, I can modify it to connect to Cognite using the same credentials as in the “Learn to Use the Cognite Python SDK” course.
When I get to cell 5, I get this error:
“””
TypeError: DataSet.__init__() missing 5 required positional arguments: 'id', 'created_time', 'last_updated_time', 'description', and 'metadata'
“””
This is what is in cell 5:
# Create datasets
try:
bra_dataset = client.data_sets.create(DataSet(external_id="BRA_TestData", name='TestDataset', write_protected=True))
except CogniteDuplicatedError as e:
print("BRA_TestData already exists, you can continue")
bra_dataset = client.data_sets.retrieve(external_id="BRA_TestData")
try:
nor_dataset = client.data_sets.create(DataSet(external_id="NOR_TestData", name='TestDataset', write_protected=True))
except CogniteDuplicatedError as e:
print("NOR_TestData already exists, you can continue")
nor_dataset = client.data_sets.retrieve(external_id="NOR_TestData")
assert isinstance(nor_dataset, DataSet )
assert isinstance(bra_dataset, DataSet )It seems to be having the issue becasue “DataSet” in line 3 is for reading, not writing.
To get it to work, I needed to:
1. Add this to the cell:
from cognite.client.data_classes import DataSet, DataSetWrite
from cognite.client.exceptions import CogniteDuplicatedError- Change both instances of: “.create(DataSet(external_id="BRA_TestData"” to “.create(DataSetWrite(external_id="BRA_TestData"”
Check the
documentation
Ask the
Community
Take a look
at
Academy
Cognite
Status
Page
Contact
Cognite Support
