🐳 Ocean Brizo.
Project description
Brizo
Helping publishers provide extended data services (e.g. storage and compute). oceanprotocol.com
"🏄♀️🌊 Brizo is an ancient Greek goddess who was known as the protector of mariners, sailors, and fishermen. She was worshipped primarily by the women of Delos, who set out food offerings in small boats. Brizo was also known as a prophet specializing in the interpretation of dreams."
🐲🦑 THERE BE DRAGONS AND SQUIDS. This is in alpha state and you can expect running into problems. If you run into them, please open up a new issue. 🦑🐲
Table of Contents
- Features
- Running Locally, for Dev and Test
- API documentation
- Configuration
- Dependencies
- Code Style
- Testing
- Debugging
- New Version
- License
Features
In the Ocean ecosystem, Brizo is the technical component executed by the Publishers allowing them to provide extended data services (e.g. storage and compute). Brizo, as part of the Publisher ecosystem, includes the credentials to interact with the infrastructure (initially cloud, but could be on-premise).
The main features available in Brizo:
- Data access - using the
/services/consume
endpoint. The data set file(s) are streamed back to the user without exposing the actual URL - Compute-to-data - using the
/services/compute
endpoint. The compute algorithm is executed remotely use the compute provider's Service Operator endpoint.
Details of the main features can be found in the Brizo API documentation
Running Locally, for Dev and Test
If you want to contribute to the development of Brizo, then you could do the following. (If you want to run a Brizo in production, then you will have to do something else.)
First, clone this repository:
git clone git@github.com:oceanprotocol/brizo.git
cd brizo/
Before running it locally we recommend to set up virtual environment:
virtualenv venv -p python3.6
source venv/bin/activate
And install all the requirements:
pip install -r requirements_dev.txt
Then run some things that Brizo expects to be running:
git clone git@github.com:oceanprotocol/barge.git
cd barge
bash start_ocean.sh --no-brizo --no-commons
Barge is the repository where all the Ocean Docker Compose files are located.
We are running the script start_ocean.sh --no-brizo
: the easy way to have Ocean projects
up and running. We run without a Brizo instance.
To learn more about Barge, visit the Barge repository.
Note that it runs an Aquarius instance and an Elasticsearch instance but Aquarius can also work with BigchainDB or MongoDB.
The most simple way to start is:
pip install -r requirements_dev.txt
export FLASK_APP=brizo/run.py
export CONFIG_FILE=config.ini
./scripts/wait_for_migration_and_extract_keeper_artifacts.sh
export PROVIDER_ADDRESS="your ethereum address goes here"
# Set one of the following
export PROVIDER_KEY="the private key"
export PROVIDER_ENCRYPTED_KEY="The encrypted key json from the keyfile"
export PROVIDER_KEYFILE="your ethereum address goes here"
# and set the password if using either PROVIDER_KEYFILE or PROVIDER_ENCRYPTED_KEY
export PROVIDER_PASSWORD="password to allow decrypting the encrypted key"
flask run --port=8030
That will use HTTP (i.e. not SSL/TLS).
The proper way to run the Flask application is using an application server such as Gunicorn. This allow you to run using SSL/TLS. You can generate some certificates for testing by doing:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
and when it asks for the Common Name (CN), answer localhost
Then edit the config file config.ini
so that:
brizo.url = https://localhost:8030
Then execute this command:
gunicorn --certfile cert.pem --keyfile key.pem -b 0.0.0.0:8030 -w 1 brizo.run:app
API documentation
Once you have Brizo running you can get access to the API documentation at:
https://127.0.0.1:8030/api/v1/docs
There is also some Brizo API documentation in the official Ocean docs.
Configuration
To get configuration settings, Brizo first checks to see if there is a non-empty
environment variable named CONFIG_FILE. It there is, it will look in a config file
at that path. Otherwise it will look in a config file named config.ini
. Note
that some settings in the config file can be overridden by setting certain
environment variables; there are more details below.
See the example config.ini file in this repo. You will see that
there are three sections: [keeper-contracts]
, [resources]
and [osmosis]
.
The [keeper-contracts] and [resources] Sections
The [keeper-contracts]
section is used to setup connection to the keeper nodes
and load keeper-contracts artifacts.
The [resources]
sections is used to configure:
- Default Metadata store (Aquarius) URI
- Default Brizo URI
- Operator Service URI for for requesting compute services
The [osmosis] Section
The [osmosis]
section of the config file is where a provider puts their own
credentials for various third-party services, such as Azure Storage.
Brizo could support files with the following kinds of URLs:
- files in Azure Storage: files with "core.windows.net" in their URLs
- files in Amazon S3 storage: files with "s3://" in their URLs
- files on ipfs: files URLs starting with "ipfs://"
- files in on-premise storage: all other files with resolvable URLs
A publisher can choose to support any of the above or build their own custom driver. It depends on which cloud providers they use.
If a publisher wants to store some files in Azure Storage (and make them available from there), then they must get and set the following config settings in the [osmosis] section of the config file. There is an Ocean tutorial about how to get all those credentials from Azure.
[osmosis]
azure.account.name = <Azure Storage Account Name (for storing files)>
azure.account.key = <Azure Storage Account key>
azure.resource_group = <Azure resource group>
azure.location = <Azure Region>
azure.client.id = <Azure Application ID>
azure.client.secret = <Azure Application Secret>
azure.tenant.id = <Azure Tenant ID>
azure.subscription.id = <Azure Subscription>
; azure.share.input and azure.share.output are only used
; for Azure Compute data assets (not for Azure Storage data assets).
; If you're not supporting Azure Compute, just leave their values
; as compute and output, respectively.
azure.share.input = compute
azure.share.output = output
You can override any of those config file settings by setting one or more of the following environment variables. You will want to do that if you're running Brizo in a container.
AZURE_ACCOUNT_NAME
AZURE_ACCOUNT_KEY
AZURE_RESOURCE_GROUP
AZURE_LOCATION
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_TENANT_ID
AZURE_SUBSCRIPTION_ID
# Just always set AZURE_SHARE_INPUT='compute' for now
AZURE_SHARE_INPUT='compute'
# Just always set AZURE_SHARE_OUTPUT='output' for now
AZURE_SHARE_OUTPUT='output'
If a publisher wants to store some files in Amazon S3 storage (and make them available from there), then there are no AWS-related config settings to set in the config file. AWS credentials actually get stored elsewhere. See the Ocean tutorial about how to set up Amazon S3 storage.
If a publisher wants to support files on IPFS storage, the only requirement is to
set the environment variable IPFS_GATEWAY
which defaults to "https://gateway.ipfs.io"
in the osmosis-ipfs-driver
.
If a publisher wants to store some files on-premise (and make them available from there), then there are no special config settings to set in the config file. The only requirement is that the file URLs must be resolvable by Brizo. See the Ocean tutorial about how to set up on-premise storage.
Compute-to-Data setup
Do the following to support the Compute to data feature:
- Set the Operator Service URI using one of the following:
- In config.ini under
operator_service.url
in theresources
section - Environment variable
OPERATOR_SERVICE_URL
- In config.ini under
- Add the Provider ethereum address to the Operator Service list of providers. The Operator Service only accepts requests signed by known providers
- Setup the Operator Service, Operator Engine and the Kubernetes infrastructure, more details here Operator Service
Dependencies
Brizo relies on the following Ocean libraries:
- ocean-utils provides common functions and datastructures for interaction with the Ocean Protocol components
- ocean-keeper handles all of the
keeper
interactions - ocean-secret-store-client to encrypt/decrypt the dataset urls
- osmosis-azure-driver mediates access to assets in Azure
- osmosis-aws-driver mediates access to assets in AWS
- osmosis-on-premise-driver mediates access to on-premise assets
Code Style
Information about our Python code style is documented in the python-developer-guide and the python-style-guide.
Testing
Automatic tests are setup via Travis (in .travis.yaml config file),
executing tox
(see the tox.ini file).
Our tests use the pytest framework.
Debugging
To debug Brizo using PyCharm, follow the next instructions:
-
Clone barge repository.
-
Run barge omitting
brizo
. (i.e.:bash start_ocean.sh --no-brizo --no-commons --local-nile-node
) -
In PyCharm, go to Settings > Project Settings > Python Debugger, and select the option Gevent Compatible
-
Configure a new debugger configuration: Run > Edit Configurations..., there click on Add New Configuration
-
Configure as shown in the next image:
-
Set the following environment variables:
PYTHONUNBUFFERED=1 CONFIG_FILE=config.ini AZURE_ACCOUNT_NAME=<COMPLETE_WITH_YOUR_DATA> AZURE_TENANT_ID=<COMPLETE_WITH_YOUR_DATA> AZURE_SUBSCRIPTION_ID=<COMPLETE_WITH_YOUR_DATA> AZURE_LOCATION=<COMPLETE_WITH_YOUR_DATA> AZURE_CLIENT_SECRET=<COMPLETE_WITH_YOUR_DATA> AZURE_CLIENT_ID=<COMPLETE_WITH_YOUR_DATA> AZURE_ACCOUNT_KEY=<COMPLETE_WITH_YOUR_DATA> AZURE_RESOURCE_GROUP=<COMPLETE_WITH_YOUR_DATA> OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
The option
OBJC_DISABLE_INITIALIZE_FORK_SAFETY
is needed if you run in last versions of MacOS. -
Now you can configure your breakpoints and debug brizo.
New Version
The bumpversion.sh
script helps to bump the project version. You can execute
the script using as first argument {major|minor|patch} to bump the version accordingly.
License
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ocean-brizo-0.9.7.tar.gz
.
File metadata
- Download URL: ocean-brizo-0.9.7.tar.gz
- Upload date:
- Size: 37.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aac807fd4d63e6d0d94e5e97eff1adc0cf92ecdf59110896bcc642d3f956c011 |
|
MD5 | 903bf3fe91df50d219751243bbff55d5 |
|
BLAKE2b-256 | 3e7e59abc7b3dabaa9dacee19e0c1acb573f548a70760b19204f558093c3ff36 |
File details
Details for the file ocean_brizo-0.9.7-py2.py3-none-any.whl
.
File metadata
- Download URL: ocean_brizo-0.9.7-py2.py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c1c6d7bb879e1bea664b276bc8d6ed09c0b8f6196b38543709c708ae254b98 |
|
MD5 | a10ae15cb6bf91bc9b497313023cac2e |
|
BLAKE2b-256 | 6af5e9b3c425fa26a741c5292f9693e2a0aa4e71f0b72f66a79e714638f07d1d |