a aDg@s|ddlZddlZddlZddlmZddlmZddlmZddl m Z dZ dZ dZ d ZGd d d eZd d ZddZdS)N)Config)abort) ApiException)sleepzsimcore/services/comp/opencorz0simcore/services/comp/rabbit-ss-0d-cardiac-modelz/simcore/services/comp/human-gb-0d-cardiac-modelz*simcore/services/comp/kember-cardiac-modelc@s eZdZdS)SimulationExceptionN)__name__ __module__ __qualname__r r Z PUBLISHEDPENDINGz)the simulation job could not be submittedok)r r)job_idr )statusdatanokunknownrr)"OPENCOR_SOLVERrDATASET_4_SOLVERDATASET_17_SOLVERDATASET_78_SOLVERr ApiClient ConfigurationrOSPARC_API_URLOSPARC_API_KEYOSPARC_API_SECRETtempfileNamedTemporaryFilejsondumpseekFilesApiZ upload_filer rrclosewrite SolversApiZget_solver_releaseZ create_jobidrZ JobInputsZ start_jobstatelenargs)r solver_name api_clientZhas_solver_inputZtemp_config_file files_apireZtemp_input_fileZ input_file solvers_apir rjobrresr r r start_simulations                     rAc Csznttjtjtjtjd}t|}|d}|dd}|dd}||||}|j dkrjt d|j dkrfz| |||}Wn4t y}zt d |d WYd}~n d}~00z.t |} | |jt|jd j} Wn6t y"}zt d |d WYd}~n d}~00t| d } ddi} |tkrPt| | d<n | | d<| nddi} WnJt y}z0dt|jd kr|jd ndd} WYd}~n d}~00| S)Nrrr r rZFAILEDzthe simulation failedSUCCESSz3the simulation job outputs could not be retrieved (rrz/the simulation results could not be retrieved (rrrresultsr!r"r#)rr(r)rr*r+r,r5Z inspect_jobr7rZget_job_outputsrr2Z download_filerDlistkeysr6openr$r/loadreadr3r8r9) r r;r>rr:Zsolver_versionroutputsr=r<Zresults_filenameZ results_filer@r r r check_simulationsZ            rK)r/rr- app.configrflaskrZ osparc.restrtimerr$r%r&r' ExceptionrrArKr r r r s    w