Source code for idmtools_platform_comps.utils.download_experiment
"""idmtools download experiment tools.This allow downloading experiments for local testing.Notes: - We need some details around this somewhere. Maybe some documentation?Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved."""importosimportstatimportsysfromconcurrent.futures._baseimportas_completedfromconcurrent.futures.threadimportThreadPoolExecutorfromcontextlibimportsuppressfromidmtoolsimportIdmConfigParserfromidmtools.core.contextimportget_current_platformfromidmtools.entities.experimentimportExperimentfromidmtools.entities.simulationimportSimulation
[docs]defget_script_extension():"""Determine extension to write out file as."""ifsys.platformin["linux","darwin"]:return"sh"else:return"bat"
[docs]defdownload_asset(asset,path):"""Download a single asset."""os.makedirs(path,exist_ok=True)asset.download_to_path(path)
[docs]defwrite_script(simulation:Simulation,path):""" Writes a shell script to execute simulation. Args: simulation: path: Returns: None """command=str(simulation.task.command)sp=os.path.join(path,f"idmtools_run.{get_script_extension()}")withopen(sp,"w")assfile:sfile.write(command)ifsys.platformin["linux","darwin"]:st=os.stat(sp)os.chmod(sp,st.st_mode|stat.S_IEXEC)