コード例 #1
0
def run_simulation(
    sim: ApiSimulation,
    isolve_version: Optional[str] = "latest",
    *,
    host: str = HOST,
    api_key: Optional[str] = KEY,
    api_secret: Optional[str] = SECRET,
):  # TODO: version should default to latest

    configuration = osparc.Configuration()
    configuration.host = host
    configuration.username = api_key
    configuration.password = api_secret

    with osparc.ApiClient(configuration) as api_client:

        solvers_api = osparc.SolversApi(api_client)
        files_api = osparc.FilesApi(api_client)

        _job, _status = submit_simulation(solvers_api,
                                          files_api,
                                          sim.raw,
                                          isolve_version,
                                          wait=True)

        logger.info(f"Simulation has results: {sim.HasResults()}")
        logger.info(
            f"Results have been written to: {Path(sim.GetOutputFileName()).parent}"
        )
コード例 #2
0
def files_api(api_client) -> osparc.FilesApi:
    return osparc.FilesApi(api_client)
コード例 #3
0
        },
        "output": ["Membrane/V"],
    }))

load_dotenv()
cfg = osparc.Configuration(
    host=os.environ.get("OSPARC_API_URL", "http://127.0.0.1:8006"),
    username=os.environ["OSPARC_API_KEY"],
    password=os.environ["OSPARC_API_SECRET"],
)
print("Entrypoint", cfg.host)

with osparc.ApiClient(cfg) as api_client:
    # Upload our configuration file.

    files_api = osparc.FilesApi(api_client)

    config_file = files_api.upload_file(str(config_path))

    # Create our simulation.

    solvers_api = osparc.SolversApi(api_client)

    solver = solvers_api.get_solver_release("simcore/services/comp/opencor",
                                            "1.0.3")

    job = solvers_api.create_job(
        solver.id,
        solver.version,
        osparc.JobInputs({
            "model_url":