海洋供应商。
ocean-provider的Python项目详细描述
提供商
? Provide an off-chain database store for data assets metadata and registration and perform part of access control in collaboration with the keeper-contracts. oceanprotocol.com
有龙和乌贼这是在alpha状态,你可以预期会遇到问题。如果你碰到他们,请打开a new issue_
目录
功能
提供商处理所有与区块链无关的核心功能,包括计算和存储接口,以及与海洋守护者的连接。此外,提供者实现了Ocean的服务完整性和编排功能,允许请求、订购、计划、验证和管理服务
本地运行,用于开发和测试
如果您想为提供者的开发做出贡献,那么可以执行以下操作。(如果要在生产环境中运行提供商,则必须执行其他操作。)
首先,克隆此存储库:
git clone git@github.com:oceanprotocol/provider.git
cd provider/
然后运行一些提供商希望运行的内容:
cd docker
docker-compose up
你可以通过阅读docker/docker-compose.yml来了解它的运行方式。 注意,它运行MongoDB,但是提供者也可以使用BigChainDB或ElasticSearch。 它还运行Ganache和所有的Ocean Protocol Keeper Contracts和Ganache CLI。
最简单的方法是:
pip install -r requirements_dev.txt # or requirements_conda.txt if using CondaexportFLASK_APP=provider/run.py exportCONFIG_FILE=oceandb.ini ./scripts/deploy flask run
将使用http(即不是ssl/tls)。
运行flask应用程序的正确方法是使用应用服务器,如gunicorn。这允许您使用ssl/tls运行。 您可以通过执行以下操作生成一些用于测试的证书:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
当它要求公共名(cn)时,回答localhost
然后编辑配置文件oceandb.ini
,以便:
provider.scheme = httpsprovider.host = localhostprovider.port = 5000
然后执行此命令:
gunicorn --certfile cert.pem --keyfile key.pem -b 0.0.0.0:5000 -w 1 provider.run:app
API文档
应用程序运行后,您可以访问文档:
https://127.0.0.1:5000/api/v1/docs
(或者http
如果您使用的是http。)
提示:如果你的浏览器在顶部显示了一个夸张的标题,但是显示“未能加载规范”,那么我们发现,在chrome中,如果我们转到chrome://flags/allow unsecurelocalhost并将其切换到enabled,然后重新启动chrome,它就工作了。
如果您想进一步了解元数据的本体,可以在 OEP-8。
配置
可以使用config_file环境变量(推荐)传递配置,也可以在oceandb.ini文件中查找配置。
在配置中,现在有三个部分:
- oceandb:包含要连接到oceandb的不同值。您可以找到有关如何使用oceandbhere的更多信息。
- Keeper合同:本节帮助您连接部署合同的网络。您可以找到有关如何配置here的更多信息。
[keeper-contracts]keeper.host=0.0.0.0keeper.port=8545#contracts.folder=venv/contractsmarket.address=0xbc0be3598a31715bac5235718f96bb242804e61eauth.address=0x6ba5f72e5399aa67db5b22ee791851937d4910f5token.address=0xfd83b273b395b1029c41bb32071500bf662e6a8aprovider.address=
- 资源:此部分具有与不同资源提供程序连接的属性。目前我们只使用Azure,但这将迅速增加。
[resources]azure.account.name=testocnfilesazure.account.key=k2Vk4yfb88WNlWW+W54a8ytJm8MYO1GW9IgiV7TNGKSdmKyVNXzyhiRZ3U1OHRotj/vTYdhJj+ho30HPyJpuYQ==azure.container=testfiles
代码样式
关于python中代码样式的信息记录在这两个链接中python-developer-guide 以及python-style-guide。
测试
通过travis设置自动测试,执行tox
。
我们的测试使用pytest框架。
新版本
bumpversion.sh
脚本有助于提高项目版本可以使用第一个参数{major minor patch}来执行脚本,从而相应地提升版本。
许可证
Copyright 2018 Ocean Protocol Foundation Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.