苏门答腊服务器是一个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添加到 网址。

Table showing the operations that can be performed on the record store.
URLGETPOSTPUTDELETE
/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 projectGive 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 labelDelete 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项目的数据库。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何获取给定日期范围内的日期列表?   处理多个同名XML条目的java Apache配置   java Jersey如何确定应用程序的基本URI?   用于错误报告的java连续屏幕记录   使用字符串对象的锁进行同步的java线程并发   正则表达式从Java中的字符串文本中提取重复模式集   java可以成为Liferay V6。0.6可以使用Maven构建系统编写吗?   JavaSpring和Hibernate上的java句柄软删除   java/cplex约束的线性化   java如何在Spring+JSP中查看发送请求和获取响应之间的时间差   ArrayQue对象的2d字符数组的java维度   ssl无法使用任何java技术从internet提取数据。网SocketException:java。安全NoSuchAlgorithmException   java如何检查应用程序是否第一次启动   java使用log4j通过SMTPAppender发送电子邮件报告