Skip to main content

A python library to use Simulagora programatically

Project description

Summary

A python library to use Simulagora programatically either directly from the command line or via a Python program.

Prerequisites

You will need a proper installation of cwclientlib, which itself requires Python 2.7 and Python requests.

An account on Simulagora is of course also needed.

Using Simulagora client

  1. Log in on Simulagora and consult the token that was generated for you at the dedicated URL;

  2. Create a .simulagorarc file in your user directory (only readable by yourself), like:

    [my simulagora account]
    
    url = https://www.simulagora.com
    token_id = the token id
    secret = the token itself
    

Examples

We assume here that your .simulagorarc is correctly set up.

Examples directly from the command line. Get a list of the studies you can access:

$ simulagora studies
[{'eid': 4173, 'name': u'Study 1'},
 {'eid': 4277, 'name': u'Study 2'},
 {'eid': 4310, 'name': u'Study 3'}]
$ simulagora executables
[{'eid': 2454, 'name': u'Attente (secondes)'},
 {'eid': 2470, 'name': u'paraview'},
 {'eid': 4672, 'name': u'bash_command #0'},
 {'eid': 4883, 'name': u'lmgc90_donut'}]
$ simulagora parameter_defs 4672
{u'command': {'description': u'Command to be evaluated at script startup',
              'eid': 4673,
              'name': u'command',
              'value_type': u'String'}}

A more complete example using Python. Create a “Code Aster piston test” study and an eponym folder, upload the data in it, and run a Code Aster computation with this data as an input on a “m1.large” server, equiped with the last Simulagora machine image (which currently has Code Aster 11.5):

from simulagora import Simulagora
from time import sleep

client = Simulagora()

# create the folder, upload the files and get their identifiers
folder = client.create_folder('Code Aster piston test')
client.upload_files(folder, 'piston.comm', 'piston.mmed', 'piston.export')
file_eids = [f['eid'] for f in client.files_in_folder(folder)]

# get the "bash command" executable which will run the "as_run" command
executable = client.find_one('Executable', name='bash_command #0')
params = {'command': 'as_run piston.export'}

# get the server type, create the study and the run, then start it
server_type = client.find_one('CloudServerType', name='m1.large')
study = client.create_study('Code Aster piston test')
run = client.create_run(study, executable, server_type, file_eids, params)
client.start_run(run)

# check its state every 5 seconds until its crashed or completed
state = None
while state not in ('wfs_run_crashed', 'wfs_run_completed'):
    state = client.state(run)
    sleep(5)
print "Run " + state.rsplit('_', 1)[-1]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
simulagora-0.1.1.tar.gz (22.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page