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 21 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions fre/pp/checkoutScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#############################################

def _checkoutTemplate(experiment, platform, target, branch='empty'):
def _checkoutTemplate(experiment, platform, target, branch=None):
"""
Checkout the workflow template files from the repo
"""
Expand All @@ -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]
Copy link
Collaborator

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.

if branch != 'empty':
if branch == None:
Copy link
Member

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

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]
name_path_tag=subprocess.run(["git","describe","--tags"],capture_output=True, text=True).stdout.split('*')
name_path_branch = name_path_branch[1].split()[0]
name_path_branch=subprocess.run(["git","branch"],capture_output=True, text=True).stdout
os.chdir(directory)
if default_tag not in name_path_tag and name_path_branch != branch:
stop_report = f"Tag and branch of prexisting directory {diretory}/{name} does not match fre --version or branch requested"
Expand All @@ -51,14 +52,14 @@ def _checkoutTemplate(experiment, platform, target, branch='empty'):
else:
if os.path.isdir(name): #scenario 3
os.chdir(name)
name_path_tag=subprocess.run(["git","describe","--tags"],capture_output=True, text=True).stdout.split()
name_path_tag=subprocess.run(["git","describe","--tags"],capture_output=True, text=True).stdout.split()[0]
os.chdir(directory)
if not default_tag in name_path_tag:
stop_report = f"Tag of prexisting directory {diretory}/{name} does not match fre --version"
sys.exit(stop_report)
return 1
else: #scenario 1
subprocess.run(f'git checkout tags/{default_tags}')
subprocess.run(f'git clone --branch={branch} https://github.com/NOAA-GFDL/fre-cli.git')

# Clone the repository with depth=1; check for errors
click.echo("cloning experiment into directory " + directory + "/" + name)
Expand Down Expand Up @@ -93,7 +94,7 @@ def _checkoutTemplate(experiment, platform, target, branch='empty'):
#############################################

@click.command()
def checkoutTemplate(experiment, platform, target, branch = 'empty'):
def checkoutTemplate(experiment, platform, target, branch = None):
'''
Wrapper script for calling checkoutTemplate - allows the decorated version
of the function to be separate from the undecorated version
Expand Down