Skip to content

feat(transformations): add external data sources client API - #2732

Merged
Khyat-Cognite merged 10 commits into
masterfrom
feat/transformations-externaldata-api
Aug 11, 2026
Merged

feat(transformations): add external data sources client API#2732
Khyat-Cognite merged 10 commits into
masterfrom
feat/transformations-externaldata-api

Conversation

@Khyat-Cognite

@Khyat-Cognite Khyat-Cognite commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

CDF-28251

Stacked on #2729 (feat/transformations-externaldata-models) — review #2729 first; this PR's diff is client-API only, no data class file is touched.

Adds client.transformations.external_data_sources for the /transformations/externaldata endpoint.

Endpoint surface

Method Endpoint Capability
list(limit=25) / __call__(chunk_size, limit) GET /transformations/externaldata transformationsExternalDataSourcesAcl:READ
upsert(data_source) POST /transformations/externaldata transformationsExternalDataSourcesAcl:WRITE
delete(external_id) POST /transformations/externaldata/delete transformationsExternalDataSourcesAcl:WRITE
verify_usability(external_id) POST /transformations/externaldata/usability transformationsExternalDataSourcesAcl:USE

There is no /byids endpoint, so there is no retrieve().

Tests

Unit (tests/tests_unit/test_api/test_transformations_external_data.py, 8 tests) — asserts the wire, not dump/load round trips:

  • list() parses into OneLakeExternalDataSource with typed nested settings
  • __call__() yields one-by-one, and __call__(chunk_size=25) yields 25 + 5 for a 30-item response
  • upsert() single and sequence — request items carry "format": "one_lake" and complete nested settings including clientSecret
  • delete() sends only items
  • verify_usability() sends a flat externalId and unwraps the nested response; the missing-usableVersion case gives is_usable is False

Integration (tests/tests_integration/test_api/test_transformations/test_externaldata.py) — upsert → list → verify_usability → delete against a live Fabric lakehouse, skipped unless ONELAKE_CLIENT_ID, ONELAKE_TENANT_ID, ONELAKE_CLIENT_SECRET, ONELAKE_WORKSPACE_ID and ONELAKE_CONTAINER_ID are set.

Also verified locally: sync codegen verify clean, pre-commit clean (the only mypy errors are pre-existing tests/utils.py numpy-typing ones, present on the base commit too), full unit suite failure set identical to the base commit, and make linkcheck/make html with -W both succeed with the new autosummary pages generated.

Adds the data-class layer for the /transformations/externaldata beta
endpoint (Fabric OneLake external data sources for transformations).
Mirrors the polymorphic read/write pattern already used by
hosted_extractors.Source/SourceWrite, since both cases share the same
shape: a write-only secret that the API never returns on read.
READ/WRITE/USE actions for the new transformations external data
sources endpoint, scoped to all-projects or a data set.
… redaction

Round-trip dump/load is covered automatically by the generic
CogniteResource suite in test_base.py (two new exclusion lines for the
as_write generic test, since the client secret is never returned on
read). The focused tests here cover only what that suite can't reach:
format dispatch, the unknown-format fallback (including the
order-dependent behavior inherited from CogniteResourceList when an
unknown-format item is first in a list), as_write raising, secret
redaction in repr/str, and usability status.
…ity.dump

Addresses gemini-code-assist review on #2729: replace pop-inside-literal
with a direct assignment guarded by a membership check.
… models

- Dispatching _load methods now declare their concrete return type
  instead of Self, since the returned instance may be a different
  subclass than the one the classmethod was called on.
- ExternalDataSourceWrite._load's error message hints that an
  unrecognized format may require an SDK upgrade.
- OneLakeExternalDataSourceWrite's docstring example reads the client
  secret from an environment variable instead of a placeholder string.
- Collapse the two issubclass checks in test_base.py's exclusion filter
  into one using a union type.
- Drop the two tests that only exercised CogniteResourceList's
  base-class type-check behavior, not anything specific to
  ExternalDataSourceList.
Adds client.transformations.external_data_sources with list, upsert,
delete and verify_usability against /transformations/externaldata, plus
the generated sync API, the docs accessor and the testing mocks.

