Skip to content

Commit

Permalink
Revert "pylint things, clean up of checkout_script functioning, fix f…
Browse files Browse the repository at this point in the history
…re versioning and put it in init where it belongs"

This reverts commit 5528378.
  • Loading branch information
Chris Blanton authored and Chris Blanton committed Nov 27, 2024
1 parent caca0ee commit b44eb12
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 25 deletions.
10 changes: 10 additions & 0 deletions fre/fre.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
import click
from .lazy_group import LazyGroup

# Horrible way to turn xxxx.y into xxxx.0y
import importlib.metadata
version_unexpanded = importlib.metadata.version('fre-cli')
version_unexpanded_split = version_unexpanded.split('.')
if len(version_unexpanded_split[1]) == 1:
version_minor = "0" + version_unexpanded_split[1]
else:
version_minor = version_unexpanded_split[1]
version = version_unexpanded_split[0] + '.' + version_minor

@click.group(
cls = LazyGroup,
lazy_subcommands = {"pp": ".pp.frepp.pp_cli",
Expand Down
11 changes: 7 additions & 4 deletions fre/pp/checkout_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import os
import sys
import subprocess
from subprocess import PIPE
from subprocess import STDOUT
import re

import click

import fre

FRE_WORKFLOWS_URL = 'https://github.com/NOAA-GFDL/fre-workflows.git'
FRE_WORKFLOWS_URL='https://github.com/NOAA-GFDL/fre-workflows.git'

def checkout_template(experiment = None, platform = None, target = None, branch = None):
def checkout_template(experiment, platform, target, branch=None):
"""
Checkout the workflow template files from the repo
"""
Expand All @@ -36,7 +39,7 @@ def checkout_template(experiment = None, platform = None, target = None, branch
# Create the directory if it doesn't exist
directory = os.path.expanduser("~/cylc-src")
try:
os.makedirs(directory, exist_ok = True)
os.makedirs(directory, exist_ok=True)
except Exception as exc:
raise OSError(
'(checkoutScript) directory {directory} wasnt able to be created. exit!') from exc
Expand Down Expand Up @@ -86,7 +89,7 @@ def checkout_template(experiment = None, platform = None, target = None, branch
#############################################

@click.command()
def _checkout_template(experiment, platform, target, branch = None):
def _checkout_template(experiment, platform, target, branch=None):
'''
Wrapper script for calling checkout_template - allows the decorated version
of the function to be separate from the undecorated version
Expand Down
1 change: 1 addition & 0 deletions fre/pp/configure_script_xml.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
'''
Primary Usage: fre-bronx-to-canopy -x XML -e EXP -p PLATFORM -t TARGET
Expand Down
1 change: 1 addition & 0 deletions fre/pp/configure_script_yaml.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
Script creates rose-apps and rose-suite
files for the workflow from the pp yaml.
Expand Down
35 changes: 17 additions & 18 deletions fre/pp/frepp.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
''' fre pp '''

import click

from fre.pp import checkout_script
from fre.pp import configure_script_yaml
from fre.pp import configure_script_xml
#from fre.pp import validate
from fre.pp import install
from fre.pp import run
from fre.pp import trigger
from fre.pp import status
from fre.pp import wrapper
from .checkout_script import _checkout_template
from .configure_script_yaml import _yamlInfo
from .configure_script_xml import convert
from .validate import _validate_subtool
from .install import _install_subtool
from .run import _pp_run_subtool
from .trigger import _trigger
from .status import _status_subtool
from .wrapper import runFre2pp

@click.group(help=click.style(" - access fre pp subcommands", fg=(57,139,210)))
def pp_cli():
Expand All @@ -32,7 +31,7 @@ def pp_cli():
def status(context, experiment, platform, target):
# pylint: disable=unused-argument
""" - Report status of PP configuration"""
context.forward(status.status_subtool)
context.forward(_status_subtool)

# fre pp run
@pp_cli.command()
Expand All @@ -49,7 +48,7 @@ def status(context, experiment, platform, target):
def run(context, experiment, platform, target):
# pylint: disable=unused-argument
""" - Run PP configuration"""
context.forward(run.pp_run_subtool)
context.forward(_pp_run_subtool)

# fre pp validate
@pp_cli.command()
Expand Down Expand Up @@ -83,7 +82,7 @@ def validate(context, experiment, platform, target):
def install(context, experiment, platform, target):
# pylint: disable=unused-argument
""" - Install PP configuration"""
context.forward(install.install_subtool)
context.forward(_install_subtool)

@pp_cli.command()
@click.option("-y", "--yamlfile", type=str,
Expand All @@ -102,7 +101,7 @@ def install(context, experiment, platform, target):
def configure_yaml(context,yamlfile,experiment,platform,target):
# pylint: disable=unused-argument
""" - Execute fre pp configure """
context.forward(configure_script_yaml._yamlInfo)
context.forward(_yamlInfo)

@pp_cli.command()
@click.option("-e", "--experiment", type=str,
Expand All @@ -121,7 +120,7 @@ def configure_yaml(context,yamlfile,experiment,platform,target):
def checkout(context, experiment, platform, target, branch=None):
# pylint: disable=unused-argument
""" - Execute fre pp checkout """
context.forward(checkout_script._checkout_template)
context.forward(_checkout_template)

@pp_cli.command()
@click.option('-x', '--xml',
Expand Down Expand Up @@ -179,7 +178,7 @@ def configure_xml(context, xml, platform, target, experiment, do_analysis, histo
ppdir, do_refinediag, pp_start, pp_stop, validate, verbose, quiet, dual):
# pylint: disable=unused-argument
""" - Converts a Bronx XML to a Canopy rose-suite.conf """
context.forward(configure_script_xml.convert)
context.forward(convert)

#fre pp wrapper
@pp_cli.command()
Expand All @@ -205,7 +204,7 @@ def configure_xml(context, xml, platform, target, experiment, do_analysis, histo
def wrapper(context, experiment, platform, target, config_file, time=None, branch=None):
# pylint: disable=unused-argument
""" - Execute fre pp steps in order """
context.forward(wrapper.runFre2pp)
context.forward(runFre2pp)

@pp_cli.command()
@click.option("-e", "--experiment", type=str,
Expand All @@ -224,7 +223,7 @@ def wrapper(context, experiment, platform, target, config_file, time=None, branc
def trigger(context, experiment, platform, target, time):
# pylint: disable=unused-argument
""" - Start postprocessing for a particular time """
context.forward(trigger._trigger)
context.forward(_trigger)

if __name__ == "__main__":
''' entry point for click to fre pp commands '''
Expand Down
3 changes: 2 additions & 1 deletion fre/pp/install.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
''' fre pp install '''

from pathlib import Path
Expand Down Expand Up @@ -38,4 +39,4 @@ def install_subtool(experiment, platform, target):
@click.command()
def _install_subtool(experiment, platform, target):
''' entry point to install for click '''
return _install_subtool(experiment, platform, target)
return install_subtool(experiment, platform, target)
3 changes: 2 additions & 1 deletion fre/pp/run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
''' fre pp run '''

import subprocess
Expand All @@ -16,4 +17,4 @@ def pp_run_subtool(experiment, platform, target):
@click.command()
def _pp_run_subtool(experiment, platform, target):
''' entry point to run for click '''
return _pp_run_subtool(experiment, platform, target)
return pp_run_subtool(experiment, platform, target)
3 changes: 2 additions & 1 deletion fre/pp/status.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
''' fre pp status '''

import subprocess
Expand All @@ -17,4 +18,4 @@ def status_subtool(experiment, platform, target):
@click.command()
def _status_subtool(experiment, platform, target):
''' entry point to status for click '''
return _status_subtool(experiment, platform, target)
return status_subtool(experiment, platform, target)
1 change: 1 addition & 0 deletions fre/pp/trigger.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
''' fre pp trigger '''

import subprocess
Expand Down
1 change: 1 addition & 0 deletions fre/pp/validate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
''' fre pp validate '''

import os
Expand Down

0 comments on commit b44eb12

Please sign in to comment.