dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.74k stars 504 forks source link

Support `dolt checkout` by commit hash or tag name also known as detached head #2464

Open addisonklinke opened 2 years ago

addisonklinke commented 2 years ago

This functionality is present in git but not yet with dolt, i.e.

dolt checkout 39mg263d
dolt checkout myTag
timsehn commented 2 years ago

You can do hash but not short hash.

On Mon, Dec 6, 2021 at 12:53 PM Addison Klinke @.***> wrote:

This functionality is present in git but not yet with dolt, i.e.

dolt checkout 39mg263d dolt checkout myTag

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dolthub/dolt/issues/2464, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJAR3GDJCXLL4XOLADGDT3UPUPF3ANCNFSM5JPS3ZNA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

andy-wm-arthur commented 2 years ago

@addisonklinke Dolt doesn't support "detached head" currently, so it's not possible to checkout commits that are not referenced by a branch.

Could you let us know a bit more about your use case for checking out tags and commit hashes? If you want to inspect the data at a given hash you can use Dolt's AS OF syntax:

SELECT FROM myTable AS OF "39mg263d"
addisonklinke commented 2 years ago

@andrew-wm-arthur I would plan to checkout tags and/or commit hashes in an ML scenario where I want to train on a particular dataset version (or a commit that a colleague used). As a Python-oriented engineer, I find it more natural to do this from the CLI or Python API with dolt checkout rather than going into SQL and using AS OF

From the updated docs it looks like detached head mode is supported now. If so, does that provide all the core features needed to complete this request?

timsehn commented 2 years ago

Detached HEAD on the CLI is not something we plan on supporting in the near future. In SQL mode, we support detached heads.

radao commented 1 year ago

@timsehn is this still something thats not planned to be supported? I agree with @addisonklinke that it would be useful to checkout a commit hash or tag from a detached head to simplify the logic in ML training pipelines.

Additionally, it's not clear how to reference Releases created on DoltHub in a local Dolt repo. You can see the full hash of the release on DoltHub, but these aren't loaded as tags or anything in a local checkout.

timsehn commented 1 year ago

@timsehn is this still something thats not planned to be supported? I agree with @addisonklinke that it would be useful to checkout a commit hash or tag from a detached head to simplify the logic in ML training pipelines.

This is planned. I don't think I ever said it was not planned. We just have not got around to it.

Additionally, it's not clear how to reference Releases created on DoltHub in a local Dolt repo. You can see the full hash of the release on DoltHub, but these aren't loaded as tags or anything in a local checkout.

So releases show up as tags locally. Here's a workflow to get access to a tag without detached head. You just make a branch at the reference indicated by the tag.

PS C:\Users\timse\dolthub\dolt> dolt clone dolthub/us-jails
cloning https://doltremoteapi.dolthub.com/dolthub/us-jails
PS C:\Users\timse\dolthub\dolt> cd us-jails
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag
        _migrationtest
PS C:\Users\timse\dolthub\dolt\us-jails> dolt checkout -b release-branch _migrationtest
Switched to branch 'release-branch'
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag -v
_migrationtest  i3f3orlfmbjgqnst90c8r96jps7tdtv9
Tagger: andy <andy@dolthub.com>
Date:   Fri Jul 29 08:27:37 -0700 2022

        savepoint for migration testing

PS C:\Users\timse\dolthub\dolt\us-jails> dolt branch -va
  main                                                  i3f3orlfmbjgqnst90c8r96jps7tdtv9
* release-branch                                        i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/main                                   i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/spacelove/docs-1654809848              5unofrovlp90drn0uh13louv5551tk95
  remotes/origin/spacelove/workspace-1650463967         405hm744g48scb9cp778ul1uld0sm448
  remotes/origin/spacelove/workspace-1650464366         1clf17r2n0rcllcttaof2rfngse61cjc
radao commented 1 year ago

@timsehn is this still something thats not planned to be supported? I agree with @addisonklinke that it would be useful to checkout a commit hash or tag from a detached head to simplify the logic in ML training pipelines.

This is planned. I don't think I ever said it was not planned. We just have not got around to it.

Understood, thanks!

Additionally, it's not clear how to reference Releases created on DoltHub in a local Dolt repo. You can see the full hash of the release on DoltHub, but these aren't loaded as tags or anything in a local checkout.

So releases show up as tags locally. Here's a workflow to get access to a tag without detached head. You just make a branch at the reference indicated by the tag.

PS C:\Users\timse\dolthub\dolt> dolt clone dolthub/us-jails
cloning https://doltremoteapi.dolthub.com/dolthub/us-jails
PS C:\Users\timse\dolthub\dolt> cd us-jails
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag
        _migrationtest
PS C:\Users\timse\dolthub\dolt\us-jails> dolt checkout -b release-branch _migrationtest
Switched to branch 'release-branch'
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag -v
_migrationtest  i3f3orlfmbjgqnst90c8r96jps7tdtv9
Tagger: andy <andy@dolthub.com>
Date:   Fri Jul 29 08:27:37 -0700 2022

        savepoint for migration testing

PS C:\Users\timse\dolthub\dolt\us-jails> dolt branch -va
  main                                                  i3f3orlfmbjgqnst90c8r96jps7tdtv9
* release-branch                                        i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/main                                   i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/spacelove/docs-1654809848              5unofrovlp90drn0uh13louv5551tk95
  remotes/origin/spacelove/workspace-1650463967         405hm744g48scb9cp778ul1uld0sm448
  remotes/origin/spacelove/workspace-1650464366         1clf17r2n0rcllcttaof2rfngse61cjc

Works for me, thanks for the example!

nkonev commented 1 year ago

+1 also bumped into this


I found a workaround

SELECT p.* FROM `companies/tag_start_36c7c702-185f-4f4b-a700-12c7f1f943b0`.company_profile p  limit 100;

-- or
USE `companies/tag_start_36c7c702-185f-4f4b-a700-12c7f1f943b0`;
SELECT t.*
FROM companies.company_profile t
LIMIT 501;
timsehn commented 1 year ago

This might be easier to do now that we have dolt stash.

https://github.com/dolthub/dolt/issues/573