diff --git a/fre/make/createCheckout.py b/fre/make/createCheckout.py index dc5a74c1..fc4d2df4 100644 --- a/fre/make/createCheckout.py +++ b/fre/make/createCheckout.py @@ -5,10 +5,9 @@ import logging import sys 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): # Define variables yml = yamlfile @@ -65,7 +64,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): @@ -80,7 +79,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() @@ -105,6 +104,13 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v freCheckout.finish(pc) print("\nCheckout script created at " + 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 90fc8127..36068329 100644 --- a/fre/make/createCompile.py +++ b/fre/make/createCompile.py @@ -9,7 +9,6 @@ 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): # Define variables yml = yamlfile @@ -60,10 +59,10 @@ def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose): raise ValueError (platformName + " does not exist in " + modelYaml.combined.get("compile").get("platformYaml")) (compiler,modules,modulesInit,fc,cc,modelRoot,iscontainer,mkTemplate,containerBuild,ContainerRun,RUNenv)=modelYaml.platforms.getPlatformFromName(platformName) - ## Make the bldDir based on the modelRoot, the platform, and the 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 + "-" + target.gettargetName() + "/exec" os.system("mkdir -p " + bldDir) @@ -82,14 +81,19 @@ def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose): fremakeBuildList.append(fremakeBuild) click.echo("\nCompile script created at " + bldDir + "/compile.sh" + "\n") if run: - #print("ITS GONNA RUN") if baremetalRun: pool = Pool(processes=nparallel) # Create a multiprocessing Pool pool.map(buildBaremetal.fremake_parallel,fremakeBuildList) # process data_inputs iterable with pool -# else: -# fremakeBuild.run() 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 54946349..b2053e5f 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 """ @@ -73,7 +73,7 @@ def make_cli(): @click.pass_context def run_fremake(context, yamlfile, platform, target, parallel, jobs, no_parallel_checkout, verbose): """ - Perform all fremake functions to run checkout and compile model""" - context.forward(fremake_run) + context.forward(runfremake._fremake_run) #### @make_cli.command() @@ -114,7 +114,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): """ - Write the checkout script """ - context.forward(checkout_create) + context.forward(createCheckout._checkout_create) ##### @make_cli.command @@ -136,7 +136,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) ##### @@ -178,7 +178,7 @@ def create_makefile(context,yamlfile,platform,target): @click.pass_context def create_compile(context,yamlfile,platform,target,jobs,parallel,execute,verbose): """ - Write the compile script """ - context.forward(compile_create) + context.forward(createCompile._compile_create) @make_cli.command @click.option("-y", @@ -202,8 +202,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 934a07fd..14fa5ec1 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): +def _fremake_run(yamlfile,platform,target,parallel,jobs,no_parallel_checkout,verbose): ''' 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()