iterative / gto

🏷️ Git Tag Ops. Turn your Git repository into Artifact Registry or Model Registry.
https://dvc.org/doc/gto
Apache License 2.0
140 stars 16 forks source link

gto should not push on register without --push flag. #405

Closed tnjordan closed 1 year ago

tnjordan commented 1 year ago

The gto command has a --push flag which according to the docs will push a created tag.

--push - Push created tag automatically (experimental)

However, looking into the code the tag will automatically be pushed if the git repository has a remote.

This is unexpected as it is not a mentioned actions in the docs. I looked back into a older versions of gto (v0.3.5) and saw that there was similar logic, but found the logic to not be implemented/functional.

I have a github action that automatically increments the tag version when changes are pushed to a branch (prod).

name: Increment Tag Version
on:
  push:
    branches:
      - prod

jobs:
  tag-up:
    environment: ${{ github.ref_name }}
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
        with:
          token: ${{ secrets.<Personal Access Token>}}
          fetch-depth: 0

      - name: ⬆️ tag version ⬆️
        run: |
          pip install gto
          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          gto register pfc-irm HEAD --bump-patch

      - name: ✍ push tags ✍
        run: |
          git push origin --tags

This action was working with gto prior to the version 1 release. It now fails with the logs:

Created git tag '<model>@v1.0.11' that registers version
Running `git push origin <model>@v1.0.11`
❌ The command `git push origin <model>@v1.0.11` failed. Make sure your local 
repository is in sync with the remote.

I am not sure why the automatic gto register push is failing; however, I would suggest that the push only happens when the --push flag is provided. An additional --auto-push flag could be created that could cover the current behavior.

Alternatively pushing could be the default behavior and a --no-push flag could be provided to prevent pushing.

mnrozhkov commented 1 year ago

Thanks for reporting @tnjordan! I found out about this issue today as well.

shcheklein commented 1 year ago

I've confirmed that this is a bug. Fix is coming here https://github.com/iterative/gto/pull/417 . Sorry for the inconvenience folks. There was a lack of tests that made the last refactoring fragile a bit.

shcheklein commented 1 year ago

Should be fixed in the 1.3.0 that should be published today.