Skip to content

Commit

Permalink
Merge pull request #214 from oceanprotocol/feature/oep8-small-fixes
Browse files Browse the repository at this point in the history
Feature/oep8 small fixes
  • Loading branch information
Enrique Ruiz authored Aug 16, 2019
2 parents ae08c2a + 561484d commit 7ed3cde
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.0
current_version = 0.4.1
commit = True
tag = True

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
History
=======

0.4.1 (Aug 16th, 2019)
----------------------
* Change serviceDefinitionId to index
* Type of services have to be lowercase

0.4.0 (Aug 13th, 2019)
----------------------
* Update to the new DDO structure with main instead of base.
Expand Down
2 changes: 1 addition & 1 deletion aquarius/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# SPDX-License-Identifier: Apache-2.0

__author__ = """OceanProtocol"""
__version__ = '0.4.0'
__version__ = '0.4.1'
36 changes: 18 additions & 18 deletions aquarius/app/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,21 @@ def register():
service:
type: array
description: List of services.
example: [{"type": "Authorization",
example: [{"type": "authorization",
"serviceEndpoint": "http://localhost:12001",
"service": "SecretStore",
"serviceDefinitionId": "0"
"index": 0
},
{"type": "Access",
"serviceDefinitionId": "1",
{"type": "access",
"index": 1,
"serviceEndpoint":
"http://localhost:8030/api/v1/brizo/services/consume",
"purchaseEndpoint":
"http://localhost:8030/api/v1/brizo/services/access/initialize"
},
{
"type": "Metadata",
"serviceDefinitionId": "2",
"type": "metadata",
"index": 2,
"serviceEndpoint":
"http://myaquarius.org/api/v1/provider/assets/metadata/did:op
:0c184915b07b44c888d468be85a9b28253e80070e5294b1aaed81c2f0264e430",
Expand Down Expand Up @@ -251,8 +251,8 @@ def register():
_record = copy.deepcopy(data)
_record['created'] = datetime.strptime(data['created'], '%Y-%m-%dT%H:%M:%SZ')
for service in _record['service']:
if service['type'] == 'Metadata':
service_id = int(service['serviceDefinitionId'])
if service['type'] == 'metadata':
service_id = int(service['index'])
if Config(filename=app.config['CONFIG_FILE']).allow_free_assets_only == 'true':
if _record['service'][service_id]['attributes']['main']['price'] != "0":
logger.warning('Priced assets are not supported in this marketplace')
Expand Down Expand Up @@ -349,20 +349,20 @@ def update(did):
service:
type: array
description: List of services.
example: [{"type": "Access",
"serviceDefinitionId": "1",
example: [{"type": "access",
"index": 1,
"serviceEndpoint":
"http://localhost:8030/api/v1/brizo/services/consume",
"purchaseEndpoint":
"http://localhost:8030/api/v1/brizo/services/access/initialize"},
{"type": "Authorization",
{"type": "authorization",
"serviceEndpoint": "http://localhost:12001",
"service": "SecretStore",
"serviceDefinitionId": "0"
"index": 0
},
{
"type": "Metadata",
"serviceDefinitionId": "2",
"type": "metadata",
"index": 2,
"serviceEndpoint":
"http://myaquarius.org/api/v1/provider/assets/metadata/did:op
:0c184915b07b44c888d468be85a9b28253e80070e5294b1aaed81c2f0264e430",
Expand Down Expand Up @@ -455,7 +455,7 @@ def update(did):
return _sanitize_record(_record), 201
else:
for service in _record['service']:
if service['type'] == 'Metadata':
if service['type'] == 'metadata':
if Config(filename=app.config['CONFIG_FILE']).allow_free_assets_only == 'true':
if _record['service'][0]['attributes']['main']['price'] != "0":
logger.warning('Priced assets are not supported in this marketplace')
Expand Down Expand Up @@ -713,7 +713,7 @@ def check_no_urls_in_files(main, method):

def _get_metadata(services):
for service in services:
if service['type'] == 'Metadata':
if service['type'] == 'metadata':
return service


Expand Down Expand Up @@ -758,9 +758,9 @@ def _make_paginate_response(query_list_result, search_model):
def _reorder_services(services):
result = []
for service in services:
if service['type'] == 'Metadata':
if service['type'] == 'metadata':
result.append(service)
for service in services:
if service['type'] != 'Metadata':
if service['type'] != 'metadata':
result.append(service)
return result
2 changes: 1 addition & 1 deletion aquarius/app/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ def query(self, query):
@staticmethod
def is_listed(services):
for service in services:
if service['type'] == 'Metadata':
if service['type'] == 'metadata':
if 'curation' in service['attributes'] and 'isListed' in service['attributes']['curation']:
return service['attributes']['curation']['isListed']
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/oceanprotocol/aquarius',
version='0.4.0',
version='0.4.1',
zip_safe=False,
)
121 changes: 63 additions & 58 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ def client():
],
"service": [
{
"type": "Authorization",
"type": "authorization",
"serviceEndpoint": "http://localhost:12001",
"service": "SecretStore",
"serviceDefinitionId": "0"
"index": 0
},
{
"type": "Access",
"type": "access",
"serviceEndpoint": "http://localhost:8030/api/v1/brizo/services/consume",
"purchaseEndpoint": "http://localhost:8030/api/v1/brizo/services/access/initialize",
"serviceDefinitionId": "1",
"index": 1,
"templateId": "0x208aca4B0316C9996F085cbD57E01c11Bc0E7cb1",
"name": "dataAssetAccessServiceAgreement",
"creator": "",
Expand Down Expand Up @@ -219,24 +219,16 @@ def client():
}
},
{
"type": "Metadata",
"type": "metadata",
"serviceEndpoint": "http://localhost:5000/api/v1/aquarius/assets/ddo/did:op:0c184915b07b44c888d468be85a9b28253e80070e5294b1aaed81c2f0264e430",
"attributes": {
"main": {
"name": "Ocean protocol white paper",
"type": "dataset",
"description": "Introduce the main concepts and vision behind ocean protocol",
"dateCreated": "2012-10-10T17:00:00Z",
"datePublished": "2012-10-10T17:00:00Z",
"author": "Ocean Protocol Foundation Ltd.",
"license": "CC-BY",
"copyrightHolder": "Ocean Protocol Foundation Ltd.",
"workExample": "Text PDF",
"inLanguage": "en",
"categories": [
"white-papers"
],
"tags": ["data exchange", "sharing", "curation", "bonding curve"],
"price": "888000000000000000000000000000000",
"files": [
{
Expand All @@ -261,17 +253,6 @@ def client():

}
],
"links": [
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-averages-25km/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/"
}
],
"checksum": "0x6d78a905bd54d373f71940f8b441bb2ef10758a47dab5b94a94becd688a9e58c",
"encryptedFiles": "<tests.resources.mocks.secret_store_mock.SecretStoreMock object at 0x7f8146a94710>.0c184915b07b44c888d468be85a9b28253e80070e5294b1aaed81c2f0264e430!![{\"url\": \"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.pdf\", \"checksum\": \"efb2c764274b745f5fc37f97c6b0e761\", \"checksumType\": \"MD5\", \"contentLength\": \"4535431\", \"resourceId\": \"access-log2018-02-13-15-17-29-18386C502CAEA932\"}, {\"url\": \"s3://ocean-test-osmosis-data-plugin-dataseeding-1537375953/data.txt\", \"checksum\": \"efb2c764274b745f5fc37f97c6b0e761\", \"contentLength\": \"4535431\", \"resourceId\": \"access-log2018-02-13-15-17-29-18386C502CAEA932\"}, {\"url\": \"http://ipv4.download.thinkbroadband.com/5MB.zip\"}]!!0"
},
Expand All @@ -281,6 +262,27 @@ def client():
"schema": "Binary Voting"
},
"additionalInformation": {
"description": "Introduce the main concepts and vision behind ocean protocol",
"copyrightHolder": "Ocean Protocol Foundation Ltd.",
"workExample": "Text PDF",
"inLanguage": "en",
"categories": [
"white-papers"
],
"tags": ["data exchange", "sharing", "curation", "bonding curve"],
"links": [
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs"
"-daily/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs"
"-averages-25km/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/"
}
],
"updateFrequency": "yearly",
"structuredMarkup": [
{
Expand All @@ -294,7 +296,7 @@ def client():
]
}
},
"serviceDefinitionId": "2"
"index": 2
}
],
"proof": {
Expand Down Expand Up @@ -323,16 +325,16 @@ def client():
],
"service": [
{
"type": "Authorization",
"type": "authorization",
"serviceEndpoint": "http://localhost:12001",
"service": "SecretStore",
"serviceDefinitionId": "0"
"index": 0
},
{
"type": "Access",
"type": "access",
"serviceEndpoint": "http://localhost:8030/api/v1/brizo/services/consume",
"purchaseEndpoint": "http://localhost:8030/api/v1/brizo/services/access/initialize",
"serviceDefinitionId": "1",
"index": 1,
"templateId": "0x208aca4B0316C9996F085cbD57E01c11Bc0E7cb1",
"name": "dataAssetAccessServiceAgreement",
"creator": "",
Expand Down Expand Up @@ -481,24 +483,17 @@ def client():
}
},
{
"type": "Metadata",
"type": "metadata",
"serviceEndpoint": "http://localhost:5000/api/v1/aquarius/assets/ddo/did:op:0c184915b07b44c888d468be85a9b28253e80070e5294b1aaed81c2f0264e430",
"attributes": {
"main": {
"name": "Ocean protocol white paper",
"type": "dataset",
"description": "Introduce the main concepts and vision behind ocean protocol",
"dateCreated": "2012-10-10T17:00:00Z",
"datePublished": "2012-10-10T17:00:00Z",
"author": "Ocean Protocol Foundation Ltd.",
"license": "CC-BY",
"copyrightHolder": "Ocean Protocol Foundation Ltd.",
"workExample": "Text PDF",
"inLanguage": "en",
"categories": [
"white-papers"
],
"tags": ["data exchange", "sharing", "curation", "bonding curve"],

"price": "888000000000000000000000000000000",
"files": [
{
Expand All @@ -521,17 +516,6 @@ def client():
"contentType": "text/csv",
}
],
"links": [
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-averages-25km/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/"
}
],
"checksum": "0x6d78a905bd54d373f71940f8b441bb2ef10758a47dab5b94a94becd688a9e58c",
"encryptedFiles": "<tests.resources.mocks.secret_store_mock.SecretStoreMock object at 0x7f8146a94710>.0c184915b07b44c888d468be85a9b28253e80070e5294b1aaed81c2f0264e430!![{\"url\": \"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.pdf\", \"checksum\": \"efb2c764274b745f5fc37f97c6b0e761\", \"checksumType\": \"MD5\", \"contentLength\": \"4535431\", \"resourceId\": \"access-log2018-02-13-15-17-29-18386C502CAEA932\"}, {\"url\": \"s3://ocean-test-osmosis-data-plugin-dataseeding-1537375953/data.txt\", \"checksum\": \"efb2c764274b745f5fc37f97c6b0e761\", \"contentLength\": \"4535431\", \"resourceId\": \"access-log2018-02-13-15-17-29-18386C502CAEA932\"}, {\"url\": \"http://ipv4.download.thinkbroadband.com/5MB.zip\"}]!!0"
},
Expand All @@ -542,6 +526,27 @@ def client():
"isListed": False
},
"additionalInformation": {
"description": "Introduce the main concepts and vision behind ocean protocol",
"copyrightHolder": "Ocean Protocol Foundation Ltd.",
"workExample": "Text PDF",
"inLanguage": "en",
"categories": [
"white-papers"
],
"tags": ["data exchange", "sharing", "curation", "bonding curve"],
"links": [
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs"
"-daily/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs"
"-averages-25km/"
},
{
"url": "http://data.ceda.ac.uk/badc/ukcp09/"
}
],
"updateFrequency": "yearly",
"structuredMarkup": [
{
Expand All @@ -555,7 +560,7 @@ def client():
]
}
},
"serviceDefinitionId": "2"
"index": 2
}
],
"proof": {
Expand Down Expand Up @@ -608,19 +613,19 @@ def client():
"service": [
{
"type": "Consume",
"serviceDefinitionId": "0",
"index": 0,
"serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/consume?pubKey=${"
"pubKey}&serviceId={serviceId}&url={url}"
},
{
"type": "Compute",
"serviceDefinitionId": "1",
"index": 1,
"serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/compute?pubKey=${"
"pubKey}&serviceId={serviceId}&algo={algo}&container={container}"
},
{
"type": "Metadata",
"serviceDefinitionId": "2",
"type": "metadata",
"index": 2,
"serviceEndpoint": "http://myaquarius.org/api/v1/provider/assets/metadata/{did}",
"attributes": {
"main": {
Expand Down Expand Up @@ -717,19 +722,19 @@ def client():
"service": [
{
"type": "Consume",
"serviceDefinitionId": "0",
"index": 0,
"serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/consume?pubKey=${"
"pubKey}&serviceId={serviceId}&url={url}"
},
{
"type": "Compute",
"serviceDefinitionId": "1",
"index": 1,
"serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/compute?pubKey=${"
"pubKey}&serviceId={serviceId}&algo={algo}&container={container}"
},
{
"type": "Metadata",
"serviceDefinitionId": "2",
"type": "metadata",
"index": 2,
"serviceEndpoint": "http://myaquarius.org/api/v1/provider/assets/metadata/{did}",
"attributes": {
"main": {
Expand Down

0 comments on commit 7ed3cde

Please sign in to comment.