The API is in public beta, so the methods emit a FeaturePreviewWarning.
Delete takes no ignore_unknown_ids as the endpoint accepts no fields
other than the items to delete.
Unit tests assert the wire format of each request and the parsing of
each response, including that delete sends nothing but the items and
that the usability request takes a flat external id.

The integration test runs a full upsert/list/verify/delete lifecycle
against a live Fabric lakehouse, and skips unless credentials for one
are present in the environment.
@Khyat-Cognite Khyat-Cognite self-assigned this Jul 31, 2026
@Khyat-Cognite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the TransformationExternalDataSourcesAPI (and its synchronous counterpart SyncTransformationExternalDataSourcesAPI) to manage external data sources available to transformations, such as Microsoft Fabric OneLake. It includes methods for listing, upserting, deleting, and verifying the usability of external data sources, along with comprehensive unit and integration tests, documentation updates, and testing mocks. I have no feedback to provide as there are no review comments.

Base automatically changed from feat/transformations-externaldata-models to master July 31, 2026 12:20
@Khyat-Cognite
Khyat-Cognite marked this pull request as ready for review August 3, 2026 02:46
@Khyat-Cognite
Khyat-Cognite requested review from a team as code owners August 3, 2026 02:46

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the TransformationExternalDataSourcesAPI (and its synchronous counterpart SyncTransformationExternalDataSourcesAPI) to manage external data sources available to transformations, such as Microsoft Fabric OneLake. It implements methods for listing, iterating, upserting, deleting, and verifying the usability of these data sources, along with corresponding unit and integration tests, mock support, and documentation updates. There are no review comments, and I have no additional feedback to provide.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.74%. Comparing base (d7806bd) to head (e504340).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...test_api/test_transformations/test_externaldata.py 42.85% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2732      +/-   ##
==========================================
- Coverage   93.77%   93.74%   -0.03%     
==========================================
  Files         509      513       +4     
  Lines       52252    52434     +182     
==========================================
+ Hits        48999    49156     +157     
- Misses       3253     3278      +25     
Files with missing lines Coverage Δ
cognite/client/_api/transformations/__init__.py 75.70% <100.00%> (+0.46%) ⬆️
...ognite/client/_api/transformations/externaldata.py 100.00% <100.00%> (ø)
cognite/client/_cognite_client.py 95.83% <100.00%> (+0.01%) ⬆️
...gnite/client/_sync_api/transformations/__init__.py 94.64% <100.00%> (+0.19%) ⬆️
...e/client/_sync_api/transformations/externaldata.py 100.00% <100.00%> (ø)
cognite/client/testing.py 100.00% <100.00%> (ø)
...nit/test_api/test_transformations_external_data.py 100.00% <100.00%> (ø)
tests/tests_unit/test_docstring_examples.py 100.00% <ø> (ø)
...test_api/test_transformations/test_externaldata.py 42.85% <42.85%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@haakonvt haakonvt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid! Just some minor stuff left:

Comment thread cognite/client/_api/transformations/externaldata.py Outdated
Comment thread cognite/client/_api/transformations/externaldata.py Outdated
Comment thread cognite/client/_api/transformations/externaldata.py Outdated
Comment thread cognite/client/_api/transformations/externaldata.py
Comment thread cognite/client/_api/transformations/externaldata.py
Comment thread cognite/client/_api/transformations/externaldata.py Outdated
Comment thread docs/source/transformations.rst
Comment thread tests/tests_integration/test_api/test_transformations/test_externaldata.py Outdated
…s API

Remove the class docstring to match sibling API classes, add missing
API docs links to list/upsert/delete/verify_usability, add a doc-only
upsert_mode kwarg to upsert to showcase replace semantics, clarify that
delete does not silently ignore unknown external IDs, switch to
os.getenv in the integration test, and add a TODO for wiring all of
Transformations into the docstring-example doctests.
@Khyat-Cognite
Khyat-Cognite requested a review from haakonvt August 7, 2026 08:08

@haakonvt haakonvt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Khyat-Cognite

Copy link
Copy Markdown
Contributor Author

🦄

@Khyat-Cognite
Khyat-Cognite added this pull request to the merge queue Aug 11, 2026
Merged via the queue into master with commit 60b6c36 Aug 11, 2026
24 checks passed
@Khyat-Cognite
Khyat-Cognite deleted the feat/transformations-externaldata-api branch August 11, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants