-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: main
Are you sure you want to change the base?
Checkout edits #249
Conversation
syntax fixed on line 36
switched to checking out tag 2024.01
…i into checkout_edits
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".
Determine the default tag, with Checkout that with
fre pp clone --branch=shield https://github.com/NOAA-GFDL/fre-workflows Check out the requested branch/tag with
Determine the default tag, with 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
Verify that either the branch ( in ~/cylc-src/NAME matches the user request. If not, give the mismatch error. |
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?
|
@@ -0,0 +1 @@ | |||
__version__ = '2024.01' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
you'll wanna peek at the click argument default values as well |
fre/pp/checkoutScript.py
Outdated
if os.path.isdir(name): #scenario 4 | ||
os.chdir(name) | ||
name_path_tag=subprocess.run(["git","describe","--tags"],capture_output=True, text=True).stdout | ||
name_path_branch=subprocess.run(["git","branch"],capture_output=True, text=True).stdout.split()[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about the split()[1] here.. is it safe and will it always be the second member?
git branch
gives a lot of output. e.g.
(docs) c2b:~/git/fre-cli%>git branch
204-improve-fre-cmor-run-functionality
CMORPytestUpdates
catalog-merge
checkout_edits
* docs
main
update-docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I experimented locally, I always saw it give * branch_name as the first entry. But if its different on different places, I can generalize so it splits at *, and then splits the original way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am implementing changes to generalize this. When working locally, I only ever saw * current_branch' as the top item. But for other scenarios, new push should fix that.
sys.exit(stop_report) | ||
return 1 | ||
# branch and version parameters | ||
default_tag = subprocess.run(["fre","--version"],capture_output=True, text=True).stdout.split()[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tag retrieved from fre --version
has a one digit month but the fre-workflows (and fre-cli) tags are two-digit month. So this
c2b:~%>fre --version
fre-cli | 2024.1
needs to be expanded to 2024.01
to be used as a tag for fre-workflows.
fre/pp/checkoutScript.py
Outdated
@@ -20,7 +20,7 @@ | |||
|
|||
############################################# | |||
|
|||
def _checkoutTemplate(experiment, platform, target): | |||
def _checkoutTemplate(experiment, platform, target, branch='empty'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me (as a not-quite python person), but it might be more pythonic to set the default to be None
. (We can always improve it later)
def _checkoutTemplate(experiment, platform, target, branch=None):
fre/pp/checkoutScript.py
Outdated
sys.exit(stop_report) | ||
return 1 | ||
else: #scenario 1 | ||
subprocess.run(f'git checkout tags/{default_tags}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want a git clone
here instead, just like the one above.
git clone --branch={default_tag} https://github.com/NOAA-GFDL/fre-cli.git
fre/pp/checkoutScript.py
Outdated
@@ -36,11 +36,12 @@ def _checkoutTemplate(experiment, platform, target, branch='empty'): | |||
|
|||
# branch and version parameters | |||
default_tag = subprocess.run(["fre","--version"],capture_output=True, text=True).stdout.split()[2] | |||
if branch != 'empty': | |||
if branch == None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: branch is None
instead of branch == None
Describe your changes
Added logic to fre pp Checkout to account for branch changes
Issue ticket number and link (if applicable)
issue 174