Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using version uuid in datachain pull #621

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

ilongin
Copy link
Contributor

@ilongin ilongin commented Nov 25, 2024

In this PR we are changing the way to find if the same local dataset already exists when pulling remote dataset from Studio or not. Before we were using name + version combination which is not stable (as commented by Matt here) as someone could have local dataset with the same name and version as remote one, but with totally different data which would lead to not pulling the remote one. Also, someone could pull remote dataset and then rename it which would lead to pulling remote dataset again on another pull.

Now, instead of name + version combination we use uuid which is uniquely identifying specific dataset (version).
If local dataset version with same uuid as remote one already exists, regardless of the name or version mismatch, it is not pulled again.

Also, optional parameters local-name and local-version are added to CLI of dataset pull to specify the name / version of local dataset to which we want to pull remote one. This is needed in the case if local dataset with same name + version already exists with different data, but we still want to pull remote one - in that case use can enter alternative name or version or both.

@ilongin ilongin linked an issue Nov 25, 2024 that may be closed by this pull request
Copy link

cloudflare-workers-and-pages bot commented Nov 25, 2024

Deploying datachain-documentation with  Cloudflare Pages  Cloudflare Pages

Latest commit: 80b64ce
Status: ✅  Deploy successful!
Preview URL: https://c47cefce.datachain-documentation.pages.dev
Branch Preview URL: https://ilongin-602-use-uuid-datacha.datachain-documentation.pages.dev

View logs

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.71%. Comparing base (be41789) to head (80b64ce).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/datachain/dataset.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #621      +/-   ##
==========================================
- Coverage   87.73%   87.71%   -0.03%     
==========================================
  Files         112      112              
  Lines       10675    10694      +19     
  Branches     1437     1439       +2     
==========================================
+ Hits         9366     9380      +14     
- Misses        950      954       +4     
- Partials      359      360       +1     
Flag Coverage Δ
datachain 87.65% <96.66%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ilongin ilongin requested a review from a team November 25, 2024 14:06
@@ -170,7 +174,7 @@ def check_for_status(self) -> None:
Checks are done every PULL_DATASET_CHECK_STATUS_INTERVAL seconds
"""
export_status_response = self.studio_client.dataset_export_status(
self.dataset_name, self.dataset_version
self.remote_ds_name, self.remote_ds_version
Copy link
Member

Choose a reason for hiding this comment

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

[Q] Why not use uuid instead of remote_ds_name + remote_ds_version & local_ds_name + local_ds_version?

Copy link
Contributor Author

@ilongin ilongin Nov 25, 2024

Choose a reason for hiding this comment

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

Yea, there are other APIs that use name + version as well, but I would leave that to followup issue not to bloat this one too much.
In general, user does use explicit name and version when initiating pull, e.g datachain pull ds://dogs@v3 but the use of uuid in the process after initial get dataset info would fix potential issue of someone renaming remote dataset right in the middle of pull process (not sue how likely is this to happen but it's still the potential risk)

Copy link
Member

Choose a reason for hiding this comment

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

None of this needs to go into this PR but I wanted to mention it and this seems like an ok place.

I would advocate for hiding local/remote name/version from users as much as possible. (From experience) I think the concept will only confuse users. Only exposing it when we absolutely need to makes sense to me

For example:

If the user tries to pull cat@v1 under the following circumstances we should throw an error stating there is a dataset with that name already and the uuid doesn't match. Ask them to rename the local dataset (as SaaS is the source of truth):

name version uuid local remote
cat 1 cf308a6b-0e66-477f-ba76-9c3f8ffd27fe X
cat 1 d1c1ac59-5763-4069-a328-8292ec6a6205 X

I think we should update the output of ls datasets to have the same format as the above or at least give it the ability to show these discrepancies somehow.

I am now second-guessing myself and wondering whether the local/remote name and version are that bad.

Copy link
Contributor Author

@ilongin ilongin Nov 28, 2024

Choose a reason for hiding this comment

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

That's how it works in this PR:

  1. If local dataset with same uuid exists -> skip pulling and printing "Local copy of dataset cats@v1 already present". If it has different name locally it says "Local copy of dataset cats@v1 already present as dataset other_cats@v5"
  2. If we don't find local dataset with same uuid and there is already local dataset name + version present that holds completely different data we throw error with message "Local dataset cats@v1 already exists, please choose different local dataset name or version"

I didn't want to mention uuid anywhere as I'm not sure yet if that's something we should bother user with, but maybe I could enhance message from 2) by mentioning it ... "

EDIT: Changed it to "Local dataset cats@v1 already exists with different uuid, please choose different local dataset name or version"

remote_ds_version = remote_ds.get_version(version)
except (DatasetVersionNotFoundError, StopIteration) as exc:
raise DataChainError(
f"Dataset {remote_ds_name} doesn't have version {version}" " on server"
Copy link
Member

Choose a reason for hiding this comment

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

[C] Should be a single string

@@ -400,6 +400,18 @@ def get_parser() -> ArgumentParser: # noqa: PLR0915
"--edatachain-file",
help="Use a different filename for the resulting .edatachain file",
)
parse_pull.add_argument(
Copy link
Member

Choose a reason for hiding this comment

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

[C] I still don't know if it is better to expose these or uuid to the user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should let client work with name / version. uuid is not really practical, and also user cannot really set it.

@ilongin ilongin merged commit 045f3b0 into main Nov 29, 2024
38 checks passed
@ilongin ilongin deleted the ilongin/602-use-uuid-datachain-pull branch November 29, 2024 10:30
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.

Use uuid to identify if dataset exists locally on datachain pull
2 participants