diff --git a/fre/make/createCheckout.py b/fre/make/createCheckout.py index 0c07ae00..aa284689 100644 --- a/fre/make/createCheckout.py +++ b/fre/make/createCheckout.py @@ -6,10 +6,9 @@ import sys import shutil import click -from .gfdlfremake import varsfre, yamlfre, checkout, targetfre import fre.yamltools.combine_yamls as cy +from .gfdlfremake import varsfre, yamlfre, checkout, targetfre -@click.command() def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,verbose,force_checkout): # Define variables yml = yamlfile @@ -66,7 +65,7 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v RUNenv ) = modelYaml.platforms.getPlatformFromName(platformName) ## Create the source directory for the platform - if iscontainer == False: + if iscontainer is False: srcDir = modelRoot + "/" + fremakeYaml["experiment"] + "/src" # if the source directory does not exist, it is created if not os.path.exists(srcDir): @@ -81,7 +80,7 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v print("\nCheckout script created in "+ srcDir + "/checkout.sh \n") # Run the checkout script - if run == True: + if run is True: freCheckout.run() else: sys.exit() @@ -129,5 +128,13 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v else: print("\nCheckout script PREVIOUSLY created in "+ tmpDir + "/checkout.sh" + "\n") +@click.command() +def _checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,verbose): + ''' + Decorator for calling checkout_create - allows the decorated version + of the function to be separate from the undecorated version + ''' + return checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,verbose) + if __name__ == "__main__": checkout_create() diff --git a/fre/make/createCompile.py b/fre/make/createCompile.py index bae1ca42..d67f6914 100644 --- a/fre/make/createCompile.py +++ b/fre/make/createCompile.py @@ -9,8 +9,7 @@ from .gfdlfremake import varsfre, yamlfre, targetfre, buildBaremetal import fre.yamltools.combine_yamls as cy -@click.command() -def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose,force_compile): +def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose): # Define variables yml = yamlfile name = yamlfile.split(".")[0] @@ -63,7 +62,7 @@ def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose,force_ ## Make the bldDir based on the modelRoot, the platform, and the target srcDir = modelRoot + "/" + fremakeYaml["experiment"] + "/src" ## Check for type of build - if iscontainer == False: + if iscontainer is False: baremetalRun = True bldDir = modelRoot + "/" + fremakeYaml["experiment"] + "/" + platformName + "-" + target.gettargetName() + "/exec" os.system("mkdir -p " + bldDir) @@ -109,5 +108,13 @@ def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose,force_ else: sys.exit() +@click.command() +def _compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose): + ''' + Decorator for calling compile_create - allows the decorated version + of the function to be separate from the undecorated version + ''' + return compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose) + if __name__ == "__main__": compile_create() diff --git a/fre/make/createDocker.py b/fre/make/createDocker.py index 27639751..59b73ee9 100644 --- a/fre/make/createDocker.py +++ b/fre/make/createDocker.py @@ -8,7 +8,6 @@ from .gfdlfremake import varsfre, targetfre, yamlfre, buildDocker import fre.yamltools.combine_yamls as cy -@click.command() def dockerfile_create(yamlfile,platform,target,execute): srcDir="src" checkoutScriptName = "checkout.sh" @@ -52,7 +51,7 @@ def dockerfile_create(yamlfile,platform,target,execute): ## Make the bldDir based on the modelRoot, the platform, and the target srcDir = modelRoot + "/" + fremakeYaml["experiment"] + "/src" ## Check for type of build - if iscontainer == True: + if iscontainer is True: image="ecpe4s/noaa-intel-prototype:2023.09.25" bldDir = modelRoot + "/" + fremakeYaml["experiment"] + "/exec" tmpDir = "tmp/"+platformName @@ -78,5 +77,13 @@ def dockerfile_create(yamlfile,platform,target,execute): else: sys.exit() +@click.command() +def _dockerfile_create(yamlfile,platform,target,execute): + ''' + Decorator for calling dockerfile_create - allows the decorated version + of the function to be separate from the undecorated version + ''' + return dockerfile_create(yamlfile,platform,target,execute) + if __name__ == "__main__": dockerfile_create() diff --git a/fre/make/createMakefile.py b/fre/make/createMakefile.py index 0232bf4b..eaf340dd 100644 --- a/fre/make/createMakefile.py +++ b/fre/make/createMakefile.py @@ -8,7 +8,6 @@ from .gfdlfremake import makefilefre, varsfre, targetfre, yamlfre import fre.yamltools.combine_yamls as cy -@click.command() def makefile_create(yamlfile,platform,target): srcDir="src" checkoutScriptName = "checkout.sh" @@ -46,7 +45,7 @@ def makefile_create(yamlfile,platform,target): ## Make the bldDir based on the modelRoot, the platform, and the target srcDir = modelRoot + "/" + fremakeYaml["experiment"] + "/src" ## Check for type of build - if iscontainer == False: + if iscontainer is False: baremetalRun = True bldDir = modelRoot + "/" + fremakeYaml["experiment"] + "/" + platformName + "-" + targetObject.gettargetName() + "/exec" os.system("mkdir -p " + bldDir) @@ -78,5 +77,13 @@ def makefile_create(yamlfile,platform,target): freMakefile.writeMakefile() click.echo("\nMakefile created at " + bldDir + "/Makefile" + "\n") +@click.command() +def _makefile_create(yamlfile,platform,target): + ''' + Decorator for calling makefile_create - allows the decorated version + of the function to be separate from the undecorated version + ''' + return makefile_create(yamlfile,platform,target) + if __name__ == "__main__": makefile_create() diff --git a/fre/make/fremake.py b/fre/make/fremake.py index ef668c7e..2020e5b0 100644 --- a/fre/make/fremake.py +++ b/fre/make/fremake.py @@ -1,9 +1,9 @@ import click -from .createCheckout import checkout_create -from .createCompile import compile_create -from .createDocker import dockerfile_create -from .createMakefile import makefile_create -from .runFremake import fremake_run +from fre.make import createCheckout +from fre.make import createMakefile +from fre.make import createCompile +from fre.make import createDocker +from fre.make import runFremake yamlfile_opt_help = """Experiment yaml compile FILE""" experiment_opt_help = """Name of experiment""" @@ -86,7 +86,7 @@ def make_cli(): @click.pass_context def run_fremake(context, yamlfile, platform, target, parallel, jobs, no_parallel_checkout, verbose, force_checkout, force_compile): """ - Perform all fremake functions to run checkout and compile model""" - context.forward(fremake_run) + context.forward(runfremake._fremake_run) #### @make_cli.command() @@ -131,7 +131,7 @@ def run_fremake(context, yamlfile, platform, target, parallel, jobs, no_parallel @click.pass_context def create_checkout(context,yamlfile,platform,target,no_parallel_checkout,jobs,execute,verbose,force_checkout): """ - Write the checkout script """ - context.forward(checkout_create) + context.forward(createCheckout._checkout_create) ##### @make_cli.command @@ -153,7 +153,7 @@ def create_checkout(context,yamlfile,platform,target,no_parallel_checkout,jobs,e @click.pass_context def create_makefile(context,yamlfile,platform,target): """ - Write the makefile """ - context.forward(makefile_create) + context.forward(createMakefile._makefile_create) ##### @@ -199,7 +199,7 @@ def create_makefile(context,yamlfile,platform,target): @click.pass_context def create_compile(context,yamlfile,platform,target,jobs,parallel,execute,verbose,force_compile): """ - Write the compile script """ - context.forward(compile_create) + context.forward(createCompile._compile_create) @make_cli.command @click.option("-y", @@ -223,7 +223,7 @@ def create_compile(context,yamlfile,platform,target,jobs,parallel,execute,verbos @click.pass_context def create_dockerfile(context,yamlfile,platform,target,execute): """ - Write the dockerfile """ - context.forward(dockerfile_create) + context.forward(createDocker._dockerfile_create) if __name__ == "__main__": make_cli() diff --git a/fre/make/runFremake.py b/fre/make/runFremake.py index b911dbc0..3c1fa7d4 100644 --- a/fre/make/runFremake.py +++ b/fre/make/runFremake.py @@ -9,16 +9,13 @@ import logging from multiprocessing.dummy import Pool from pathlib import Path - import click - import fre.yamltools.combine_yamls as cy from .gfdlfremake import ( targetfre, varsfre, yamlfre, checkout, makefilefre, buildDocker, buildBaremetal ) -@click.command() -def fremake_run(yamlfile,platform,target,parallel,jobs,no_parallel_checkout,verbose,force_checkout,foce_compile): +def fremake_run(yamlfile,platform,target,parallel,jobs,no_parallel_checkout,verbose,force_checkout,force_compile): ''' run fremake via click''' yml = yamlfile name = yamlfile.split(".")[0] @@ -202,6 +199,13 @@ def fremake_run(yamlfile,platform,target,parallel,jobs,no_parallel_checkout,verb # process data_inputs iterable with pool pool.map(buildBaremetal.fremake_parallel,fremakeBuildList) +@click.command() +def _fremake_run(yamlfile,platform,target,parallel,jobs,no_parallel_checkout,verbose): + ''' + Decorator for calling fremake_run - allows the decorated version + of the function to be separate from the undecorated version + ''' + return fremake_run(yamlfile,platform,target,parallel,jobs,no_parallel_checkout,verbose) if __name__ == "__main__": fremake_run()