def copy_module_parameters(moduleName):
    module = parse_modules.get_module(moduleName)
    path = os.path.dirname(SimEx.Calculators.__file__)+'/RegisteredCalculators/'
    src = path + moduleName + "_ParamTemplate.py"
    dest = moduleName+"_params.py"
    if not os.path.exists(dest):
        shutil.copy(src,dest)
Exemplo n.º 2
0
def copy_module_parameters(moduleName):
    module = parse_modules.get_module(moduleName)
    path = os.path.dirname(
        SimEx.Calculators.__file__) + '/RegisteredCalculators/'
    src = path + moduleName + "_ParamTemplate.py"
    dest = moduleName + "_params.py"
    if not os.path.exists(dest):
        shutil.copy(src, dest)
def create_modulecall_code(moduleName,prevModule,nextModule):
    module = parse_modules.get_module(moduleName)
    codelines = """
    
#======================================================================================    
# Module ${ModuleName}
#======================================================================================    

from SimEx.Calculators.${ModuleName} import ${ModuleName}
import ${ModuleName}_params

if (${ModuleName}_params.output_path == 'default'):
    ${ModuleName}_params.output_path = "output/${ModuleName}"
    if not os.path.exists('output'): os.makedirs('output')    

${SetInputToPrevModulePath}

${ModuleName}_inst = ${ModuleName} (
                                    parameters=${ModuleName}_params.parameters,
                                    input_path=${ModuleName}_params.input_path,
                                    output_path=${ModuleName}_params.output_path
                                    )
prCyan("-"*80)
prCyan ("Running ${ModuleName} ...")                                  
module_time=time.time()                                    
${ModuleName}_inst.backengine()
prCyan ("Done in "+str(datetime.timedelta(seconds=time.time()-module_time)))
                       """
    prevpath = """
if (${ModuleName}_params.input_path == 'default'):
    ${ModuleName}_params.input_path = "output/${PrevModuleName}"
               """
    if (prevModule):
        codelines=codelines.replace("${SetInputToPrevModulePath}",prevpath)    
        codelines=codelines.replace("${PrevModuleName}",prevModule)
    else:
        codelines=codelines.replace("${SetInputToPrevModulePath}","")
    codelines=codelines.replace("${ModuleName}",moduleName)
        
    return codelines
Exemplo n.º 4
0
def create_modulecall_code(moduleName, prevModule, nextModule):
    module = parse_modules.get_module(moduleName)
    codelines = """

#======================================================================================
# Module ${ModuleName}
#======================================================================================

from SimEx.Calculators.${ModuleName} import ${ModuleName}
import ${ModuleName}_params

if (${ModuleName}_params.output_path == 'default'):
    ${ModuleName}_params.output_path = "output/${ModuleName}"
    if not os.path.exists('output'): os.makedirs('output')

${SetInputToPrevModulePath}

${ModuleName}_inst = ${ModuleName} (
                                    parameters=${ModuleName}_params.parameters,
                                    input_path=${ModuleName}_params.input_path,
                                    output_path=${ModuleName}_params.output_path
                                    )
prCyan("-"*80)
prCyan ("Running ${ModuleName} ...")
module_time=time.time()
${ModuleName}_inst.backengine()
prCyan ("Done in "+str(datetime.timedelta(seconds=time.time()-module_time)))
                       """
    prevpath = """
if (${ModuleName}_params.input_path == 'default'):
    ${ModuleName}_params.input_path = "output/${PrevModuleName}"
               """
    if (prevModule):
        codelines = codelines.replace("${SetInputToPrevModulePath}", prevpath)
        codelines = codelines.replace("${PrevModuleName}", prevModule)
    else:
        codelines = codelines.replace("${SetInputToPrevModulePath}", "")
    codelines = codelines.replace("${ModuleName}", moduleName)

    return codelines