Skip to content

feat(transformations): add OneLake external data source data classes#2714

Draft
Khyat-Cognite wants to merge 23 commits into
masterfrom
feat/onelake-edc-data-model
Draft

feat(transformations): add OneLake external data source data classes#2714
Khyat-Cognite wants to merge 23 commits into
masterfrom
feat/onelake-edc-data-model

Conversation

@Khyat-Cognite

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

Copy link
Copy Markdown

CDF-28228

Summary

Slice 1 of 3 — splits PR #2713 into reviewable pieces.

This PR adds the data model layer for Fabric OneLake external data sources used by transformations. No client API or documentation yet.

What's in this PR

Production code

  • cognite/client/data_classes/transformations/external_data.py — read/write/list/usability models, OneLake credentials/settings, ExternalDataSourceWrite.onelake() factory
  • cognite/client/data_classes/__init__.py — public re-exports (ExternalDataSource, ExternalDataSourceWrite, OneLake*, etc.)
  • cognite/client/data_classes/capabilities.pyTransformationsExternalDataSourcesAcl (READ / WRITE / USE)

Tests (co-located)

  • tests/tests_unit/test_data_classes/test_transformations/test_external_data.py — serialization round-trips, onelake() factory, dump/load

Backend contract (jetfire)

Registers credentials for transform SQL: ext_onelake('external_id', 'table'[, 'schema'])

Endpoint Method ACL
/transformations/external_data GET list, POST upsert (201) READ / WRITE
/transformations/external_data/delete POST WRITE
/transformations/external_data/usability POST USE

What comes next

PR Branch Scope
2 — Client API feat/onelake-edc-api client.transformations.external_data_sources (list, upsert, delete, verify_usability), sync codegen, mocks, API unit + integration tests
3 — Docs feat/onelake-edc-docs transformations_external_data.rst, toctree link

Merge this PR first, then review PR 2 (stacked on this branch).

Test plan

  • pytest tests/tests_unit/test_data_classes/test_transformations/test_external_data.py
  • lint / test_core CI green

Parent

Replaces the data-model portion of #2713. Close #2713 after all three slices are merged to master.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.61390% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.68%. Comparing base (7d5e3df) to head (41b1cba).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ient/data_classes/transformations/external_data.py 99.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2714      +/-   ##
==========================================
- Coverage   93.70%   93.68%   -0.03%     
==========================================
  Files         504      506       +2     
  Lines       51120    51368     +248     
==========================================
+ Hits        47904    48125     +221     
- Misses       3216     3243      +27     
Files with missing lines Coverage Δ
cognite/client/data_classes/capabilities.py 96.99% <100.00%> (+0.03%) ⬆️
...te/client/data_classes/transformations/__init__.py 85.76% <100.00%> (+0.05%) ⬆️
tests/tests_unit/test_base.py 98.97% <100.00%> (+0.03%) ⬆️
.../tests_unit/test_data_classes/test_capabilities.py 100.00% <ø> (ø)
...classes/test_transformations/test_external_data.py 100.00% <100.00%> (ø)
...ient/data_classes/transformations/external_data.py 99.36% <99.36%> (ø)

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

Add read/write/list/usability data classes for Fabric OneLake external
data sources, public re-exports, IAM capability helper, and unit tests
for serialization round-trips.
The external data source exports accidentally dropped MeteringData from
the public data_classes surface and added an unrelated RecordId export.
Replace the date-expired authlib/cryptography shim with a Pyodide
version check so stlite's 0.26.2 job keeps working.
@Khyat-Cognite
Khyat-Cognite force-pushed the feat/onelake-edc-data-model branch from 98e71c4 to ad1e459 Compare July 9, 2026 08:53
@Khyat-Cognite
Khyat-Cognite requested a review from a team July 9, 2026 08:59
@Khyat-Cognite
Khyat-Cognite marked this pull request as ready for review July 9, 2026 09:18
@Khyat-Cognite
Khyat-Cognite requested review from a team as code owners July 9, 2026 09:18

@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 support for Fabric OneLake external data sources in transformations, adding new data classes, ACL capabilities, and corresponding unit tests. The feedback focuses on reducing boilerplate and aligning with the style guide by removing redundant custom dump methods on several data classes, simplifying others using super().dump(), and removing manual load/dump unit tests that are already covered automatically by the SDK's base test suite.

Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py
Comment thread cognite/client/data_classes/transformations/external_data.py
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread tests/tests_unit/test_data_classes/test_transformations/test_external_data.py Outdated
Drop redundant custom dump implementations on simple OneLake credential and
usability classes, use super().dump() on source models, and remove manual
load/dump unit tests covered by test_base.py per style guide.
@Khyat-Cognite

Khyat-Cognite commented Jul 9, 2026

Copy link
Copy Markdown
Author

All gemini fixes were applied -- it was right lot of redundancy.

@Khyat-Cognite Khyat-Cognite self-assigned this Jul 9, 2026
@Khyat-Cognite

