以编程方式使用simulagora的python库
simulagora的Python项目详细描述
摘要
直接从 命令行或通过python程序。
使用Simulagora客户端
登录Simulagora并在 dedicated URL;
在用户的.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的更完整的示例。创建“活塞测试代码”研究 和一个同名文件夹,上传其中的数据,并运行一个代码aster计算 把这些数据作为“m1.large”服务器的输入 Simulagora机器图像(当前代码为ASTER 11.5):
fromsimulagoraimportSimulagorafromtimeimportsleepclient=Simulagora.for_instance('simulagora')# create the folder, upload the files and get their identifiersfolder=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" commandexecutable=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 itserver_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 completedstate=Nonewhilestatenotin('wfs_run_crashed','wfs_run_completed'):state=client.state(run)sleep(5)print"Run "+state.rsplit('_',1)[-1]