跳转到主要内容

一个用于程序化使用Simulagora的Python库

项目描述

摘要

一个用于从命令行或通过Python程序程序化使用Simulagora的Python库。

先决条件

您需要一个合适的cwclientlib安装,它本身需要Python 2.7和Python requests

当然还需要在Simulagora上有账户。

使用Simulagora客户端

  1. Simulagora上登录,并查看在专用URL上为您生成的令牌;

  2. 在您的用户.config目录中创建一个cwclientlibrc文件(只能由您自己读取),如下所示

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

示例

直接从命令行获取可以访问的研究列表示例。

$ 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'}]

使用Python的更完整示例。创建一个“Code Aster活塞测试”研究和一个同名的文件夹,上传其中的数据,然后在配备最新Simulagora机器镜像的“m1.large”服务器上使用这些数据作为输入运行Code Aster计算,该机器镜像目前有Code Aster 11.5。

from simulagora import Simulagora
from time import sleep

client = Simulagora.for_instance('simulagora')

# create the folder, upload the files and get their identifiers
folder = client.create_folder('Code Aster piston test')
file_eids = client.upload_files(folder, 'piston.comm', 'piston.mmed', 'piston.export')

# get the "bash command" executable which will run the "as_run" command
executable = client.find_one('Executable', name='bash command')
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='m3.xlarge')
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]

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

simulagora-0.5.0.tar.gz (19.3 kB 查看哈希值)

上传时间 源代码

由以下组织支持