Changes are grouped as follows:
Dependencyfor new hard requirements that you must make sure work with your project before upgradingDeprecatedfor methods/features that are still available, but will be removed in a future releaseRemovedfor methods/features that have been removed (and what to do now!)Function Signaturefor methods/functions with a change to its function signature, e.g. change in default valuesFunctionalityfor changes that are not backwards compatibleChangedfor changes that do not fall into any other categoryOptionalfor new, optional methods/features that you should be aware of - and could take advantage of
- httpx: The SDK now uses
httpxinstead ofrequestsfor HTTP operations. This is a new required dependency that enables the new async interface.
- Async Support: The SDK now provides full async support. The main client is now
AsyncCogniteClient, but the synchronousCogniteClientis still available for backward compatibility. An important implementation detail is that it just wrapsAsyncCogniteClient. - All helper/utility methods on data classes now have an async variant. A few examples: Class
Assethaschildrenand now alsochildren_async,subtreeandsubtree_async, classFunctionnow hascallandcall_async, classTimeSeriesnow haslatestandlatest_asyncetc. - Instantiating a client has gotten a tiny bit simpler, by allowing either
clusterorbase_urlto be passed. When passing cluster, it is expected to be on the form 'https://{cluster}.cognitedata.com' - The context manager
FileMultipartUploadSession, returned by a call to one of the Files API methods multipart_upload_contentormultipart_upload_content_session, now also supports async; you can enter withasync with, and upload parts usingawait upload_part_async`. - The SDK now ships with a new mock for the async client, namely
AsyncCogniteClientMock. Both it and the previousCogniteClientMockare greatly improved and provide better type safety, checking of call signatures and spec_set=True is now enforced for all APIs (even the mocked client itself), through the use ofcreate_autospecand bottom-up construction of nested APIs. - With the move to an async client, concurrency now works in Pyodide e.g. Jupyter-Lite in the browser. This also means that user interfaces like Streamlit won't freeze while resources from CDF are being fetched!
- Good to know: File upload speeds are now significantly faster on Windows after
requestsare gone!
- The generic
aggregatemethod on classic CDF APIs has been removed (Assets, Events, Sequences and Time Series). Use one of the more specificaggregate_count,aggregate_unique_values,aggregate_cardinality_values,aggregate_cardinality_properties, oraggregate_unique_propertiesinstead. - The generic
aggregatemethod on the Data Sets API and Files API has been replaced withaggregate_count. - The aggregation data class
CountAggregatehas been removed. Methods now return the count (int) directly. - The generic
filtermethod on classic CDF APIs has been removed (Assets, Events, Sequences and Time Series). Use the normallistmethod instead and pass filters asadvanved_filters=...instead. - The method
triggeron the Workflow Executions API has been removed. Useruninstead. - The method
createon the Workflow Triggers API has been removed. Useupsertinstead. - The method
get_triggerson the Workflow Triggers API has been removed. Uselistinstead. - The method
get_trigger_run_historyon the Workflow Triggers API has been removed. Uselist_runsinstead. - Data class
WorkflowTriggerCreatehas been removed. UseWorkflowTriggerUpsert. - The method
as_primitivemethod on the identifier data classWorkflowVersionIdhas been removed. Useas_tupleinstead. - The methods
insert,retrieve,retrieve_last_rowandretrieve_dataframeon the Sequence Data API no longer support the parametercolumn_external_ids. Usecolumnsinstead. - The
__iter__method has been removed from all APIs. Use__call__instead:for ts in client.time_series(). This makes it seamless to pass one or more parameters. - The helper methods on
client.iam,compare_capabilitiesandverify_capabilitiesno longer support theignore_allscope_meaningparameter. - The Templates API has been completely removed from the SDK (the API service has already been shut off)
- The separate beta
CogniteClienthas been removed. Note: APIs currently in alpha/beta are (already) implemented directly on the main client and throw warnings on use.
- System-managed, read-only properties for
CogniteFilein../cdm/v1.py,is_uploadedanduploaded_time, have been removed from theCogniteFileApplyclass. - The write class for classic time series,
TimeSeriesWriteno longer has the fieldinstance_id. All time series with instance ID must be created through the Data Modeling API, so this was confusing. - The write class for classic file,
FileMetadataWriteno longer has the fieldinstance_id. All files with instance ID must be created through the Data Modeling API, so this was confusing. - The method
load_yamlon the data classQueryhas been removed. Useloadinstead.
- Datapoints API method
retrieve_dataframe_in_tzhas been removed. Useretrieve,retrieve_arraysorretrieve_dataframeand specifytimezoneinstead. - All references to
legacy_nameon time series data classes and API have been removed. - Data class
DataPointSubscriptionCreatehas been removed. UseDataPointSubscriptionWrite.
- Attributes on all "read" data classes now have the correct type (typically no longer
Optional[...]), meaning type inference will be correct. If you try to instantiate these classes directly (you shouldn't - use the write versions instead!), you will see that all required parameters in the API response will also be required on the object. What is a read class? Any data class returned by the SDK from a call to the API to fetch a resource of some kind. - All (HTTP) responses from the SDK (returned by e.g.
client.postorclient.get) are now of typeCogniteHTTPResponse(fromcognite.client.response) instead of the specific type from the underlying http library to support future http-client changes. - Parameter
partitionshas been removed from all__call__methods except for the Raw Rows API (which has special handling for it). It was previosuly being ignored with the added side effect of ignoringchunk_sizestemming from a very early API design oversight. - The method
retrieveon the Workflow Versions API no longer acceptsworkflow_external_idandversionas separate arguments. Pass a single or a sequence ofWorkflowVersionId(tuples also accepted). - When loading a
ViewPropertyorViewPropertyApply, the resource dictionary must contain the"connectionType"key or an error is raised. - The specific exceptions
CogniteDuplicatedErrorandCogniteNotFoundErrorshould now always be used when appropriate (previously certain API endpoints always usedCogniteAPIError) ModelFailedExceptionhas changed name toCogniteModelFailedError.- For
class Transformation, which used to have an asyncrunmethod, this is now namedrun_asyncto unify the overall interface. The same applies to thecancelandjobsmethods for the same class, andupdateandwaitonTransformationJob. - ClientConfig:
max_workershas functionally been removed (just throws a warning). Concurrency is now controlled viaglobal_config.concurrency_settings. See the Settings documentation for details.timeout: default has been increased from 30 sec to 60 sec
- global_config:
- New setting
follow_redirectsthat controls whether or not to follow redirects. Defaults toFalse. - New setting
file_download_chunk_sizethat allows you to override the chunk size for streaming file downloads. Defaults toNone(auto). - New setting
file_upload_chunk_sizethat allows you to override the chunk size for streaming file uploads. proxieshave been replaced byproxyand follow httpx directly. See: Proxies - HTTPXmax_retry_backoff: default has been increased from 30 sec to 60 secmax_connection_pool_size: default has been reduced from 50 to 20
- New setting
- The default value for the
operatorparameter in theInstancesAPI.searchmethod has been changed toAND(which previously defaulted to 'OR' behavior). This change provides more precise search results by default, requiring all search terms to be present. If you need the previous behavior of matching any search term, explicitly passoperator='OR'. - All typed instance apply classes, e.g.
CogniteAssetApplyfromcognite.client.data_classes.data_modeling.cdm.v1(orextractor_extensions.v1) now work with patch updates (usingreplace=False). Previously, all unset fields would be dumped asNoneand thus cleared/nulled in the backend database. Now, any unset fields are not dumped and will not clear an existing value (unless used withreplace=True). - For users of the Data Modeling API method
sync, the data classes have been split from those used inquery. They can be recognized by simply appendingSyncto the end, e.g.QueryandQuerySync. Previously, these were used for both, but as these API endpoints continue to evolve, it makes sense to fine-tune the data classes to each - starting now. Examples:QuerySync,SelectSync,NodeResultSetExpressionSyncandEdgeResultSetExpressionSync. - When using
to_pandason a list of Data Modeling instances, the properties will be expanded by default (to separate columns). To get the old behaviour, passexpand_properties=False. - When using
to_pandason a list of Data Modeling instances, parametersexpand_metadataandmetadata_prefixare no longer silently ignored and will raise as unrecognized. - When using
geton a list of Data Modeling instances, the parameteridhas been removed. Useinstance_id(orexternal_idwhen there is no ambiguity on space).
- When using the Datapoints API to ingest datapoints through
insert_dataframe, the parametersexternal_id_headersandinstance_id_headershave been removed. The new logic infers the kind of identifier from the type of the column: an integer is an ID, a string is an external ID and a NodeId (or 2-tuple of space and ext.id) is an instance ID. This also means you can pass more than one type of time series identifier in the same pandas DataFrame. - Datapoints API method
retrieve_dataframeand allto_pandasmethods on datapoints-container-like objects now accept a new parameter:include_unit(bool). Time series using physical units viaunit_external_id, will end up as part of the pandas DataFrame columns (like aggregate info). - The
.columnsof the returned pandas DataFrame from both Datapoints API methodretrieve_dataframeand allto_pandasmethods on datapoints-container-like objects are now pandasMultiIndex, where each level corresponds to the: time series identifiers (always present), then the possible aggregate-, granularity-, status code- and unit information. Any level with no information is automatically dropped. This solves several practical problems in the past when the identifiers were always cast to string before e.g.|interpolationwas appended directly to it. This worked ok untilNodeIdappeared. Now, the identifiers are never cast. If you have anode_id, you can extract the time series directly from the dataframe:df[node_id]. If you fetch several aggregates, you can select one just as easily:df[node_id, "average"]. - When using the Datapoints API to request datapoints, passing dictionaries with individual settings is no longer supported. Pass raw identifiers (
str,int,NodeId) orDatapointsQuery. - When using the Datapoints API to ingest datapoints, empty containers no longer raise
ValueError, but short-circuit. - Passing
column_namesto the Datapoints API methodretrieve_dataframeor toto_pandason any datapoints-container-like instance is no longer supported. The resolving is now dynamic with the precedence order: instance ID, then external ID and lastly (internal) ID. - The
Datapointsclass was previously (mis)used for several different API endpoints with different response structures. Dedicated classes have been introduced:- retrieve_latest: Now returns
LatestDatapointorLatestDatapointListinstead ofDatapointsorDatapointsList.LatestDatapointhas scalar values:timestampisdatetime(notlist[int]),valueisfloat | str(not a list). Usehas_datapointproperty to check if a datapoint was returned (or justif dp: ...).# Before (v7) if dps := client.time_series.data.retrieve_latest(id=123): ts = dps[0].timestamp # int (ms) val = dps[0].value # After (v8) if dp := client.time_series.data.retrieve_latest(id=123): ts = dp.timestamp # datetime (UTC) val = dp.value
- TimeSeries.latest(): Now returns
LatestDatapointinstead ofDatapoint | None. - Synthetic datapoints queries: Now return
SyntheticDatapointsorSyntheticDatapointsListinstead ofDatapointsorDatapointsList. Theerrorfield only exists onSyntheticDatapoints(where it belongs). Useto_pandas(include_errors=True)onSyntheticDatapointsto include the error column. - Datapoint subscriptions:
DatapointsUpdate.upsertsis nowSubscriptionDatapointsinstead ofDatapoints.
- retrieve_latest: Now returns
Datapointsclass no longer has theerrorattribute (moved toSyntheticDatapoints).DatapointsandDatapointsArraynow requireidandis_step,is_stringandtype.- Removed
include_errorsparameter fromDatapoints.to_pandas(). This parameter only applies toSyntheticDatapoints.to_pandas(). - Iterating through a
DatapointsArrayis no longer supported. Access the numpy arrays directly and use vectorised operations instead. - Extending a
Datapointsinstance is no longer supported.
- Accessing the Sequence Data API through the Sequence API should use
.datainstead of.rows. This may raise in a future version.
CogniteResource.to_pandasandCogniteResourceList.to_pandasnow converts known timestamps todatetimeby default. Can be turned off with the new parameterconvert_timestamps. Note: To comply with older pandas v1, the dtype will always bedatetime64[ns], although in v2 this could have beendatetime64[ms].- Read operations, like
retrieve_multiplewill now fast-fail. Previously, all requests would be executed before the error was raised, potentially fetching thousands of unneccesary resources.
- The Templates API is deprecated, and will be removed in a future version. Please migrate to Data Modeling. Read more at: https://docs.cognite.com/cdf/data_modeling/
- The
client.assets.aggregateuseclient.assets.aggregate_countinstead. - The
client.events.aggregateuseclient.events.aggregate_countinstead. - The
client.sequence.aggregateuseclient.sequence.aggregate_countinstead. - The
client.time_series.aggregateuseclient.time_series.aggregate_countinstead.
- Deprecated method
aggregate_metadata_keyson AssetsAPI. Update your query fromaggregate_metadata_keys(filter=my_filter)toaggregate_unique_properties("metadata", filter=my_filter). - Deprecated method
aggregate_metadata_valueson AssetsAPI. Update your query fromaggregate_metadata_values(keys=["country"], filter=my_filter)toaggregate_unique_values(["metadata", "country"], filter=my_filter). - Deprecated method
update_feature_typeson GeospatialAPI, usepatch_feature_typesinstead. - The
SequenceColumnsno longer set theexternal_idtocolumn{no}if it is missing. It now must be set explicitly by the user. - Dataclasses
ViewDirectRelationandContainerDirectRelationare replaced byDirectRelation. - Dataclasses
MappedPropertyDefinitionandMappedApplyPropertyDefinitionare replaced byMappedPropertyandMappedPropertyApply. - Dataclasses
RequiresConstraintDefinitionandUniquenessConstraintDefinitionare replaced byRequiresConstraintandUniquenessConstraint. - In data class
Transformationattributeshas_source_oidc_credentialsandhas_destination_oidc_credentialsare replaced by properties.
- All
.dumpmethods for CogniteResource classes likeAssetorEventnow usescamel_case=Trueby default. This is to match the intended use case, preparing the object to be sent in an API request. CogniteResource.to_pandasnow more closely resemblesCogniteResourceList.to_pandaswith parametersexpand_metadataandmetadata_prefix, instead of accepting a sequence of column names (expand) to expand, with no easy way to add a prefix. Also, it no longer expands metadata by default.- Additionally,
Asset.to_pandas, haveexpand_aggregatesandaggregates_prefix. Since the possibleaggregateskeys are known,camel_casewill also apply to these if expanded as opposed to metadata keys. - Removed parameters
propertyandaggregatesfor methodaggregate_unique_valueson GeospatialAPI, use theoutputparameter instead. - Removed parameter
fieldsfor methodaggregate_unique_valueson EventsAPI, use the other aggregate-prefixed methods instead. - Removed parameter
function_external_idfor methodcreateon FunctionSchedulesAPI (function_id has been required since the deprecation of API keys). client.data_modeling.instances.aggregatethe parametersinstance_typeandgroup_byhas swapped order.- The return type of
client.data_modeling.instances.aggregatehas changed fromInstanceAggregationResultListto a more specific valueAggregatedNumberedValue | list[AggregatedNumberedValue] | InstanceAggregationResultListdepending on theaggregatesandgroup_byparameters. - The
client.sequences.datamethods.retrieveand.insertmethod has changed signature: The parametercolumn_external_idsis renamedcolumns. The old parametercolumn_external_idsis still there, but is deprecated. In addition, int the.retrievemethod, the parametersidandexternal_idhave been moved to the beginning of the signature. This is to better match the API and have a consistent overload implementation. - The
client.sequences.data.retrieve_latestis renamedclient.sequences.data.retrieve_last_row.
- All
asserts meant for the SDK user, now raise appropriate errors instead (ValueError,RuntimeError...). CogniteAssetHierarchyErroris no longer possible to catch as anAssertionError.- More narrow exception types like
CogniteNotFoundErrorandCogniteDuplicatedErrorare now raised instead ofCogniteAPIErrorfor the following methods:DatapointsAPI.retrieve_latest,RawRowsAPI.list,RelationshipsAPI.list,SequencesDataAPI.retrieve,SyntheticDatapointsAPI.query. Additionally, all calls usingpartitionsto API methods likelist(or the generator version) now do the same. - Several methods in the data modelling APIs have had parameter names now correctly reflect whether they accept a single or multiple items (i.e. id -> ids).
- Passing
limit=0no longer returnsDEFAULT_LIMIT_READ(25) resources, but raises aValueError. - Loading
ObjectDetectionattributes.attributes,.bounding_box,.polygonand.polylinenow returns typesdict[str, Attribute],BoundingBox,PolygonandPolylineinstead ofdicts. - Loading
TextRegionattribute.text_regionnow returnBoundingBoxinstead ofdict. - Loading
AssetLinkattribute.text_regionand.asset_refreturnsBoundingBoxandCdfResourceRefinstead ofdict. - Loading
KeypointCollectionattributes.keypointsand.attributesreturndict[str, Keypoint]anddict[str, Attribute]instead ofdict. - Loading
VisionExtractPredictionsthe attributestext_predictions,asset_tag_prediction,industrial_object_prediction,people_predictions,personal_protective_equipment_predictions,digital_gauge_predictions,dial_gauge_predictions,level_gauge_predictions,valve_predictionsnow returnsdict[str, TextRegion],list[AssetLink],list[ObjectDetection],list[KeypointCollectionWithObjectDetection]instead ofdict. - Loading
FeatureParametersthe attributestext_detection_parameters,asset_tag_detection_parameters,industrial_object_prediction_parameters,personal_protective_equipment_parameters,digital_gauge_parameters,dial_gauge_detection_parameters,level_gauge_parameters,valve_detection_parametersnow returnsTextDetectionParameter,AssetTagDetectionParameters,PeopleDetectionParameters,IndustrialObjectDetectionParameters,PersonalProtectiveEquimentDetectionParameters,DigitalGaugeDetection,ValveDetectioninstead ofdict. - Loading
ExtractionPipelinethe attribute.contactsnow returnslist[ExtractionPipelineContact]instead ofdict. - Loading
GeospatialComputedResponsethe attribute.itemsnow returnsGeospatialComputedItemListinstead oflist[dict]. - Loading
Transformationthe attributes.running_job,.last_finished_job,.blocked,.schedule.source_session,.destination_session,.source_nonce,destination_nonce,.source_oidc_credentials,.destination_oidc_credentialsnow returnsTransformationJob,TransformationBlockedInfo,TransformationSchedule,SessionDetails,NonceCredentialsOidcCredentials, instead ofdicts. - Loading
TransformationPreviewResultthe attribute.schemanow returnsTransformationSchemaColumnListinstead oflist[dict]. - Loading
TransformationJobthe attribute.destinationand.statusnow returnTransformationDestinationandTransformationJobStatusinstead ofdict. - The
Groupattributecapabilitiesis now aCapabilitiesobject, instead of adict. - The class
SequenceDatahas been replaced bySequenceRows. The oldSequenceDataclass is still available for backwards compatibility, but will be removed in the next major version. However, all API methods now returnSequenceRowsinstead ofSequenceData. - The attribute
columnsinSequencehas been changed fromSequenceType[dict]toSequnceColumnList. - The class
SequenceRowsinclient.data_classes.transformations.commonhas been renamed toSequenceRowsDestination. - Classes
Geometry,AssetAggregate,AggregateResultItem,EndTimeFilter,Label,LabelFilter,ExtractionPipelineContact,TimestampRange,AggregateResult,GeometryFilter,GeoLocation,RevisionCameraProperties,BoundingBox3Dare no longerdictbut classes with attributes matchhng the API. - Calling
client.iam.token.inspect()now gives an objectTokenInspectionwith attributecababilitiesof typeProjectCapabilityListinstead oflist[dict] - In data class
Transformationthe attributeschedule,running_job, andlast_running_job,external_idandidare set to theTransformationidandexternal_idif not set. If they are set to a different value, aValueErroris raised
CogniteImportErrorcan now be caught asImportError.
- Removed support for legacy auth (API keys, service accounts, client.login.status()). Use OIDC to authenticate instead and use
client.iam.token.inspect()instead oflogin.status(). - Removed the deprecated
extractionPipelineargument toclient.extraction_pipelines.create. Onlyextraction_pipelineis accepted now. - Removed the deprecated
client.datapointsaccessor attribute. The datapoints API can only be accessed throughclient.time_series.datanow. - Removed the deprecated
client.extraction_pipeline_runsaccessor attribute. The extraction pipeline run API can only be accessed throughclient.extraction_pipelines.runsnow. - Removed the deprecated
external_idattribute onExtractionPipelineRun. This has been replaced withextpipe_external_id.
- Required dependency,
protobuf. - Optional dependency,
numpy(performance benefits, but requires refactoring).
- Consider changing
client.datapoints(deprecated) toclient.time_series.data.
DatapointsAPI.query: All three retrieve-endpoints now support arbitrarily complex queries. See docstring ofDatapointsAPI.retrievefor example usage.DatapointsAPI.retrieve_dataframe_dict: Not needed as the combination of.getand e.g..averagecovers the same use case - with simpler syntax.- Exception
CogniteDuplicateColumnsError: Duplicated identifiers in datapoint queries are now allowed. - All convenience methods related to plotting and the use of
matplotlib(go ask your FNDS <3 (Friendly Neighborhood Data Scientist).
- All parameters to all retrieve methods are now keyword-only (meaning no positional arguments are supported).
- All Cognite resource types (data classes) have a
to_pandas(orto_geopandas) method. Previously, these had various defaults for thecamel_caseparameter, but they have all been changed toFalse. DatapointsAPI.insert_dataframehas new default values for:dropna: Changed fromFalsetoTrue(functionality unchanged, applies per-column)external_id_headers: Changed fromFalsetoTrueto disincentivize the use of internal IDs.
DatapointsAPI.retrieve_dataframeno longer has a mix ofids andexternal_ids in the columns when given identifiers for both arguments. Instead, the user might select either by passing the new parametercolumn_names.DatapointsAPI.retrieve_dataframeno longer supports thecompleteparameter.DatapointsAPI.retrieve_dataframenow accepts the parameteruniform_index (bool). See function docstring for explanation and usage examples.
- Fetching datapoints with
limit=0no longer returns default number of datapoints, but 0. - Fetching raw datapoints with a finite
limitandinclude_outside_points=Truenow returns both outside points (if they exist) regardless of the givenlimit, meaning the returned datapoints count is up tolimit+2. - Fetching aggregate datapoints now includes the time period(s) (given by the
granularityunit) thatstartandendare part of (used to be only the "fully in-between" points). - The
getmethod ofDatapointsListandDatapointsArrayListnow returns a list ofDatapoints(or list ofDatapointsArray) for all identifiers that were duplicated in the user's query. Previously duplicated identifiers would raise prior to fetching data with one exception: (weird edge case) when passing theidandexternal_idfor the same time series. - The ordering of columns with aggregates in
pandas.DataFrames as returned byDatapointsAPI.retrieve_dataframe,Datapoints.to_pandasandDatapointsList.to_pandasis now chronological, i.e.averagebeforediscrete_variancewhich in turn comes beforesum. - The utility function
datetime_to_msno longer issues aFutureWarningon missing timezone information. It will interpret naivedatetimes as local time as is Python's default interpretation. - The utility function
ms_to_datetimeno longer issues aFutureWarningon returning a naivedatetimein UTC. It will now return an awaredatetimeobject in UTC. - The utility function
ms_to_datetimeno longer raisesValueErrorfor inputs from before 1970, but will raise for input outside the allowed minimum- and maximum supported timestamps in the API.
- Resource types
DatapointsArrayandDatapointsArrayListwhich offer way more efficient memory storage for datapoints (usesnumpy.ndarrays) - New datapoints fetching method,
DatapointsAPI.retrieve_arrays, returningDatapointsArrayandDatapointsArrayList. - A single aggregate, e.g.
average, can be specified by a string directly,aggregates="average"(as opposed to packing it inside a list,aggregates=["average"])
...
...
...