Skip to content

feat(transformations): add Fabric OneLake external data sources API#2713

Draft
Khyat-Cognite wants to merge 5 commits into
masterfrom
feat/onelake-external-data-sources
Draft

feat(transformations): add Fabric OneLake external data sources API#2713
Khyat-Cognite wants to merge 5 commits into
masterfrom
feat/onelake-external-data-sources

Conversation

@Khyat-Cognite

Copy link
Copy Markdown

Summary

  • Adds client.transformations.external_data_sources sub-resource with upsert(), list(), delete(), and verify_usability() methods
  • OneLake is read-only — transforms read FROM OneLake via ext_onelake() SQL; writing to OneLake is not supported
  • Follows the existing schedules/notifications sub-resource pattern: Core/Read/Write data class hierarchy, WriteList companion, sync wrapper, autospec mock support
  • Adds TransformationsExternalDataSourcesAcl (READ/WRITE actions) to capabilities

New public surface

from cognite.client.data_classes.transformations.external_data import ExternalDataSourceWrite

source = ExternalDataSourceWrite.onelake(
    external_id="fabric-lakehouse-prod",
    client_id="<azure-app-id>",
    tenant_id="<azure-tenant-uuid>",
    client_secret="<secret>",
    workspace_name="<fabric-workspace-guid>",
    container_name="<fabric-lakehouse-guid>",
)
client.transformations.external_data_sources.upsert(source)
result = client.transformations.external_data_sources.verify_usability("fabric-lakehouse-prod")
sources = client.transformations.external_data_sources.list()
client.transformations.external_data_sources.delete("fabric-lakehouse-prod")

Files changed

  • cognite/client/data_classes/transformations/external_data.py — new data classes
  • cognite/client/_api/transformations/external_data.py — async API
  • cognite/client/_sync_api/transformations/external_data.py — sync wrapper
  • cognite/client/data_classes/capabilities.pyTransformationsExternalDataSourcesAcl
  • cognite/client/testing.py — mock spec for both async and sync clients
  • docs/source/transformations_external_data.rst — Sphinx docs
  • Unit tests (data class serialization + API calls with HTTPXMock)
  • Integration tests (local-only, skip in CI when jetfire .env is absent)

Test plan

  • Run unit tests: pytest tests/tests_unit/test_data_classes/test_transformations/test_external_data.py tests/tests_unit/test_api/test_transformation_external_data.py -v
  • Verify imports: python -c "from cognite.client.data_classes import ExternalDataSource, ExternalDataSourceWrite"
  • Verify mock: python -c "from cognite.client.testing import CogniteClientMock; m = CogniteClientMock(); print(m.transformations.external_data_sources)"
  • Verify capability: python -c "from cognite.client.data_classes.capabilities import TransformationsExternalDataSourcesAcl"
  • Local integration test (requires work/jetfire-backend/.env): pytest tests/tests_integration/test_api/test_transformations/test_external_data.py -v

Notes

  • Integration tests are local-only in v1 — they skip automatically when work/jetfire-backend/.env is absent. Adding Fabric credentials to SDK CI secrets is future work.
  • dataSetId vs datasetId casing should be verified at integration test time (see architecture notes in the implementation).
  • _capability_name = "transformationsExternalDataSourcesAcl" should be verified against the backend IAM configuration.
  • Sync wrapper is hand-written (sync codegen requires poetry/ruff unavailable locally).

Adds client.transformations.external_data_sources as a new sub-resource
under TransformationsAPI, enabling users to register, list, verify, and
delete Fabric OneLake external data sources for use in transforms.

OneLake sources are read-only — transforms read from OneLake tables via
ext_onelake() SQL but writing back to OneLake is not supported.

New public surface:
- ExternalDataSourceWrite.onelake() factory for creating sources
- client.transformations.external_data_sources.upsert()
- client.transformations.external_data_sources.list()
- client.transformations.external_data_sources.delete()
- client.transformations.external_data_sources.verify_usability()
- TransformationsExternalDataSourcesAcl capability class (READ/WRITE)

Implementation follows the existing schedules/notifications sub-resource
pattern: three-layer Core/Read/Write data class hierarchy, WriteList
companion, sync wrapper generated from the async API, and autospec mock
support in CogniteClientMock.

Integration tests are local-only (require work/jetfire-backend/.env with
Fabric credentials) and skip automatically in CI.
@Khyat-Cognite Khyat-Cognite self-assigned this Jul 9, 2026
Khyat-Cognite and others added 3 commits July 9, 2026 09:42
…ourcesAcl

The /usability endpoint requires USE ACL on the backend — grants Spark
driver access to verify credentials without granting full WRITE.
Align sync codegen hashes, docs stubs, list mixins, and HTTP mocks with
jetfire external_data API behavior; fix Fabric integration env var names.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove unpublished api-docs URLs from docstrings, apply ruff formatting,
reorder data class exports, and refresh sync codegen hash.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.69834% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.61%. Comparing base (6904cd7) to head (0af324f).
⚠️ Report is 43 commits behind head on master.

Files with missing lines Patch % Lines
...est_api/test_transformations/test_external_data.py 39.58% 29 Missing ⚠️
...ient/data_classes/transformations/external_data.py 86.69% 27 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2713      +/-   ##
==========================================
+ Coverage   93.09%   93.61%   +0.52%     
==========================================
  Files         490      509      +19     
  Lines       49869    51509    +1640     
==========================================
+ Hits        46424    48220    +1796     
+ Misses       3445     3289     -156     
Files with missing lines Coverage Δ
cognite/client/_api/transformations/__init__.py 75.70% <100.00%> (+0.46%) ⬆️
...gnite/client/_api/transformations/external_data.py 100.00% <100.00%> (ø)
cognite/client/_cognite_client.py 95.83% <100.00%> (+0.14%) ⬆️
...gnite/client/_sync_api/transformations/__init__.py 94.64% <100.00%> (+0.19%) ⬆️
.../client/_sync_api/transformations/external_data.py 100.00% <100.00%> (ø)
cognite/client/data_classes/__init__.py 100.00% <100.00%> (ø)
cognite/client/data_classes/capabilities.py 96.99% <100.00%> (+0.03%) ⬆️
cognite/client/testing.py 100.00% <100.00%> (ø)
...unit/test_api/test_transformation_external_data.py 100.00% <100.00%> (ø)
...classes/test_transformations/test_external_data.py 100.00% <100.00%> (ø)
... and 2 more

... and 71 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.

External data classes are documented on transformations_external_data.rst;
keeping the automodule in transformations.rst caused 23 Sphinx duplicate
object warnings that fail linkcheck.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant