Skip to content

Commit

Permalink
Merge pull request #5 from keyko-io/feature/update-names
Browse files Browse the repository at this point in the history
Udpate names to nevermined
  • Loading branch information
aaitor committed Apr 30, 2020
2 parents 0ee7a6b + 44883f6 commit 89a6ebf
Show file tree
Hide file tree
Showing 69 changed files with 226 additions and 222 deletions.
4 changes: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ Related to Issue #
- [ ] Follows the code style of this project.
- [ ] Tests Cover Changes
- [ ] Documentation

#### Funny gif

![Put a link of a funny gif inside the parenthesis-->]()
15 changes: 8 additions & 7 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
git clone https://github.com/keyko-io/nevermind-tools
cd nevermind-tools
export KEEPER_VERSION=v0.1.2
git clone https://github.com/keyko-io/nevermined-tools
cd nevermined-tools
export KEEPER_VERSION=v0.2.0
export METADATA_VERSION=latest
rm -rf "${HOME}/.nevermind/nevermind-contracts/artifacts"
bash -x start_nevermind.sh --no-commons --no-gateway --no-faucet --no-dashboard --latest 2>&1 > start_nevermind.log &
export EVENTS_HANDLER_VERSION=v0.2.0
rm -rf "${HOME}/.nevermined/nevermined-contracts/artifacts"
bash -x start_nevermined.sh --no-commons --no-gateway --no-faucet --no-dashboard 2>&1 > start_nevermined.log &
cd ..
for i in $(seq 1 50); do
sleep 5
[ -f "${HOME}/.nevermind/nvermind-contracts/artifacts/ready" ] && break
[ -f "${HOME}/.nevermined/nvermind-contracts/artifacts/ready" ] && break
done
ls -la "${HOME}/.nevermind/nevermind-contracts/artifacts/"
ls -la "${HOME}/.nevermined/nevermined-contracts/artifacts/"
./scripts/wait_for_migration_and_extract_keeper_artifacts.sh
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ docker/docs
squid_py.db
consume-downloads
.log
start_nevermind.log
start_nevermined.log
errors.log.*
info.log.*
*.db
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
History
=======

0.2.0 (April, 2020)
-------------------------

