苏门答腊服务器是一个django应用程序,它实现了一个基于http的计算实验记录存储。
sumatra-server的Python项目详细描述
苏门答腊服务器是一个Django应用程序,它为 计算实验记录(如模拟、脚本分析),包括 支持reproducible research的目标。
特别是,它实现了 HttpRecordStore客户端在Sumatra。
它基于Piston框架。
开始
下面假设您已经有了一个您希望的django项目 为计算实验添加记录存储。如果你没有,你可以 下载example project here。
您需要安装苏门答腊服务器、苏门答腊、活塞和 django-tagging。将以下行添加到 设置.py:
'sumatra_server', 'sumatra.web', 'sumatra.recordstore.django_store', 'tagging',
您的INSTALLED_APPS还应该包含'django.contrib.auth'和 'django.contrib.contenttypes'。
现在决定记录存储在url结构中的位置,并编辑 相应的url.py,例如:
urlpatterns = patterns('', # other url mappings (r'^records/', include('sumatra_server.urls')), )
现在运行syncdb:
$ python manage.py syncdb Creating tables ... Creating table sumatra_server_projectpermission Creating table django_store_project Creating table django_store_executable Creating table django_store_dependency Creating table django_store_repository Creating table django_store_parameterset Creating table django_store_launchmode Creating table django_store_datastore Creating table django_store_platforminformation Creating table django_store_record_platforms Creating table django_store_record_dependencies Creating table django_store_record Creating table tagging_tag Creating table tagging_taggeditem
如果要加载一些测试数据以进行测试,请运行:
$ python manage.py loaddata haggling permissions
这将用一些仿真记录填充记录存储,这些记录由 用户“testuser”,密码为“abc123”。
API
苏门答腊服务器实现了一个RESTfulapi,它返回html或json, 取决于http请求中的accept头。通常,如果您访问 通过网页浏览器浏览网页,你应该得到HTML版本,而苏门答腊岛或 兼容工具将接收json版本。您还可以重写accept 通过显式地将?format=html或?format=json添加到 网址。
URL | GET | POST | PUT | DELETE |
---|---|---|---|---|
/ | Return a list of projects | . | . | . |
/<project_name>/ | Return a list of records for the given project. May add a querystring ^{tt8}$ to show only records that have one of the supplied tags | . | Create a new project and give the current user permission to access the project | . |
/<project_name>/permissions/ | Return a list of users who can access this project | Give a user permission to access this project | . | . |
/<project_name>/<record_label>/ | Return the record with the given label | . | Create or update a record with the given label | Delete the record with the given label |
/<project_name>/tagged/<tag>/ | Return a list of records with the given tag (not yet implemented) | . | . | Delete all records having the given tag (not yet implemented) |
json格式
下面是一个使用json编码的模拟记录的示例。这是 必须用于将新记录放入存储区的格式:
{ "user": "testuser", "project_id": "TestProject", "label": "20100709-154255", "reason": "Simulation to test the HttpRecordStore with Sumatra Server", "outcome": "Eureka! Nobel prize here we come.", "executable": { "path": "/usr/local/bin/python", "version": "2.5.2", "name": "Python", "options": "" }, "repository": { "url": "/Users/andrew/tmp/SumatraTest", "type": "MercurialRepository" }, "version": "396c2020ca50", "diff": "", "main_file": "main.py", "parameters": { "content": "seed = 65785 # seed for random number generator\ndistr = \"uniform\" # statistical distribution to draw values from \nn = 100 # number of values to draw", "type": "SimpleParameterSet" }, "launch_mode": { "type": "SerialLaunchMode", "parameters": "{}" }, "timestamp": "2010-07-09 15:42:55", "duration": 0.58756184577941895, "datastore": { "type": "FileSystemDataStore", "parameters": "{'root': '/Users/andrew/tmp/SumatraTest/Data'}" }, "output_data": [ { "path": "output.dat", "digest": 'a39100d5130f613b96c9fcf605b68d53d60f6fdb', "metadata": "", } for key in record.output_data], "input_datastore": { "type": "FileSystemDataStore", , "parameters": "{'root': '/'}", }, "input_data": [], "dependencies": [ { "path": "/Library/Frameworks/Python.framework/Versions/4.0.30002/lib/python2.5/site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/matplotlib", "version": "0.98.3", "name": "matplotlib", "module": "python", "diff": "" }, { "path": "/Library/Frameworks/Python.framework/Versions/4.0.30002/lib/python2.5/site-packages/numpy-1.1.1.0001-py2.5-macosx-10.3-fat.egg/numpy", "version": "1.1.1", "name": "numpy", "module": "python", "diff": "" }, ], "platforms": [ { "system_name": "Darwin", "ip_addr": "127.0.0.1", "architecture_bits": "32bit", "machine": "i386", "architecture_linkage": "", "version": "Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386", "release": "9.8.0", "network_name": "localhost", "processor": "i386" } ], "tags": "" }
这些字段大多只写一次,即如果将另一个记录放在同一个记录中 url,只考虑“原因”、“结果”和“标记”的更改。
身份验证
苏门答腊服务器使用http基本身份验证,并针对用户进行验证 Django项目的数据库。