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

40.Add fremake tools #64

Merged
merged 45 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
141bd75
#40 Start to add fremake tools to fre-cli
singhd789 Feb 28, 2024
a79a07b
#40 Add create-checkout tool functionality
singhd789 Mar 7, 2024
88d81a5
Update checkout.py
singhd789 Mar 7, 2024
27bb9f6
makefile and dockerfile
bcc2761 Mar 12, 2024
b56dc8f
#40 Update and add fremake tools
singhd789 Mar 12, 2024
3a9ecb2
Merge branch 'main' of github.com:NOAA-GFDL/fre-cli into 40.fremake-t…
singhd789 Mar 12, 2024
ffd8235
makefile works...?
Mar 12, 2024
f9d5eee
i hope this doesn't break the code, fixed merge for fremake.py imports
Mar 13, 2024
1fcab45
#40 Add `execute/run` option to checkout and compile
singhd789 Mar 18, 2024
d3899c7
create-dockerfile with correct user ID
bcc2761 Mar 19, 2024
5c97cb8
Merge branch '40.fremake-tools' of github.com:NOAA-GFDL/fre-cli into …
bcc2761 Mar 19, 2024
ebced9a
docker run
bcc2761 Mar 20, 2024
f4f5d99
readme in progress
bcc2761 Apr 2, 2024
924cd37
added refactor changes, neeed to add fremake function
bcc2761 Apr 11, 2024
a7d395a
fixed weird -y flag problem
bcc2761 Apr 11, 2024
45c3bb4
#40 Add click options for configure Yaml script
Apr 11, 2024
a9d953b
added fremake-run
bcc2761 Apr 11, 2024
9f13926
Merge branch '40.fremake-tools' of github.com:NOAA-GFDL/fre-cli into …
bcc2761 Apr 11, 2024
7e5e718
#40 Fix merge conflict
Apr 11, 2024
d6ae5d4
Update __init__.py
bcc2761 Apr 11, 2024
a946062
Update meta.yaml
bcc2761 Apr 11, 2024
494e9e4
Update meta.yaml
bcc2761 Apr 12, 2024
e2f4b49
Update meta.yaml
bcc2761 Apr 12, 2024
5623b3c
Update meta.yaml
bcc2761 Apr 12, 2024
e45fd0e
Update build_conda.yml
bcc2761 Apr 12, 2024
bb975e3
Update build_conda.yml
bcc2761 Apr 12, 2024
8d9d117
changed import syntax
bcc2761 Apr 12, 2024
355a80a
Update build_conda.yml
bcc2761 Apr 12, 2024
3c296cd
Update build_conda.yml
bcc2761 Apr 12, 2024
4fd59f9
attempt to fix workflow
bcc2761 Apr 12, 2024
6361654
Merge branch '40.fremake-tools' of github.com:NOAA-GFDL/fre-cli into …
bcc2761 Apr 12, 2024
574e7e4
work with renamed packagE
bcc2761 Apr 15, 2024
a107c27
trigger workflow
bcc2761 Apr 15, 2024
e4ab30c
Update build_conda.yml
bcc2761 Apr 15, 2024
a3a9cde
just put gfdlfremake into here
bcc2761 Apr 15, 2024
6430877
Merge branch '40.fremake-tools' of github.com:NOAA-GFDL/fre-cli into …
bcc2761 Apr 15, 2024
d50b40e
Merge branch 'main' into 40.fremake-tools
bcc2761 Apr 15, 2024
e9541c1
fixing some scripts
bcc2761 Apr 15, 2024
1ff1401
Merge branch '40.fremake-tools' of github.com:NOAA-GFDL/fre-cli into …
bcc2761 Apr 15, 2024
1f11e7e
#40 Change `target` to `targetObject` to use correct variable
Apr 16, 2024
59d40ed
#40 Move generation of last few lines of dockerfile
Apr 16, 2024
4e40ea2
adding some print statements
bcc2761 Apr 16, 2024
14d5283
#40 Update checkout script creation
Apr 16, 2024
18d5ac8
added more specification
bcc2761 Apr 16, 2024
16eb8ac
Update build_conda.yml
bcc2761 Apr 16, 2024
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
3 changes: 1 addition & 2 deletions fre/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from fre.fre import *
from fre.frecheck import *
from fre.frelist import *
from fre.fremake import *
from .make import *
from fre.frepp import *
from fre.frerun import *
from fre.frecatalog import *
Expand Down
248 changes: 169 additions & 79 deletions fre/fre.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from fre import frecheck
from fre.frecheck.frecheck import *

from fre import fremake
from fre.fremake.fremake import *
from .make import checkout_create, compile_create, makefile_create, dockerfile_create, fremake_run

