From e063d85868d439378c84df1fca729364dd884f62 Mon Sep 17 00:00:00 2001 From: Avery Kiihne Date: Wed, 2 Oct 2024 14:55:11 -0400 Subject: [PATCH 1/9] checkout updated for issue #174 --- fre/pp/checkoutScript.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 5095a52c..1f06f73b 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -17,7 +17,7 @@ ############################################# -def _checkoutTemplate(experiment, platform, target, branch='main'): +def _checkoutTemplate(experiment, platform, target, branch='main',forced='off'): """ Checkout the workflow template files from the repo """ @@ -31,6 +31,15 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): # Set the name of the directory name = f"{experiment}__{platform}__{target}" + #check if version of branch is correct + branch_status=subprocess.check_output(['git','status']) + if str(branch_test).find('Your branch is up to date') < 0 and forced == 'off': + branch_error = ( + "Error in checkoutTemplate: Branch not up to date\n" + f"Turn paramter forced on to run without branches matching") + sys.exit(branch_error) + return 0 + # Clone the repository with depth=1; check for errors click.echo("cloning experiment into directory " + directory + "/" + name) clonecmd = ( From 6e701aab8f1e55f18f8ea6e0a531bc6fae47957c Mon Sep 17 00:00:00 2001 From: kiihne-noaa Date: Wed, 9 Oct 2024 09:54:12 -0400 Subject: [PATCH 2/9] Update checkoutScript.py syntax fixed on line 36 --- fre/pp/checkoutScript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 1f06f73b..55b863e4 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -33,7 +33,7 @@ def _checkoutTemplate(experiment, platform, target, branch='main',forced='off'): #check if version of branch is correct branch_status=subprocess.check_output(['git','status']) - if str(branch_test).find('Your branch is up to date') < 0 and forced == 'off': + if str(branch_status).find('Your branch is up to date') < 0 and forced == 'off': branch_error = ( "Error in checkoutTemplate: Branch not up to date\n" f"Turn paramter forced on to run without branches matching") From b9c9d01b0e923df5e45496c70a01aed3007d79b0 Mon Sep 17 00:00:00 2001 From: kiihne-noaa Date: Thu, 10 Oct 2024 15:20:41 -0400 Subject: [PATCH 3/9] Update checkoutScript.py switched to checking out tag 2024.01 --- fre/pp/checkoutScript.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 55b863e4..01017fae 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -17,7 +17,7 @@ ############################################# -def _checkoutTemplate(experiment, platform, target, branch='main',forced='off'): +def _checkoutTemplate(experiment, platform, target, branch='main'): """ Checkout the workflow template files from the repo """ @@ -31,19 +31,11 @@ def _checkoutTemplate(experiment, platform, target, branch='main',forced='off'): # Set the name of the directory name = f"{experiment}__{platform}__{target}" - #check if version of branch is correct - branch_status=subprocess.check_output(['git','status']) - if str(branch_status).find('Your branch is up to date') < 0 and forced == 'off': - branch_error = ( - "Error in checkoutTemplate: Branch not up to date\n" - f"Turn paramter forced on to run without branches matching") - sys.exit(branch_error) - return 0 - # Clone the repository with depth=1; check for errors click.echo("cloning experiment into directory " + directory + "/" + name) clonecmd = ( f"git clone -b {branch} --single-branch --depth=1 --recursive " + f"git checkout tags/2024.01 " f"https://github.com/NOAA-GFDL/fre-workflows.git {name}" ) preexist_error = f"fatal: destination path '{name}' exists and is not an empty directory." click.echo(clonecmd) From 582592f579466e8ca98deea976c6131885186041 Mon Sep 17 00:00:00 2001 From: kiihne-noaa Date: Fri, 25 Oct 2024 13:47:40 -0400 Subject: [PATCH 4/9] added exit if local branch is not branch request --- fre/pp/checkoutScript.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 01017fae..73596933 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -30,7 +30,15 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): # Set the name of the directory name = f"{experiment}__{platform}__{target}" - + # Get name of local branch and check branch rquest + branch_names = subprocess.run(["git","branch"],capture_output=True, text=True) + local_branch_name = branch_names.stdout.split()[1] + if branch != 'main': + if branch != local_branch_name: + stop_report = ("Error in branch: local branch does not match branch input" + sys.exit(stop_report) + return 1 + # Clone the repository with depth=1; check for errors click.echo("cloning experiment into directory " + directory + "/" + name) clonecmd = ( From a2f536f2f9388f982d72cff4f303513476f55869 Mon Sep 17 00:00:00 2001 From: kiihne-noaa Date: Mon, 28 Oct 2024 10:29:22 -0400 Subject: [PATCH 5/9] fixed bracket --- fre/pp/checkoutScript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 73596933..dc58c15b 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -35,7 +35,7 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): local_branch_name = branch_names.stdout.split()[1] if branch != 'main': if branch != local_branch_name: - stop_report = ("Error in branch: local branch does not match branch input" + stop_report = ("Error in branch: local branch does not match branch input") sys.exit(stop_report) return 1 From 3a7f3784aae553d38e2c3a5279e4118c1b58ae19 Mon Sep 17 00:00:00 2001 From: Avery Kiihne Date: Thu, 31 Oct 2024 13:37:38 -0400 Subject: [PATCH 6/9] tags version --- fre/pp/checkoutScript.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 27cecdc0..3eccb561 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -4,11 +4,15 @@ # Description: import os +import sys import subprocess from subprocess import PIPE from subprocess import STDOUT import re import click +from fre import fre +from click.testing import CliRunner + ############################################# @@ -29,6 +33,7 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): # Set the name of the directory name = f"{experiment}__{platform}__{target}" + # Get name of local branch and check branch rquest branch_names = subprocess.run(["git","branch"],capture_output=True, text=True) local_branch_name = branch_names.stdout.split()[1] @@ -37,16 +42,19 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): stop_report = ("Error in branch: local branch does not match branch input") sys.exit(stop_report) return 1 - + # Clone the repository with depth=1; check for errors click.echo("cloning experiment into directory " + directory + "/" + name) clonecmd = ( f"git clone -b {branch} --single-branch --depth=1 --recursive " - f"git checkout tags/2024.01 " f"https://github.com/NOAA-GFDL/fre-workflows.git {name}" ) preexist_error = f"fatal: destination path '{name}' exists and is not an empty directory." click.echo(clonecmd) cloneproc = subprocess.run(clonecmd, shell=True, check=False, stdout=PIPE, stderr=STDOUT) + + if branch == 'main': + subprocess.run(['git' ,'checkout' ,'tags/2024.01]') + if not cloneproc.returncode == 0: if re.search(preexist_error.encode('ASCII'),cloneproc.stdout) is not None: argstring = f" -e {experiment} -p {platform} -t {target}" @@ -60,7 +68,7 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): f"\t cylc stop {name}\n" f"\t cylc clean {name}\n" f"\t rm -r ~/cylc-src/{name}" ) - click.echo(stop_report) + sys.exit(stop_report) return 1 else: #if not identified, just print the error From 0ac03223ee8700d54260a01dfc609c90d720c766 Mon Sep 17 00:00:00 2001 From: kiihne-noaa Date: Thu, 31 Oct 2024 13:41:10 -0400 Subject: [PATCH 7/9] Update __init__.py with version --- fre/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fre/__init__.py b/fre/__init__.py index e69de29b..4711e312 100644 --- a/fre/__init__.py +++ b/fre/__init__.py @@ -0,0 +1 @@ +__version__ = '2024.01' From 8a67e19d1f0d4bff84f2cc23ee904dff01aaa0af Mon Sep 17 00:00:00 2001 From: kiihne-noaa Date: Thu, 31 Oct 2024 13:48:45 -0400 Subject: [PATCH 8/9] added version checker #174 --- fre/pp/checkoutScript.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index 3eccb561..dc8f08af 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -53,7 +53,9 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): cloneproc = subprocess.run(clonecmd, shell=True, check=False, stdout=PIPE, stderr=STDOUT) if branch == 'main': - subprocess.run(['git' ,'checkout' ,'tags/2024.01]') + local_version = subprocess.run(['fre' ,'--version']) + if local_version != '2024.01': + subprocess.run(['git' ,'checkout' ,'tags/2024.01']) if not cloneproc.returncode == 0: if re.search(preexist_error.encode('ASCII'),cloneproc.stdout) is not None: From 64d5cc8c1f6e7ef5382195196a853bb98c9a8618 Mon Sep 17 00:00:00 2001 From: Avery Kiihne Date: Wed, 6 Nov 2024 16:50:13 -0500 Subject: [PATCH 9/9] git fixes --- fre/pp/checkoutScript.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fre/pp/checkoutScript.py b/fre/pp/checkoutScript.py index dc8f08af..55e4870e 100644 --- a/fre/pp/checkoutScript.py +++ b/fre/pp/checkoutScript.py @@ -20,7 +20,7 @@ ############################################# -def _checkoutTemplate(experiment, platform, target, branch='main'): +def _checkoutTemplate(experiment, platform, target): """ Checkout the workflow template files from the repo """ @@ -53,10 +53,7 @@ def _checkoutTemplate(experiment, platform, target, branch='main'): cloneproc = subprocess.run(clonecmd, shell=True, check=False, stdout=PIPE, stderr=STDOUT) if branch == 'main': - local_version = subprocess.run(['fre' ,'--version']) - if local_version != '2024.01': - subprocess.run(['git' ,'checkout' ,'tags/2024.01']) - + subprocess.run('git checkout tags/2024.01') if not cloneproc.returncode == 0: if re.search(preexist_error.encode('ASCII'),cloneproc.stdout) is not None: argstring = f" -e {experiment} -p {platform} -t {target}"