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

Checkout edits #249

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Checkout edits #249

wants to merge 11 commits into from

Conversation

kiihne-noaa
Copy link
Contributor

Describe your changes

Added logic to fre pp Checkout to account for branch changes

Issue ticket number and link (if applicable)

issue 174

@ceblanton
Copy link
Collaborator

ceblanton commented Nov 5, 2024

There are 4 logical pathways that we want for fre pp checkout.

It's cheating a little to do this, but git helpfully conflates branches and tags. So everywhere we use branch or tag, we should try to use "branch/tag" or "branch or tag".

  1. If --branch is not specified, and ~/cylc-src/NAME doesn't exist, then:

Determine the default tag, with fre --version.

Checkout that with git clone -b $tag

  1. If --branch is specified, and ~/cylc-src/NAME doesn't exist, then:

fre pp clone --branch=shield https://github.com/NOAA-GFDL/fre-workflows

Check out the requested branch/tag with git clone -b $user_request

  1. If --branch is not specified, and ~/cylc-src/NAME exists, then:

Determine the default tag, with fre --version

Determine the branch and tag of ~/cylc-src/NAME. If either match, then OK. If none match, then give an error with the mismatch.

You can get the branch of ~/cylc-src/NAME with git branch and the tag with git describe. e.g.

git clone https://github.com/NOAA-GFDL/fre-workflows -b 2024.01 my-workflows
Cloning into 'my-workflows'...
remote: Enumerating objects: 5680, done.
remote: Counting objects: 100% (450/450), done.
remote: Compressing objects: 100% (73/73), done.
remote: Total 5680 (delta 391), reused 410 (delta 365), pack-reused 5230 (from 1)
Receiving objects: 100% (5680/5680), 1.26 MiB | 5.88 MiB/s, done.
Resolving deltas: 100% (3136/3136), done.
Note: switching to '3d75b570fc39ad25f20dfbf450ed875ed754968d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Updating files: 100% (178/178), done.

(fre-test) c2b:~%>cd my-workflows
(fre-test) c2b:~/my-workflows%>git describe
2024.01
  1. If --branch is specified, and ~/cylc-src/NAME exists, then:

Verify that either the branch (git branch) or tag (git describe)

in ~/cylc-src/NAME matches the user request. If not, give the mismatch error.

@ceblanton
Copy link
Collaborator

I pip-installed your branch to give it a try on the 4 logical pathways, and it failed with a IndexError. Do you see this on your end?

(fre-test) c2b:~%>fre pp checkout -e myexp -p myplat -t mytar   
Traceback (most recent call last):
  File "/nbhome/fms/conda/envs/fre-test/bin/fre", line 10, in <module>
    sys.exit(fre())
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/c2b/.local/lib/python3.9/site-packages/fre/pp/frepp.py", line 125, in checkout
    context.forward(checkoutTemplate)
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 804, in forward
    return __self.invoke(__cmd, *args, **kwargs)
  File "/nbhome/fms/conda/envs/fre-test/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/c2b/.local/lib/python3.9/site-packages/fre/pp/checkoutScript.py", line 89, in checkoutTemplate
    return _checkoutTemplate(experiment, platform, target, branch)
  File "/home/c2b/.local/lib/python3.9/site-packages/fre/pp/checkoutScript.py", line 39, in _checkoutTemplate
    local_branch_name = branch_names.stdout.split()[1]
IndexError: list index out of range

@@ -0,0 +1 @@
__version__ = '2024.01'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this used? I think it makes sense to store the version here instead of setup.py, but want to avoid duplication.

Copy link
Member

Choose a reason for hiding this comment

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

i think the idea is to check the fre-cli version below with a pythonic approach, but i'm wondering if this idea is actually dead-on-arrival the more i think about it...

@singhd789 singhd789 requested review from singhd789 and removed request for singhd789 November 5, 2024 18:21
fre/pp/checkoutScript.py Outdated Show resolved Hide resolved
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.

3 participants