跳转到主要内容

Sumatra Server是一个Django应用程序,它实现了基于HTTP的存储,用于记录计算实验。

项目描述

Sumatra Server是一个 Django 应用程序,它实现了基于HTTP的存储,用于记录计算实验(例如模拟、脚本分析),目的是支持 可重复研究

特别是,它实现了Sumatra中的客户端 HttpRecordStore 的服务器端对应物。

它基于 Piston 框架。

入门

以下假设您已经有一个Django项目,并希望向其中添加计算实验记录存储。如果没有,您可以在此处下载一个 示例项目

您需要已安装Sumatra Server、Sumatra、Piston和 django-tagging。将以下行添加到您的settings.py中的 INSTALLED_APPS 元组中

'sumatra_server',
'sumatra.web',
'sumatra.recordstore.django_store',
'tagging',

您的 INSTALLED_APPS 应该还包含 'django.contrib.auth''django.contrib.contenttypes'

现在确定记录存储将在您的URL结构中的哪个位置,并相应地编辑您的urls.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

Sumatra服务器实现了一个RESTful API,根据HTTP请求中的Accept头返回HTML或JSON。通常情况下,如果您通过网页浏览器访问页面,应该得到HTML版本,而Sumatra或兼容工具将接收到JSON版本。您也可以通过在URL末尾显式添加?format=html?format=json来覆盖Accept头。

表格显示了可以执行记录存储的操作.

URL

GET

POST

PUT

DELETE

/

返回项目列表

.

.

.

/<项目名称>/

返回给定项目的记录列表。可以添加查询字符串?tags=tag1,tag2以仅显示具有所提供标签之一的记录

.

创建新的项目并授予当前用户访问项目的权限

.

/<项目名称>/permissions/

返回可以访问此项目的用户列表

授予用户访问此项目的权限

.

.

/<项目名称>/<记录标签>/

返回给定标签的记录

.

创建或更新给定标签的记录

删除给定标签的记录

/<项目名称>/tagged/<标签>/

返回具有给定标签的记录列表(尚未实现)

.

.

删除具有给定标签的所有记录(尚未实现)

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": ""
}

大多数这些字段是只写一次的,即如果您将另一个记录PUT到相同的URL,只有“原因”、“结果”和“标签”的变化将被考虑。

身份验证

Sumatra服务器使用HTTP基本身份验证,并验证您的Django项目的用户数据库。

项目详情


下载文件

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

源分布

sumatra-server-0.3.0.tar.gz (16.9 kB 查看散列值)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面