* [#4](https://github.com/keyko-io/nevermined-sdk-py/issues/4) Migrate squid-py
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include CHANGELOG.md
include LICENSE
include README.md
include nevermind_skd_py/agreements/access_sla_template.json
include nevermined_skd_py/agreements/access_sla_template.json

recursive-include tests *
recursive-exclude * __pycache__
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Nevermind
Nevermined
Copyright 2020 Keyko GmbH.

This product includes software developed at
Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![banner](https://raw.githubusercontent.com/keyko-io/assets/master/images/logo/small/keyko_logo@2x-100.jpg)](https://keyko.io)

# Python API for Nevermind Data platform
# Python API for Nevermined Data platform

> 🦑 Python SDK for connecting with Nevermind Data Platform
> 🦑 Python SDK for connecting with Nevermined Data Platform
> [keyko.io](https://keyko.io)
[![PyPI](https://img.shields.io/pypi/v/nevermind-sdk-py.svg)](https://pypi.org/project/nevermind-sdk-py/)
[![PyPI](https://img.shields.io/pypi/v/nevermined-sdk-py.svg)](https://pypi.org/project/nevermined-sdk-py/)

---

Expand Down Expand Up @@ -37,7 +37,7 @@ Python 3.6
Install Squid:

```
pip install nevermind-sdk-py
pip install nevermined-sdk-py
```

### Usage:
Expand All @@ -46,54 +46,54 @@ pip install nevermind-sdk-py
import os
import time

from nevermind_sdk_py import (
Nevermind,
from nevermined_sdk_py import (
Nevermined,
ConfigProvider,
Config,
Metadata,
Account
)

ConfigProvider.set_config(Config('config.ini'))
# Make a new instance of Nevermind
nevermind = Nevermind() # or Nevermind(Config('config.ini'))
config = nevermind.config
# Make a new instance of Nevermined
nevermined = Nevermined() # or Nevermined(Config('config.ini'))
config = nevermined.config
# make account instance, assuming the ethereum account and password are set
# in the config file `config.ini`
account = nevermind.accounts.list()[0]
account = nevermined.accounts.list()[0]
# or
account = Account(config.parity_address, config.parity_password)

# PUBLISHER
# Let's start by registering an asset in the Nevermind network
# Let's start by registering an asset in the Nevermined network
metadata = Metadata.get_example()

# consume and service endpoints require `gateway.url` is set in the config file
# or passed to Nevermind instance in the config_dict.
# or passed to Nevermined instance in the config_dict.
# define the services to include in the new asset DDO

ddo = nevermind.assets.create(metadata, account)
ddo = nevermined.assets.create(metadata, account)

# Now we have an asset registered, we can verify it exists by resolving the did
_ddo = nevermind.assets.resolve(ddo.did)
_ddo = nevermined.assets.resolve(ddo.did)
# ddo and _ddo should be identical

# CONSUMER
# search for assets
asset_ddo = nevermind.assets.search('Nevermind protocol')[0]
asset_ddo = nevermined.assets.search('Nevermined protocol')[0]
# Need some ocean tokens to be able to order assets
nevermind.accounts.request_tokens(account, 10)
nevermined.accounts.request_tokens(account, 10)

# Start the purchase/consume request. This will automatically make a payment from the specified account.
consumer_account = nevermind.accounts.list()[1]
service_agreement_id = nevermind.assets.order(asset_ddo.did, 0, consumer_account)
consumer_account = nevermined.accounts.list()[1]
service_agreement_id = nevermined.assets.order(asset_ddo.did, 0, consumer_account)

# after a short wait (seconds to minutes) the asset data files should be available in the `downloads.path` defined in config
# wait a bit to let things happen
time.sleep(20)

# Asset files are saved in a folder named after the asset id
dataset_dir = os.path.join(nevermind.config.downloads_path, f'datafile.{asset_ddo.asset_id}.0')
dataset_dir = os.path.join(nevermined.config.downloads_path, f'datafile.{asset_ddo.asset_id}.0')
if os.path.exists(dataset_dir):
print('asset files downloaded: {}'.format(os.listdir(dataset_dir)))

Expand Down Expand Up @@ -152,13 +152,13 @@ In addition to the configuration file, you may use the following environment var
pip install -r requirements_dev.txt
```

1. Create the local testing environment using [nevermind-tools](https://github.com/keyko-io/nevermind-tools). Once cloned that repository, you can start the cluster running:
1. Create the local testing environment using [nevermined-tools](https://github.com/keyko-io/nevermined-tools). Once cloned that repository, you can start the cluster running:

```
./start_nevermind.sh --latest --no-gateway --no-common --local-spree-node
./start_nevermined.sh --latest --no-gateway --no-common --local-spree-node
```

It runs a Nevermind Metadata node and an Ethereum RPC client. For details, read `docker-compose.yml`.
It runs a Nevermined Metadata node and an Ethereum RPC client. For details, read `docker-compose.yml`.

1. Create local configuration file

Expand Down
4 changes: 2 additions & 2 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The nevermind-sdk-py Release Process
# The nevermined-sdk-py Release Process

- Create a new local feature branch, e.g. `git checkout -b feature/bumpversion-to-v0.2.5`
- Use the `bumpversion.sh` script to bump the project version. You can execute the script using {major|minor|patch} as first argument to bump the version accordingly:
Expand All @@ -11,7 +11,7 @@
- Wait for all the tests to pass!
- Merge the pull request into the `develop` branch.
- To make a GitHub release (which creates a Git tag):
- Go to the nevermind-sdk-py repo's Releases page [https://github.com/keyko-io/nevermind-sdk-py/releases](https://github.com/keyko-io/nevermind-sdk-py/releases)
- Go to the nevermined-sdk-py repo's Releases page [https://github.com/keyko-io/nevermined-sdk-py/releases](https://github.com/keyko-io/nevermined-sdk-py/releases)
- Click "Draft a new release".
- For tag version, put something like `v0.2.5`
- For release title, put the same value (like `v0.2.5`).
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = nevermind-sdk-py
SPHINXPROJ = nevermined-sdk-py
SOURCEDIR = source
BUILDDIR = build

Expand Down
10 changes: 5 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright 2018 Nevermind Protocol Foundation
# Copyright 2018 Nevermined Protocol Foundation
# SPDX-License-Identifier: Apache-2.0

#
Expand All @@ -25,9 +25,9 @@

# -- Project information -----------------------------------------------------

project = 'nevermind-sdk-py'
copyright = 'nevermind-sdk-py contributors'
author = 'nevermind-sdk-py contributors'
project = 'nevermined-sdk-py'
copyright = 'nevermined-sdk-py contributors'
author = 'nevermined-sdk-py contributors'

# The full version, including alpha/beta/rc tags
release = '0.1.0'
Expand All @@ -48,7 +48,7 @@

# apidoc settings
# See https://github.com/sphinx-contrib/apidoc
apidoc_module_dir = '../../nevermind_sdk_py'
apidoc_module_dir = '../../nevermined_sdk_py'
# apidoc_output_dir = 'api' by default, and leave it that way!
apidoc_separate_modules = True
# See https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nevermind-sdk-py API Reference Docs
nevermined-sdk-py API Reference Docs
===========================

These docs are API Reference docs.
Expand Down
34 changes: 17 additions & 17 deletions examples/buy_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from common_utils_py.agreements.service_types import ServiceTypes

from examples import ExampleConfig, example_metadata
from nevermind_sdk_py import ConfigProvider, Nevermind
from nevermind_sdk_py.nevermind.keeper import NevermindKeeper as Keeper
from nevermined_sdk_py import ConfigProvider, Nevermined
from nevermined_sdk_py.nevermined.keeper import NeverminedKeeper as Keeper
from tests.resources.helper_functions import get_account


Expand All @@ -28,7 +28,7 @@ def _process_event(event):

def buy_asset():
"""
Requires all Nevermind services running.
Requires all Nevermined services running.
"""
ConfigProvider.set_config(ExampleConfig.get_config())
Expand All @@ -37,25 +37,25 @@ def buy_asset():
'duero': '0xfEF2d5e1670342b9EF22eeeDcb287EC526B48095',
'nile': '0x4aaab179035dc57b35e2ce066919048686f82972'
}
# make nevermind instance
nevermind = Nevermind()
# make nevermined instance
nevermined = Nevermined()
Diagnostics.verify_contracts()
acc = get_account(0)
if not acc:
acc = ([acc for acc in nevermind.accounts.list() if acc.password] or nevermind.accounts.list())[0]
acc = ([acc for acc in nevermined.accounts.list() if acc.password] or nevermined.accounts.list())[0]

keeper = Keeper.get_instance()
# Register ddo
did = '' # 'did:nv:7648596b60f74301ae1ef9baa5d637255d517ff362434754a3779e1de4c8219b'
if did:
ddo = nevermind.assets.resolve(did)
ddo = nevermined.assets.resolve(did)
logging.info(f'using ddo: {did}')
else:
ddo = nevermind.assets.create(example_metadata.metadata, acc, providers=[], use_secret_store=True)
ddo = nevermined.assets.create(example_metadata.metadata, acc, providers=[], use_secret_store=True)
assert ddo is not None, f'Registering asset on-chain failed.'
did = ddo.did
logging.info(f'registered ddo: {did}')
# nevermind here will be used only to publish the asset. Handling the asset by the publisher
# nevermined here will be used only to publish the asset. Handling the asset by the publisher
# will be performed by the Gateway server running locally
test_net = os.environ.get('TEST_NET', '')
if test_net.startswith('nile'):
Expand Down Expand Up @@ -83,24 +83,24 @@ def buy_asset():
logging.info(f'is {provider} set as did provider: '
f'{keeper.did_registry.is_did_provider(ddo.asset_id, provider)}')

nevermind_cons = Nevermind()
nevermined_cons = Nevermined()
consumer_account = get_account(1)

# sign agreement using the registered asset did above
service = ddo.get_service(service_type=ServiceTypes.ASSET_ACCESS)
# This will send the order request to Gateway which in turn will execute the agreement on-chain
nevermind_cons.accounts.request_tokens(consumer_account, 10)
nevermined_cons.accounts.request_tokens(consumer_account, 10)
sa = ServiceAgreement.from_service_dict(service.as_dictionary())
agreement_id = ''
if not agreement_id:
# Use these 2 lines to request new agreement from Gateway
# agreement_id, signature = nevermind_cons.agreements.prepare(did, sa.service_definition_id,
# agreement_id, signature = nevermined_cons.agreements.prepare(did, sa.service_definition_id,
# consumer_account)
# nevermind_cons.agreements.send(did, agreement_id, sa.service_definition_id, signature,
# nevermined_cons.agreements.send(did, agreement_id, sa.service_definition_id, signature,
# consumer_account)

# assets.order now creates agreement directly using consumer account.
agreement_id = nevermind_cons.assets.order(
agreement_id = nevermined_cons.assets.order(
did, sa.index, consumer_account)

logging.info('placed order: %s, %s', did, agreement_id)
Expand All @@ -121,14 +121,14 @@ def buy_asset():
)
logging.info(f'Got access event {event}')
i = 0
while nevermind.agreements.is_access_granted(
while nevermined.agreements.is_access_granted(
agreement_id, did, consumer_account.address) is not True and i < 15:
time.sleep(1)
i += 1

assert nevermind.agreements.is_access_granted(agreement_id, did, consumer_account.address)
assert nevermined.agreements.is_access_granted(agreement_id, did, consumer_account.address)

nevermind.assets.consume(
nevermined.assets.consume(
agreement_id,
did,
sa.index,
Expand Down
4 changes: 2 additions & 2 deletions examples/example_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2018 Nevermind Protocol Foundation
# Copyright 2018 Nevermined Protocol Foundation
# SPDX-License-Identifier: Apache-2.0

import logging
import os
import sys

from nevermind_sdk_py import Config
from nevermined_sdk_py import Config


def get_variable_value(variable):
Expand Down
4 changes: 2 additions & 2 deletions examples/example_metadata.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright 2018 Nevermind Protocol Foundation
# Copyright 2018 Nevermined Protocol Foundation
# SPDX-License-Identifier: Apache-2.0
import uuid

metadata = {
"main": {
"name": "Nevermind protocol white paper",
"name": "Nevermined protocol white paper",
"dateCreated": "2012-02-01T10:55:11Z",
"author": "Mario",
"license": "CC0: Public Domain",
Expand Down

0 comments on commit 89a6ebf

Please sign in to comment.