Skip to content

Add datasource copy API - #719

Merged
guysmoilov merged 2 commits into
mainfrom
codex/copy-datasource
Sep 2, 2026
Merged

Add datasource copy API#719
guysmoilov merged 2 commits into
mainfrom
codex/copy-datasource

Conversation

@guysmoilov

Copy link
Copy Markdown
Member

Summary

  • add public helpers for copying a datasource and its current query
  • return the copied datasource so callers can wait for asynchronous processing
  • expose generic copy-origin metadata returned by the API

Testing

  • .venv/bin/python -m pytest tests/data_engine/test_datasource.py

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 40a9a953-021f-43cb-a085-1c9f29f8d35a

📥 Commits

Reviewing files that changed from the base of the PR and between 0278a09 and af06b68.

📒 Files selected for processing (3)
  • dagshub/data_engine/client/gql_mutations.py
  • dagshub/data_engine/model/datasource_state.py
  • tests/data_engine/test_datasource.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • dagshub/data_engine/model/datasource_state.py
  • dagshub/data_engine/client/gql_mutations.py
  • tests/data_engine/test_datasource.py

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)

📝 Walkthrough

Walkthrough

The PR adds asynchronous datasource copying. It serializes the source query, submits a GraphQL copy mutation, returns the copied datasource, and preserves origin metadata in client models and datasource state. Tests verify origin preservation during refresh.

Changes

Datasource copy workflow

Layer / File(s) Summary
Copy result contract
dagshub/data_engine/client/models.py, dagshub/data_engine/model/datasource_state.py
Adds DatasourceOriginResult, makes metadataFields optional, and stores origin metadata in DatasourceState.
GraphQL copy operation
dagshub/data_engine/client/gql_mutations.py, dagshub/data_engine/client/data_client.py
Builds and executes the copy mutation with the source ID, name, and serialized query.
Public datasource copy API
dagshub/data_engine/model/datasource.py, dagshub/data_engine/datasources.py
Adds instance and module-level copy helpers for asynchronous datasource creation.
Origin preservation and validation
dagshub/data_engine/model/datasource_state.py, tests/data_engine/test_datasource.py
Preserves existing origin metadata when refresh results omit it. The regression test verifies this behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to af06b

The PR adds datasource-copy helpers and related metadata while returning the copied datasource for asynchronous processing; no actionable merge-blocking risk remains based on the supplied evidence.

Sequence Diagram(s)

sequenceDiagram
  participant Datasource
  participant DataClient
  participant GraphQLAPI
  Datasource->>DataClient: Submit source ID, name, and serialized query
  DataClient->>GraphQLAPI: Execute copy_datasource mutation
  GraphQLAPI-->>DataClient: Return copied datasource result and origin
  DataClient-->>Datasource: Construct copied Datasource
Loading

Poem

A rabbit copies queries bright
A new datasource hops in sight
Its origin stays close behind
With status and name neatly aligned
The GraphQL path runs swift and clear

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding a datasource copy API.
Description check ✅ Passed The description directly summarizes the datasource copy helpers, asynchronous processing behavior, origin metadata, and test command.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/copy-datasource

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5b27c034-d0e4-46a6-a682-969303c013f8

📥 Commits

Reviewing files that changed from the base of the PR and between 733227f and 0278a09.

📒 Files selected for processing (7)
  • dagshub/data_engine/client/data_client.py
  • dagshub/data_engine/client/gql_mutations.py
  • dagshub/data_engine/client/models.py
  • dagshub/data_engine/datasources.py
  • dagshub/data_engine/model/datasource.py
  • dagshub/data_engine/model/datasource_state.py
  • tests/data_engine/test_datasource.py

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📜 Review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.13)
  • GitHub Check: Build documentation
⚠️ CI failures not shown inline (1)

GitHub Check: Flake8: 1 error

Conclusion: failure

View job details

Flake8 found 1 error
🧰 Additional context used
🪛 GitHub Check: Flake8
dagshub/data_engine/client/gql_mutations.py

[failure] 194-194: dagshub/data_engine/client/gql_mutations.py#L194
Line too long (125 > 120 characters) (E501)

🔇 Additional comments (3)
dagshub/data_engine/client/models.py (1)

104-115: LGTM!

Also applies to: 124-125

dagshub/data_engine/model/datasource_state.py (1)

10-16: LGTM!

Also applies to: 52-52, 225-225

tests/data_engine/test_datasource.py (1)

14-21: LGTM!

Also applies to: 64-93

Comment thread dagshub/data_engine/client/gql_mutations.py Outdated
Comment thread dagshub/data_engine/model/datasource.py
@guysmoilov guysmoilov self-assigned this Aug 30, 2026
@guysmoilov guysmoilov added the enhancement New feature or request label Aug 30, 2026
@guysmoilov
guysmoilov merged commit dcb4b4e into main Sep 2, 2026
12 checks passed
@guysmoilov
guysmoilov deleted the codex/copy-datasource branch September 2, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant