Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
18ee841
add httpx and poetry update
haakonvt Aug 27, 2024
3d0e5ff
add: unpack_items function
haakonvt Dec 20, 2024
43c885d
refactor: move url methods to utils/_url.py. add VALID_URL_PATTERN
haakonvt Dec 20, 2024
84838f6
remove playground
haakonvt Feb 5, 2025
f51985a
refactor: split out basic api methods in BasicAPIClient
haakonvt Oct 3, 2025
8d60db1
update HTTPClient(WithRetry), HTTPClient(WithRetry)Config and RetryTr…
haakonvt Feb 6, 2025
7ef9079
update GlobalConfig and ClientConfig
haakonvt Feb 6, 2025
99bcea4
update APIClient/BasicAPIClient GET/POST etc, introduce FailedRequest…
haakonvt Feb 6, 2025
1bbb7bc
update exceptions. always use specialized not-found/duplicated err
haakonvt Feb 6, 2025
bbcca7a
add drop_none_values to fix httpx usage of url params that are null
haakonvt Feb 6, 2025
a4543b0
update APIs using _do_request or stream
haakonvt Feb 6, 2025
708399c
dependency: swap responses with httpx_mock
haakonvt Jan 19, 2025
4eebe38
replace response mock with pytest-httpx (mock)
haakonvt Feb 6, 2025
12c2596
remove dependency pyodide-http
haakonvt Oct 3, 2025
16cef64
clean up pyodide patch script
haakonvt Oct 3, 2025
dd3698d
add authlib, remove requests-oauthlib
haakonvt Mar 3, 2025
678e54a
use httpx-backed authlib for client credz auth flow
haakonvt Aug 26, 2025
77b3802
update the wording/warning on 'HTTP Request logging'
haakonvt Aug 26, 2025
86a4311
update .gemini/styleguide.md with httpx.Response
haakonvt Aug 26, 2025
921bec1
add EventLoopThreadExecutor + global_config.event_loop
haakonvt Aug 27, 2025
cac29b4
Fix http client usage in organization API
erlendvollset Sep 11, 2025
31c71a3
Fix required vs nullable attributes on Asset and related classes
erlendvollset Sep 2, 2025
b02974f
Fix required vs nullable attributes on Event and related classes
erlendvollset Sep 2, 2025
96b5ff2
Fix required vs nullable attributes on DataSet and related classes
erlendvollset Sep 2, 2025
f0322d1
Fix required vs nullable attributes on TimeSeries and related classes
erlendvollset Sep 2, 2025
57d46bc
Fix required vs nullable attributes on File and Annotation classes
erlendvollset Sep 2, 2025
427607c
Fix required vs nullable attributes on Relationship classes
erlendvollset Sep 2, 2025
30665bc
Fix required vs nullable attributes on Raw classes
erlendvollset Sep 2, 2025
d606e9d
Fix required vs nullable attributes on Sequence classes
erlendvollset Sep 2, 2025
11ae56a
Fix required vs nullable attributes on Group and SecurityCategory cla…
erlendvollset Sep 2, 2025
ac969a7
Fix required vs nullable attributes on Function classes
erlendvollset Sep 2, 2025
cf3a6fe
Fix required vs nullable attributes on Vision classes
erlendvollset Sep 3, 2025
7a6c088
Fix required vs nullable attributes on ExtractionPipeline and related…
erlendvollset Sep 3, 2025
0ec1509
Fix required vs nullable attributes on ThreeD classes
erlendvollset Sep 4, 2025
9fc41ad
Move test_unit/test_transformations/test_common.py into test_unit/tes…
erlendvollset Sep 2, 2025
83e1519
Fix load methods for Datapoint classes
erlendvollset Sep 3, 2025
290aff0
Fix load method for EntityMatchingModel
erlendvollset Sep 2, 2025
e7950c2
Fix various unit tests
erlendvollset Sep 2, 2025
c845523
Import Self from typing_extensions
erlendvollset Sep 3, 2025
d264707
Introduce DefaultResourceGenerator
erlendvollset Sep 4, 2025
7674755
Fix cognite_client unit tests
erlendvollset Sep 4, 2025
2fe54cb
Fix dataclass unit tests
erlendvollset Sep 4, 2025
39f03bc
Fix docstring example tests
erlendvollset Sep 4, 2025
40605a1
Fix required vs nullable attributes on Transformation classes
erlendvollset Sep 4, 2025
751fe64
Enable mypy for some asset tests
erlendvollset Sep 4, 2025
a64508d
Make pretty much all unit tests pass
erlendvollset Sep 4, 2025
b9d3c8b
Remove all traces of templates API
erlendvollset Sep 4, 2025
a2537eb
More typing.Self -> typing_extensions.Self
erlendvollset Sep 4, 2025
0d538f7
fix: create_hierarchy, AssetHierarchy and their tests
haakonvt Sep 5, 2025
3311341
Enable mypy for events tests
erlendvollset Sep 5, 2025
aff7ace
Enable mypy for raw tests
erlendvollset Sep 5, 2025
ddcbaa3
Fix load method for Group
erlendvollset Sep 5, 2025
8754ced
Fix remaining asset unit tests
erlendvollset Sep 5, 2025
0da20c6
Fix remaining integration tests
erlendvollset Sep 5, 2025
cf1bfd0
Fix doctests
erlendvollset Sep 5, 2025
71d62d3
Run mypy on all util unit tests
erlendvollset Sep 5, 2025
04ca954
Run mypy on tests_unit/test_api_client.py
erlendvollset Sep 8, 2025
95c0be2
Run mypy on tests_unit/test_base.py
erlendvollset Sep 8, 2025
44538d8
Run mypy on tests_unit/test_cognite_client.py
erlendvollset Sep 8, 2025
7b85427
Run mypy on tests_unit/test_config.py
erlendvollset Sep 8, 2025
f808cf5
Run mypy on tests_unit/test_credential_providers.py
erlendvollset Sep 8, 2025
64ff6c7
Run mypy on tests_unit/test_docstring_examples.py
erlendvollset Sep 8, 2025
1c07b80
Run mypy on tests_unit/test_exceptions.py
erlendvollset Sep 8, 2025
9c8c0fb
Run mypy on tests_integration/test_api/test_workflows.py
erlendvollset Sep 8, 2025
62788ca
Run mypy on tests_integration/test_api/test_transformations
erlendvollset Sep 8, 2025
3ee5d36
Run mypy on tests_integration/test_api/test_agents.py
erlendvollset Sep 8, 2025
b69f62b
Run mypy on tests_integration/test_api/test_annotations.py
erlendvollset Sep 8, 2025
cf498b6
Make all tests return None
erlendvollset Sep 8, 2025
fbbc769
Run mypy on tests_integration/test_api/test_data_sets.py
erlendvollset Sep 8, 2025
806032e
Run mypy on tests_integration/test_api/test_datapoint_subscriptions.py
erlendvollset Sep 8, 2025
f1b2c9c
Run mypy on tests_integration/test_api/test_diagrams.py
erlendvollset Sep 8, 2025
8a8ab92
Run mypy on tests_integration/test_api/test_documents.py
erlendvollset Sep 8, 2025
1285bbc
Fix agent dataclass unit tests
erlendvollset Sep 8, 2025
613d968
Run mypy on tests_integration/test_api/test_entity_matching.py
erlendvollset Sep 8, 2025
f0adede
Run mypy on tests_integration/test_api/test_extraction_pipelines.py
erlendvollset Sep 8, 2025
923cd52
Run mypy on tests_integration/test_api/test_files.py
erlendvollset Sep 8, 2025
fedd3bf
Run mypy on tests_integration/test_api/test_functions.py
erlendvollset Sep 8, 2025
dbf6433
Run mypy on tests_integration/test_api/test_geospatial.py
erlendvollset Sep 8, 2025
46b266a
Run mypy on tests_integration/test_api/test_iam.py
erlendvollset Sep 8, 2025
4e4bb91
Run mypy on tests_integration/test_api/test_labels.py
erlendvollset Sep 8, 2025
84f01dc
Run mypy on more integration tests
erlendvollset Sep 8, 2025
7485641
Run mypy on more relationship integration tests
erlendvollset Sep 9, 2025
613faae
Run mypy on all integration tests
erlendvollset Sep 9, 2025
41c28c8
Improve contextualization classes and clients
erlendvollset Sep 9, 2025
cdfbe70
Run mypy on files unit tests
erlendvollset Sep 11, 2025
7263cb6
Run mypy on sequences unit tests
erlendvollset Sep 11, 2025
6edfaec
Fix some failing integration tests
erlendvollset Sep 11, 2025
b6a01da
startTime is not required for VisionExtracJob
erlendvollset Sep 11, 2025
ab085b1
Run mypy on all files in tests_unit/test_api
erlendvollset Sep 11, 2025
9c5de2d
Run mypy on all test files
erlendvollset Sep 11, 2025
835b56a
Run 'build' workflow on all PRs
erlendvollset Sep 12, 2025
48b6924
Clean up ignore_missing_imports in mypy.ini
erlendvollset Sep 12, 2025
ce78d27
feat: Change to httpx.AsyncClient
haakonvt Sep 1, 2025
c6f324a
fix: stream methods
haakonvt Sep 20, 2025
295eac7
remove all __iter__ methods, update docstrings
haakonvt Sep 9, 2025
964cf4f
fix: save one list copy op in datapoints-insert-loop
haakonvt Sep 19, 2025
430ef25
rename CogniteClient to AsyncCogniteClient
haakonvt Sep 20, 2025
c16927d
Make Everything Async (except custom threading code)
haakonvt Sep 16, 2025
167f615
remove function import_as_completed
haakonvt Sep 23, 2025
dca21f7
convert AssetsAPI.create_hierarchy to async
haakonvt Sep 25, 2025
2aea338
improve ergonomics of AsyncSDKTask with __getitem__
haakonvt Sep 25, 2025
35f49ac
drop pytest-asyncio in favor of anyio (used by httpx, so non-optional)
haakonvt Sep 25, 2025
53a827c
remove retrieve_dataframe_in_tz (timezone now support in API)
haakonvt Feb 20, 2025
2c07d42
change datapoints fetch code to async 😓
haakonvt Sep 25, 2025
4e05223
fix CogniteNotFoundError missing cluster and project
haakonvt Sep 26, 2025
643ab0b
fix async: CogniteProjectAccessError._attempt_to_get_projects
haakonvt Sep 26, 2025
8dcd968
update raw rows iter method to async
haakonvt Sep 27, 2025
288496a
add AsyncCogniteClient to all examples
haakonvt Sep 27, 2025
4646642
make sequences.rows a property and add DeprecationWarning
haakonvt Sep 27, 2025
f963717
add SyncIterator (to wrap async __call__) to utils/_async_helpers.py
haakonvt Sep 27, 2025
69b99e0
rename _json.py to _json_extended.py as it conflicts with stdlib _jso…
haakonvt Sep 28, 2025
5151aa2
split SequenceDataAPI into separate file
haakonvt Sep 29, 2025
ebf6af3
split FunctionCallsAPI and FunctionSchedulesAPI into separate files
haakonvt Sep 29, 2025
b278093
split UnitSystemAPI into separate file
haakonvt Sep 29, 2025
821866b
split IAMAPIs into separate files.
haakonvt Sep 29, 2025
54cdd64
split RawAPIs into separate files
haakonvt Sep 29, 2025
8ccc225
split DocumentPreviewAPI into separate file
haakonvt Sep 29, 2025
2c27c9f
split WorkflowAPIs into separate files
haakonvt Sep 29, 2025
c6b9d7f
split 3D APIs into separate files
haakonvt Sep 29, 2025
efd550f
split ExtractionPipelinesAPIs into separate files
haakonvt Sep 29, 2025
9b2d941
split SpaceStatisticsAPI into separate file
haakonvt Sep 29, 2025
8850db8
fix mypy issues in async APIs + data classes + tests
haakonvt Oct 2, 2025
e1751d5
httpx no longer need pyodide-patching!
haakonvt Sep 30, 2025
b35ca7f
fix: reintroduce _base_url_with_base_path on API client to handle Org…
haakonvt Sep 8, 2025
88ba6e3
make the SDK work in "normal" jupyter notebooks
haakonvt Sep 30, 2025
32c4fc5
add run_sync function to _utils/async_helpers.py
haakonvt Oct 4, 2025
c9e8944
delete: cognite/client/beta.py
haakonvt Oct 4, 2025
8a7b76c
remove deprecated aggregate methods
haakonvt Oct 5, 2025
4a4a89f
remove deprecated filter methods
haakonvt Oct 5, 2025
e2fa798
remove deprecated methods in _api/workflows/
haakonvt Oct 5, 2025
ddb79c3
remove support for deprecated argument 'column_external_ids' in _api/…
haakonvt Oct 5, 2025
03b6dde
fix incorrect _RESOURCE_PATH in _api/sequence_data.py
haakonvt Oct 5, 2025
8015f95
change agg method to "count" for data sets and files
haakonvt Oct 5, 2025
f5f3b59
remove CountAggregate
haakonvt Oct 5, 2025
9db783a
make TemplateGroupsAcl a LegacyCapability
haakonvt Oct 5, 2025
6a3116b
remove deprecated partitions-support on __call__
haakonvt Oct 5, 2025
ec90a19
remove legacy_name from time series data classes++
haakonvt Oct 5, 2025
63d2d7a
remove deprecated DataPointSubscriptionCreate
haakonvt Oct 5, 2025
c4769d3
flip expand_properties default to True in to_pandas (data modeling)
haakonvt Oct 5, 2025
2a19142
fix DataModelingInstancesList.get method (remove deprecated 'id' arg)
haakonvt Oct 5, 2025
e360726
raise in ViewProperty[-Apply] when conn.def. is missing 'connectionType'
haakonvt Oct 5, 2025
879c630
remove deprecated CogniteObject method load_yaml on Query
haakonvt Oct 5, 2025
3391dec
queries for datapoints can no longer be passes as dict
haakonvt Oct 5, 2025
11931da
remove deprecated DatapointsArray.__iter__ method
haakonvt Oct 5, 2025
1adce83
fix double type annotations in docstring
haakonvt Oct 6, 2025
5835794
add decorator factory 'copy_doc_from_async' (doc = docstring)
haakonvt Oct 6, 2025
69db3d9
fix data class helper methods: assets.py
haakonvt Oct 6, 2025
ca75eed
fix data class helper methods: contextualization.py
haakonvt Oct 6, 2025
4bf9b74
fix data class helper methods: files.py
haakonvt Oct 6, 2025
3d2ee78
fix data class helper methods: functions.py
haakonvt Oct 6, 2025
983a993
fix data class helper methods: raw.py
haakonvt Oct 6, 2025
e0981fa
fix data class helper methods: sequences.py
haakonvt Oct 6, 2025
6b11998
fix data class helper methods: simulators/*
haakonvt Oct 6, 2025
3876632
fix data class helper methods: time_series.py
haakonvt Oct 6, 2025
e65e9a1
fix data class helper methods: transformations/__init__.py
haakonvt Oct 6, 2025
d978856
fix data class helper methods: transformations/jobs.py
haakonvt Oct 6, 2025
f8a4e31
remove param 'expected_fields' from Datapoints._load
haakonvt Oct 6, 2025
6b88c1d
remove warning in class Transformation on already removed init params
haakonvt Oct 6, 2025
6a27099
drop 'deprecated' from docs (toctree) after sunsetting TemplatesAPI
haakonvt Oct 6, 2025
4ffc679
update thread-executor tests to async: tests/tests_unit/test_utils/te…
haakonvt Oct 6, 2025
fef11ee
add Omitted class to be used as "not given" singleton
haakonvt Oct 7, 2025
7ca8a83
Update Apply-classes in cdm/v1.py to use OMITTED default
haakonvt Oct 7, 2025
4e52a26
Update Apply-classes in extractor_extensions/v1.py to use OMITTED def…
haakonvt Oct 7, 2025
17aaedd
Ignore OMITTED values from being dumped in: data_classes/data_modelin…
haakonvt Oct 7, 2025
06573a4
Load missing as OMITTED in Typed Apply classes in: data_classes/data_…
haakonvt Oct 15, 2025
0c85c43
use match statement in _serialize_value
haakonvt Oct 7, 2025
007b045
Ingesting no datapoints no longer raises an exception
MortGron Jun 16, 2025
2dc2454
remove alpha/beta client test fixtures/helper fns
haakonvt Oct 7, 2025
50391cc
make test util set_request_limit a fixture
haakonvt Oct 7, 2025
68970d8
refactor usage of set_request_limit
haakonvt Oct 7, 2025
6e169ac
update test to use tmp_path fixture
haakonvt Oct 7, 2025
d7b5845
spellcheck on AsyncCogniteClient
haakonvt Oct 7, 2025
35a4886
Access the response from the exception, not from the local variable
haakonvt Oct 8, 2025
4c8ba55
make PrincipalsAPI async
haakonvt Oct 8, 2025
aca45d9
fix: CI checks for pyodide after httpx addition
haakonvt Sep 1, 2025
b824cf7
remove arg ignore_allscope_meaning from ACL compare fns (in IAM)
haakonvt Oct 9, 2025
963abff
short-circuit "retrieve_multiple" and similar on [] input
haakonvt Oct 9, 2025
f774769
make ruff remove empty "if TYPE_CHECKING:" blocks
haakonvt Oct 9, 2025
cf0d355
rename ModelFailedException -> CogniteModelFailedError and fix inheri…
haakonvt Oct 9, 2025
2d098fc
Org APIs use api-layer logic, not http-layer. add CogniteOrganization…
haakonvt Oct 9, 2025
1fecfcf
build request again when retrying in AsyncHTTPClientWithRetry.stream
haakonvt Oct 13, 2025
50b03a2
remove special pyodide handling in FilesAPI upload *YEY*
haakonvt Oct 13, 2025
ae787e2
only accept pathlib.Path in FilesAPI (keep str support though)
haakonvt Oct 13, 2025
03e85ba
fix bug in '_process_file_download' by using 'is_relative_to' instead
haakonvt Oct 13, 2025
b5f34ae
add helpers for file handling: utils/_uploading.py
haakonvt Oct 13, 2025
c3638a0
fix FilesAPI: httpx AsyncClient doesn't accept regular file handles (…
haakonvt Oct 13, 2025
1c83d03
make FileMultipartUploadSession work in both sync and async contexts
haakonvt Oct 13, 2025
285c348
add script to convert async apis into sync
haakonvt Sep 29, 2025
8a70bca
add Mock for async client: AsyncCogniteClientMock
haakonvt Oct 4, 2025
9c5b4a1
properly fix missing AsyncMocks in AsyncCogniteClientMock
haakonvt Oct 14, 2025
55900f1
properly fix spec_set=True in CogniteClientMock
haakonvt Oct 14, 2025
fd47e99
change monkeypatch client fns to use patch instead of hacking __new__
haakonvt Oct 14, 2025
04aae6e
update mock tests after refactoring
haakonvt Oct 14, 2025
308ab9e
refactor BasicAsyncAPIClient._request to log but re-raise
haakonvt Oct 13, 2025
5125e37
fix: missing payload from on-error-logging/raising
haakonvt Oct 13, 2025
e0df751
run script to create all sync APIs + sync CogniteClient
haakonvt Oct 2, 2025
2eb6bd9
update API-conversion script to include sync methods + overloads
haakonvt Oct 15, 2025
3656546
run updated script to update sync APIs
haakonvt Oct 15, 2025
720ea2a
update conversion script to add basic HTTP methods++ to CogniteClient
haakonvt Oct 15, 2025
44c3b35
fix tests: tests/tests_unit/* and tests/utils.py
haakonvt Oct 15, 2025
b687e9d
fix tests: tests/tests_unit/test_api/*
haakonvt Oct 15, 2025
26318a2
fix tests: tests/tests_unit/test_data_classes/*
haakonvt Oct 15, 2025
354fe4a
WIP, fix tests: tests/tests_integration/*
haakonvt Oct 15, 2025
c4af93d
fix plain wrong code in docstring examples
haakonvt Oct 15, 2025
3dfb48a
fix: various imports
haakonvt Oct 15, 2025
1f380cb
run coverage also on test files
haakonvt Oct 16, 2025
ee8c397
refactor: insert_dataframe, infer id type from columns
haakonvt Feb 19, 2025
3a4f750
Update Sphinx documentation
haakonvt Oct 14, 2025
a1ed21b
reorgranize DatapointsAPI, split utils and aggregates
haakonvt Oct 21, 2025
f4285dd
refactor Synth.DatapointsAPI to not use _extend
haakonvt Oct 21, 2025
3b99c4c
refactor: use MultiIndex in df.columns for dps dataframes
haakonvt Oct 21, 2025
c1934cc
move Geometry from data_classes/_base to /shared.py
haakonvt Oct 21, 2025
34110e6
convert timed_cache to async, add tests
haakonvt Oct 22, 2025
c6da7e5
update _select_dps_fetch_strategy to use semaphore bound value
haakonvt Oct 22, 2025
a51195c
refactor InstancesAPI.subscribe to async
haakonvt Oct 24, 2025
565540f
update docs on InstancesAPI.subscribe -> local sqlite db
haakonvt Oct 24, 2025
c171617
Split query and sync classes
audunska Oct 16, 2025
d0fbb51
Filter: Add magic __eq__
audunska Oct 24, 2025
7f731d0
Turn split sync query classes into dataclasses
audunska Oct 23, 2025
f2d57ea
Fix tests related to Query-Sync-split
audunska Oct 17, 2025
9f8f2c5
Update InstancesAPI.subscribe doc example to use -Sync classes
audunska Oct 23, 2025
0fe1aa8
never ending TMP
haakonvt Oct 25, 2025
155d473
make BasicAsyncAPIClient picklable
haakonvt Oct 27, 2025
edbae4c
turn on pickle-client-test and add one for AsyncCogniteClient
haakonvt Oct 27, 2025
67737d3
Update MIGRATION_GUIDE.md for v7 -> v8
haakonvt Oct 5, 2025
2142f74
BUMP VERSION to 8.0.0a1
haakonvt Oct 13, 2025
8923004
WIP Cursor wrote migration guide
haakonvt Oct 28, 2025
016505a
TMP
haakonvt Oct 28, 2025
a3699a0
Split the container classes into read/write
audunska Oct 21, 2025
ee1ff0e
Update docstrings in api
audunska Oct 21, 2025
0b8f877
Update tests
audunska Oct 21, 2025
eadb735
Remove all defaults from read classes
audunska Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[run]
source=cognite
source =
cognite
tests
omit =
cognite/client/_proto/*

Expand Down
2 changes: 1 addition & 1 deletion .gemini/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import logging
from pathlib import Path
from typing import TYPE_CHECKING

from requests import Response
from httpx import Response

from cognite.client.data_classes import Asset

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: build
on:
merge_group:
pull_request:
branches: [master]

concurrency:
group: pr-${{ github.workflow }}-${{ github.head_ref }}
Expand Down Expand Up @@ -70,9 +69,10 @@ jobs:
COGNITE_BASE_URL: ${{ vars.CDF_BASE_URL_CI }}
COGNITE_CLIENT_NAME: python-sdk-integration-tests
# Testpaths are defined in the pytest.ini file:
run: pytest --durations=10 --cov --cov-report term --cov-report xml:coverage.xml -n8 --dist loadscope --reruns 2 --maxfail 20
# run: pytest --durations=10 --cov --cov-report term --cov-report xml:coverage.xml -n8 --dist loadscope --reruns 2 --maxfail 20
run: pytest tests/tests_integration/test_api/test_workflows.py --reruns 5

- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
if: matrix.os == 'windows-latest' && matrix.python-version == '3.10'
with:
token: ${{ secrets.CODECOV_TOKEN }}
# - uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
# if: matrix.os == 'windows-latest' && matrix.python-version == '3.10'
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/verify-jupyter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
whl_file=$(find dist -name "*.whl" | sed 's|^dist/||') # Find the built wheel file, remove dist/ prefix
echo "Found built wheel file: $whl_file"
SDK_FILE_PATH=$whl_file \
PACKAGES="[\"pyodide-http\", \"http://localhost:3000/dist/$whl_file\"]" \
PACKAGES="[\"anyio\", \"http://localhost:3000/dist/$whl_file\"]" \
node scripts/test-pyodide.js
2 changes: 1 addition & 1 deletion .github/workflows/verify-streamlit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
whl_file=$(find dist -name "*.whl" | sed 's|^dist/||') # Find the built wheel file, remove dist/ prefix
echo "Found built wheel file: $whl_file"
SDK_FILE_PATH=$whl_file \
PACKAGES="[\"pyodide-http\", \"http://localhost:3000/dist/$whl_file\"]" \
PACKAGES="[\"ssl\", \"anyio\", \"http://localhost:3000/dist/$whl_file\"]" \
node scripts/test-pyodide.js
11 changes: 1 addition & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@ repos:
hooks:
- id: mypy
name: mypy
# Eventually we want to run mypy on the whole test code base. But for now we only enable it for data modeling, simulators and datapoints
entry: |
poetry run dmypy run -- cognite tests/tests_integration/test_api/test_data_modeling
tests/tests_unit/test_data_classes/test_data_models
tests/tests_unit/test_utils/test_time.py
tests/tests_integration/test_api/test_datapoints.py
tests/tests_integration/test_api/test_simulators
tests/tests_integration/test_api/test_principals.py
tests/tests_unit/test_api/test_simulators
tests/tests_unit/test_data_classes/test_simulators.py
entry: poetry run dmypy run -- cognite tests
files: ^.*.(py|pyi)$
language: system
pass_filenames: false
Expand Down
58 changes: 58 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,64 @@ Changes are grouped as follows:
- `Changed` for changes that do not fall into any other category
- `Optional` for new, optional methods/features that you should be aware of - *and could take advantage of*


## From v7 to v8

### Dependency
- **httpx**: The SDK now uses `httpx` instead of `requests` for HTTP operations. This is a required dependency.
- **anyio**: Added as a required dependency (used by httpx, replaces pytest-asyncio).

### Functionality
- **Async Support**: The SDK now provides full async support. The main client is now `AsyncCogniteClient` (previously `CogniteClient`), and a new synchronous `CogniteClient` is available for backward compatibility.
- **HTTP Client**: All HTTP operations now use `httpx.AsyncClient` instead of `requests`.
- **DataFrames**: Datapoints DataFrames now use MultiIndex columns for better organization of aggregate data.
- **File Handling**: FilesAPI now prefers `pathlib.Path` objects over strings (though string support is maintained).
- **JSON Serialization**: The SDK now uses compact JSON encoding for better performance.

### Removed
- **Deprecated Aggregate Methods**: Removed deprecated `aggregate` methods from AssetsAPI, EventsAPI, SequencesAPI, and TimeSeriesAPI. Use `aggregate_count` instead.
- **Deprecated Filter Methods**: Removed deprecated filter methods from various APIs.
- **Deprecated Data Classes**:
- `CountAggregate` class removed
- `DataPointSubscriptionCreate` class removed
- `SequenceData` class replaced by `SequenceRows` (old class still available for backward compatibility)
- **Deprecated Methods**:
- `DatapointsArray.__iter__` method removed
- `CogniteObject.load_yaml` method on Query removed
- `DataModelingInstancesList.get` method no longer accepts deprecated `id` argument
- All `__iter__` methods removed from API classes
- **Legacy Attributes**:
- `legacy_name` attribute removed from time series data classes
- `expected_fields` parameter removed from `Datapoints._load`
- **Pyodide Handling**: Removed special pyodide handling in FilesAPI upload operations.

### Function Signature
- **Client Rename**: `CogniteClient` is now `AsyncCogniteClient`. A new synchronous `CogniteClient` is available.
- **Sequence Data**: `client.sequences.data.retrieve_latest` renamed to `client.sequences.data.retrieve_last_row`.
- **Data Modeling**: `expand_properties` parameter in `to_pandas` methods now defaults to `True` for data modeling classes.
- **File Paths**: FilesAPI methods now prefer `pathlib.Path` objects but still accept strings.

### Changed
- **API Organization**: Many APIs have been split into separate files (Java-style organization):
- Functions API split into `functions/` directory
- IAM API split into `iam/` directory
- Raw API split into `raw/` directory
- 3D API split into `three_d/` directory
- Workflows API split into `workflows/` directory
- **Query Classes**: Query and sync classes have been split into separate dataclasses.
- **Filter Classes**: Filter classes now have magic `__eq__` method for better usability.
- **Data Classes**: Various data classes have been updated with new attributes and methods.
- **Exception Handling**: New exception types added (e.g., `CogniteOrganizationError`, `CogniteModelFailedError`).

### Optional
- **New APIs**: Several new APIs have been added:
- Agents API for AI agent functionality
- Simulators API for simulation operations
- Document Preview API
- Space Statistics API
- **New Data Classes**: Many new data classes added for new features like agents, simulators, and enhanced data modeling.
- **Enhanced Capabilities**: New ACL capabilities added for Streams, Records, and AppConfig.

## From v6 to v7
### Functionality
- `CogniteResource.to_pandas` and `CogniteResourceList.to_pandas` now converts known timestamps to `datetime` by
Expand Down
5 changes: 3 additions & 2 deletions cognite/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

from cognite.client._cognite_client import CogniteClient
from cognite.client._cognite_client import AsyncCogniteClient
from cognite.client._constants import _RUNNING_IN_BROWSER
from cognite.client._sync_cognite_client import CogniteClient
from cognite.client._version import __version__
from cognite.client.config import ClientConfig, global_config
from cognite.client.data_classes import data_modeling

__all__ = ["ClientConfig", "CogniteClient", "__version__", "data_modeling", "global_config"]
__all__ = ["AsyncCogniteClient", "ClientConfig", "CogniteClient", "__version__", "data_modeling", "global_config"]

if _RUNNING_IN_BROWSER:
from cognite.client.utils._pyodide_helpers import patch_sdk_for_pyodide
Expand Down
53 changes: 24 additions & 29 deletions cognite/client/_api/agents/agents.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, overload
from typing import TYPE_CHECKING, overload

from cognite.client._api_client import APIClient
from cognite.client.data_classes.agents import Agent, AgentList, AgentUpsert
Expand All @@ -16,27 +16,27 @@
from cognite.client.utils.useful_types import SequenceNotStr

if TYPE_CHECKING:
from cognite.client import CogniteClient
from cognite.client import AsyncCogniteClient
from cognite.client.config import ClientConfig


class AgentsAPI(APIClient):
_RESOURCE_PATH = "/ai/agents"

def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: AsyncCogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self._warnings = FeaturePreviewWarning(api_maturity="beta", sdk_maturity="alpha", feature_name="Agents")
self._api_subversion = "beta"
self._CREATE_LIMIT = 1
self._DELETE_LIMIT = 1

@overload
def upsert(self, agents: AgentUpsert) -> Agent: ...
async def upsert(self, agents: AgentUpsert) -> Agent: ...

@overload
def upsert(self, agents: Sequence[AgentUpsert]) -> AgentList: ...
async def upsert(self, agents: Sequence[AgentUpsert]) -> AgentList: ...

def upsert(self, agents: AgentUpsert | Sequence[AgentUpsert]) -> Agent | AgentList:
async def upsert(self, agents: AgentUpsert | Sequence[AgentUpsert]) -> Agent | AgentList:
"""`Create or update (upsert) one or more agents. <https://api-docs.cognite.com/20230101-beta/tag/Agents/operation/main_ai_agents_post/>`_

Args:
Expand Down Expand Up @@ -159,20 +159,20 @@ def upsert(self, agents: AgentUpsert | Sequence[AgentUpsert]) -> Agent | AgentLi

"""
self._warnings.warn()
return self._create_multiple(
return await self._create_multiple(
list_cls=AgentList,
resource_cls=Agent,
items=agents,
input_resource_cls=AgentUpsert,
)

@overload
def retrieve(self, external_ids: str, ignore_unknown_ids: bool = False) -> Agent | None: ...
async def retrieve(self, external_ids: str, ignore_unknown_ids: bool = False) -> Agent | None: ...

@overload
def retrieve(self, external_ids: SequenceNotStr[str], ignore_unknown_ids: bool = False) -> AgentList: ...
async def retrieve(self, external_ids: SequenceNotStr[str], ignore_unknown_ids: bool = False) -> AgentList: ...

def retrieve(
async def retrieve(
self, external_ids: str | SequenceNotStr[str], ignore_unknown_ids: bool = False
) -> Agent | AgentList | None:
"""`Retrieve one or more agents by external ID. <https://api-docs.cognite.com/20230101-beta/tag/Agents/operation/get_agents_by_ids_ai_agents_byids_post/>`_
Expand All @@ -188,8 +188,9 @@ def retrieve(

Retrieve an agent by external id:

>>> from cognite.client import CogniteClient
>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient() # another option
>>> res = client.agents.retrieve(external_ids="my_agent")

Retrieve multiple agents:
Expand All @@ -198,14 +199,14 @@ def retrieve(
"""
self._warnings.warn()
identifiers = IdentifierSequence.load(external_ids=external_ids)
return self._retrieve_multiple(
return await self._retrieve_multiple(
list_cls=AgentList,
resource_cls=Agent,
identifiers=identifiers,
ignore_unknown_ids=ignore_unknown_ids,
)

def delete(self, external_ids: str | SequenceNotStr[str], ignore_unknown_ids: bool = False) -> None:
async def delete(self, external_ids: str | SequenceNotStr[str], ignore_unknown_ids: bool = False) -> None:
"""`Delete one or more agents. <https://api-docs.cognite.com/20230101-beta/tag/Agents/operation/agent_delete_ai_agents_delete_post/>`_

Args:
Expand All @@ -216,19 +217,20 @@ def delete(self, external_ids: str | SequenceNotStr[str], ignore_unknown_ids: bo

Delete an agent by external id:

>>> from cognite.client import CogniteClient
>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient() # another option
>>> client.agents.delete(external_ids="my_agent")

"""
self._warnings.warn()
self._delete_multiple(
await self._delete_multiple(
identifiers=IdentifierSequence.load(external_ids=external_ids),
wrap_ids=True,
extra_body_fields={"ignoreUnknownIds": ignore_unknown_ids},
)

def list(self) -> AgentList: # The API does not yet support limit or pagination
async def list(self) -> AgentList: # The API does not yet support limit or pagination
"""`List agents. <https://api-docs.cognite.com/20230101-beta/tag/Agents/operation/agent_list_ai_agents_get/>`_

Returns:
Expand All @@ -238,16 +240,17 @@ def list(self) -> AgentList: # The API does not yet support limit or pagination

List all agents:

>>> from cognite.client import CogniteClient
>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient() # another option
>>> agent_list = client.agents.list()

"""
self._warnings.warn()
res = self._get(url_path=self._RESOURCE_PATH)
res = await self._get(url_path=self._RESOURCE_PATH)
return AgentList._load(res.json()["items"], cognite_client=self._cognite_client)

def chat(
async def chat(
self,
agent_external_id: str,
messages: Message | ActionResult | Sequence[Message | ActionResult],
Expand Down Expand Up @@ -337,26 +340,18 @@ def chat(
"""
self._warnings.warn()

# Convert single message to list
if isinstance(messages, Message | ActionResult):
messages = [messages]

# Build request body
body: dict[str, Any] = {
body = {
"agentExternalId": agent_external_id,
"messages": [msg.dump(camel_case=True) for msg in messages],
}

if cursor is not None:
body["cursor"] = cursor

if actions is not None:
body["actions"] = [action.dump(camel_case=True) for action in actions]

# Make the API call
response = self._post(
url_path=self._RESOURCE_PATH + "/chat",
json=body,
)

response = await self._post(url_path=self._RESOURCE_PATH + "/chat", json=body)
return AgentChatResponse._load(response.json(), cognite_client=self._cognite_client)
4 changes: 2 additions & 2 deletions cognite/client/_api/ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from cognite.client._api_client import APIClient

if TYPE_CHECKING:
from cognite.client import ClientConfig, CogniteClient
from cognite.client import AsyncCogniteClient, ClientConfig


class AIAPI(APIClient):
def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: AsyncCogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self.tools = AIToolsAPI(config, api_version, cognite_client)
4 changes: 2 additions & 2 deletions cognite/client/_api/ai/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from cognite.client._api_client import APIClient

if TYPE_CHECKING:
from cognite.client import ClientConfig, CogniteClient
from cognite.client import AsyncCogniteClient, ClientConfig


class AIToolsAPI(APIClient):
def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: AsyncCogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self.documents = AIDocumentsAPI(config, api_version, cognite_client)
Loading
Loading