Copy link
Copy Markdown
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 adds support for Fabric OneLake external data sources in transformations, including new data classes, capabilities, and unit tests. It also refactors a temporary Pyodide workaround in test-pyodide.js to use a version-based check. The feedback suggests using parseInt instead of Number when parsing Pyodide version components to robustly handle pre-release or development versions containing non-numeric characters.

Comment thread scripts/test-pyodide.js
…arse

*Write classes are CDF upsert models, not lakehouse write APIs.
Use parseInt for Pyodide version components per Gemini review.
@karthikeyanraghavan

Copy link
Copy Markdown

/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 support for Fabric OneLake external data sources in transformations, adding the necessary data classes, capabilities, and unit tests. I have no feedback to provide.

@karthikeyanraghavan karthikeyanraghavan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. This PR contains only new data models for zero copy enhancements to transformations.

Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Rename OneLakeCredentialsRead and OneLakeDataSourceSettingsRead to match
SDK convention where read models have no suffix and write models use Write.

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

@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.

Did an initial pass, but did not make it all the way through. You can save a lot of walruses by checking out the load_if method.

Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Khyat-Cognite and others added 2 commits July 15, 2026 16:21
Co-authored-by: Håkon V. Treider <haakonvt@gmail.com>
Co-authored-by: Håkon V. Treider <haakonvt@gmail.com>
Khyat-Cognite and others added 3 commits July 15, 2026 16:22
Co-authored-by: Håkon V. Treider <haakonvt@gmail.com>
…odels

Use _load_if, tighten client_secret handling, redact str/repr, and require
client_secret when converting read credentials via as_write().

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Returns sections and single-line Args formatting expected by pydoclint
and the custom docstring checker.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Khyat-Cognite
Khyat-Cognite requested a review from haakonvt July 15, 2026 11:08
Khyat-Cognite and others added 2 commits July 15, 2026 16:54
ExternalDataSource.as_write requires client_secret when the read model
includes credentials; update generic writable tests accordingly.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use isinstance narrowing so client_secret is only passed on the concrete
ExternalDataSource types, not WriteableCogniteResource.

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

@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.

A few more comments, mostly lgtm, but let's revisit the onelake classmethod (feel free to bring the discussion to slack!)

Comment thread cognite/client/data_classes/capabilities.py
Comment thread cognite/client/data_classes/__init__.py
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread tests/tests_unit/test_data_classes/test_transformations/test_external_data.py Outdated
Comment thread tests/tests_unit/test_base.py Outdated
Khyat-Cognite and others added 2 commits July 16, 2026 13:47
Add OneLakeExternalDataSource(Write) subclasses, export from
transformations package only, register ACL in capability tests, and
trim redundant dump tests per SDK conventions.

Co-authored-by: Cursor <cursoragent@cursor.com>
Single import block with noqa F401; avoids ruff isort splitting as-aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Khyat-Cognite
Khyat-Cognite requested a review from haakonvt July 16, 2026 08:31
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Khyat-Cognite and others added 2 commits July 16, 2026 14:17
Return UnknownExternalDataSource for unsupported formats, require format
on load per jetfire contract, and flatten ExternalDataSourceCore away.

Co-authored-by: Cursor <cursoragent@cursor.com>
ExternalDataSource is now format-agnostic; settings and as_write() live
on OneLakeExternalDataSource. UnknownExternalDataSource has no typed
settings. Write base drops settings; OneLakeExternalDataSourceWrite
owns format-specific dump/upsert shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Khyat-Cognite
Khyat-Cognite requested a review from haakonvt July 16, 2026 09:02
@Khyat-Cognite

Copy link
Copy Markdown
Author

Ahh... Will fix lint

Annotate optional settings on OneLakeExternalDataSourceWrite, cast _load
dispatch return, and narrow test_base list/as_write helpers for mypy.

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

Copy link
Copy Markdown
Author

Ahh... Will fix lint

@haakonvt final final round?

Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
Use explicit base return type instead of Self when delegating to format
subclasses, satisfying mypy on polymorphic _load.
Comment thread cognite/client/data_classes/transformations/external_data.py Outdated
…eturn

as_write always raises ValueError for unknown formats; NoReturn makes the
contract explicit to mypy.
Comment thread tests/tests_unit/test_base.py Outdated
Comment thread tests/tests_unit/test_base.py Outdated
Make ExternalDataSource an ABC so test_base skips it. Fold partial
settings into OneLakeExternalDataSourceWrite.__init__ and remove the
__new__/with_settings factory. Revert unrelated FileMetadataList loop
change; mypy ignore documents the list-item union only.
@Khyat-Cognite
Khyat-Cognite requested a review from haakonvt July 16, 2026 10:00
Drop flat credential/location kwargs from __init__; callers pass
OneLakeDataSourceSettingsWrite, matching the read model and API shape.
@Khyat-Cognite
Khyat-Cognite marked this pull request as draft July 16, 2026 11:45
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.

4 participants