from fre import frepp
from fre.frepp.frepp import *
Expand Down Expand Up @@ -54,7 +53,7 @@ def freList():
pass

@fre.group('make')
def freMake():
def fremake():
""" - access fre make subcommands """
pass

Expand Down Expand Up @@ -124,97 +123,187 @@ def mask_atmos_plevel(context, infile, outfile, psfile):
"""
fre make subcommands to be processed
"""
@freMake.command()
@click.option('--uppercase', '-u', is_flag=True, help = 'Print statement in uppercase.')
def checkout(uppercase):
""" - Execute fre make checkout """
statement = "execute fre make checkout script"
if uppercase:
statement = statement.upper()
click.echo(statement)

@freMake.command()
@click.option("-y",
"--yamlfile",
type=str,
help="Experiment yaml compile FILE",

@fremake.command()
@click.option("-y",
"--yamlfile",
type=str,
help="Experiment yaml compile FILE",
required=True) # used click.option() instead of click.argument() because we want to have help statements
@click.option("-p",
"--platform",
@click.option("-p",
"--platform",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
type=str,
help="Hardware and software FRE platform space separated list of STRING(s). This sets platform-specific data and instructions", required=True)
@click.option("-t", "--target",
@click.option("-t", "--target",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="FRE target space separated list of STRING(s) that defines compilation settings and linkage directives for experiments. Predefined targets refer to groups of directives that exist in the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod', 'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive (cannot not use more than one of these in the target list). Any number of targets can be used.",
type=str, help="FRE target space separated list of STRING(s) that defines compilation settings and linkage directives for experiments. Predefined targets refer to groups of directives that exist in the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod', 'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive (cannot not use more than one of these in the target list). Any number of targets can be used.",
required=True)
@click.option("-f",
"--force-checkout",
is_flag=True,
help="Force checkout to get a fresh checkout to source directory in case the source directory exists")
@click.option("-F",
"--force-compile",
is_flag=True,
help="Force compile to compile a fresh executable in case the executable directory exists")
@click.option("-K",
"--keep-compiled",
is_flag=True,
help="Keep compiled files in the executable directory for future use")
@click.option("--no-link",
is_flag=True,
help="Do not link the executable")
@click.option("-E",
"--execute",
is_flag=True,
@click.option("-e",
"--execute",
is_flag=True,
help="Execute all the created scripts in the current session")
@click.option("-n",
"--parallel",
@click.option("-n",
"--parallel",
type=int,
metavar='',
default=1,
metavar='',
default=1,
help="Number of concurrent model compiles (default 1)")
@click.option("-j",
"--jobs",
type=int,
@click.option("-j",
"--jobs",
type=int,
metavar='',
default=4,
default=4,
help="Number of jobs to run simultaneously. Used for make -jJOBS and git clone recursive --jobs=JOBS")
@click.option("-npc",
"--no-parallel-checkout",
is_flag=True,
@click.option("-npc",
"--no-parallel-checkout",
is_flag=True,
help="Use this option if you do not want a parallel checkout. The default is to have parallel checkouts.")
@click.option("-s",
"--submit",
is_flag=True,
@click.option("-s",
"--submit",
is_flag=True,
help="Submit all the created scripts as batch jobs")
@click.option("-v",
"--verbose",
is_flag=True,
@click.option("-v",
"--verbose",
is_flag=True,
help="Get verbose messages (repeat the option to increase verbosity level)")
@click.option("-w",
"--walltime",
@click.pass_context
def run_fremake(context, yamlfile, platform, target, execute, parallel, jobs, no_parallel_checkout, submit, verbose):
""" - Perform all fremake functions to run checkout and compile model"""
context.forward(fremake_run)

####
@fremake.command()
@click.option("-y",
"--yamlfile",
type=str,
help="Experiment yaml compile FILE",
required=True) # used click.option() instead of click.argument() because we want to have help statements
@click.option("-p",
"--platform",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="Hardware and software FRE platform space separated list of STRING(s). This sets platform-specific data and instructions", required=True)
@click.option("-t", "--target",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="FRE target space separated list of STRING(s) that defines compilation settings and linkage directives for experiments. Predefined targets refer to groups of directives that exist in the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod', 'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive (cannot not use more than one of these in the target list). Any number of targets can be used.",
required=True)
@click.option("-j",
"--jobs",
type=int,
metavar='',
default=4,
help="Number of jobs to run simultaneously. Used for make -jJOBS and git clone recursive --jobs=JOBS")
@click.option("-npc",
"--no-parallel-checkout",
is_flag=True,
help="Use this option if you do not want a parallel checkout. The default is to have parallel checkouts.")
@click.option("-e",
"--execute",
is_flag=True,
default=False,
help="Use this to run the created checkout script.")
@click.option("-v",
"--verbose",
is_flag=True,
help="Get verbose messages (repeat the option to increase verbosity level)")
@click.pass_context
def create_checkout(context,yamlfile,platform,target,no_parallel_checkout,jobs,execute,verbose):
""" - Write the checkout script """
context.forward(checkout_create)

#####
@fremake.command
@click.option("-y",
"--yamlfile",
type=str,
help="Experiment yaml compile FILE",
required=True) # used click.option() instead of click.argument() because we want to have help statements
@click.option("-p",
"--platform",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="Hardware and software FRE platform space separated list of STRING(s). This sets platform-specific data and instructions", required=True)
@click.option("-t", "--target",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="FRE target space separated list of STRING(s) that defines compilation settings and linkage directives for experiments. Predefined targets refer to groups of directives that exist in the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod', 'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive (cannot not use more than one of these in the target list). Any number of targets can be used.",
required=True)
@click.pass_context
def create_makefile(context,yamlfile,platform,target):
""" - Write the makefile """
context.forward(makefile_create)

#####

@fremake.command
@click.option("-y",
"--yamlfile",
type=str,
help="Experiment yaml compile FILE",
required=True) # used click.option() instead of click.argument() because we want to have help statements
@click.option("-p",
"--platform",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="Hardware and software FRE platform space separated list of STRING(s). This sets platform-specific data and instructions", required=True)
@click.option("-t", "--target",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="FRE target space separated list of STRING(s) that defines compilation settings and linkage directives for experiments. Predefined targets refer to groups of directives that exist in the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod', 'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive (cannot not use more than one of these in the target list). Any number of targets can be used.",
required=True)
@click.option("-j",
"--jobs",
type=int,
metavar='',
default=4,
help="Number of jobs to run simultaneously. Used for make -jJOBS and git clone recursive --jobs=JOBS")
@click.option("-n",
"--parallel",
type=int,
metavar='',
help="Maximum wall time NUM (in minutes) to use")
@click.option("--mail-list",
type=str,
help="Email the comma-separated STRING list of emails rather than [email protected]")
metavar='', default=1,
help="Number of concurrent model compiles (default 1)")
@click.option("-e",
"--execute",
is_flag=True,
default=False,
help="Use this to run the created checkout script.")
@click.option("-v",
"--verbose",
is_flag=True,
help="Get verbose messages (repeat the option to increase verbosity level)")
@click.pass_context
def create_compile(context,yamlfile,platform,target,jobs,parallel,execute,verbose):
""" - Write the compile script """
context.forward(compile_create)

#####

@fremake.command
@click.option("-y",
"--yamlfile",
type=str,
help="Experiment yaml compile FILE",
required=True) # used click.option() instead of click.argument() because we want to have help statements
@click.option("-p",
"--platform",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="Hardware and software FRE platform space separated list of STRING(s). This sets platform-specific data and instructions", required=True)
@click.option("-t", "--target",
multiple=True, #replaces nargs=-1 since we are using click.option() instead of click.argument()
type=str,
help="FRE target space separated list of STRING(s) that defines compilation settings and linkage directives for experiments. Predefined targets refer to groups of directives that exist in the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod', 'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive (cannot not use more than one of these in the target list). Any number of targets can be used.",
required=True)
@click.option("-e",
"--execute",
is_flag=True,
help="Build Dockerfile that has been generated by create-docker.")
@click.pass_context
def fremakefunction(context, yamlfile, platform, target, force_checkout, force_compile, keep_compiled, no_link, execute, parallel, jobs, no_parallel_checkout, submit, verbose, walltime, mail_list):
""" - Execute fre make func """
context.forward(fremake.fremake.fremake)

# # this is the command that will execute all of `fre make`, but I need to test whether it will be able to pass specific flags to different areas when it they each have different flags
# @freMake.command()
# @click.option('--uppercase', '-u', is_flag=True, help = 'Print statement in uppercase.')
# @click.pass_context
# def executeAll(context, uppercase):
# """ - Execute all commands under fre make"""
# context.forward(checkout)
# context.forward(compile)
# context.forward(container)
# context.forward(list)
def create_dockerfile(context,yamlfile,platform,target,execute):
""" - Write the dockerfile """
context.forward(dockerfile_create)

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

Expand Down Expand Up @@ -376,6 +465,7 @@ def install(context, experiment, platform, target):
type=str,
help="YAML file to be used for parsing",
required=True)

@click.pass_context
def configure(context,yamlfile,experiment,platform,target):
""" - Execute fre pp configure """
Expand Down
1 change: 0 additions & 1 deletion fre/fremake/__init__.py

This file was deleted.

Loading
Loading