mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
squid fixes
This commit is contained in:
parent
f5e8f87d9b
commit
19bab9a476
content/tutorials
@ -17,7 +17,7 @@ In the previous tutorial we added asset publishing. We can now search for publis
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
async retrieveAssets() {
|
async retrieveAssets() {
|
||||||
this.dbAssets = await this.ocean.searchAssetsByText("Office Humidity")
|
this.dbAssets = await this.ocean.assets.search("10 Monkey Species Small")
|
||||||
console.log(this.dbAssets)
|
console.log(this.dbAssets)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -35,25 +35,25 @@ The retrieved assets can now be consumed so in this tutorial we consume the firs
|
|||||||
```js
|
```js
|
||||||
async consumeAsset() {
|
async consumeAsset() {
|
||||||
// get all accounts
|
// get all accounts
|
||||||
const accounts = await this.ocean.getAccounts()
|
const accounts = await this.ocean.accounts.list()
|
||||||
// get first asset
|
// get first asset
|
||||||
const consumeAsset = this.dbAssets[0]
|
const consumeAsset = this.dbAssets[0]
|
||||||
// get service we want to execute
|
// get service we want to execute
|
||||||
const service = consumeAsset.findServiceByType('Access')
|
const service = consumeAsset.findServiceByType('Access')
|
||||||
// sign service
|
// order service agreement
|
||||||
const serviceAgreementSignatureResult = await this.ocean.signServiceAgreement(
|
const agreement = await this.ocean.assets.order(
|
||||||
consumeAsset.id,
|
consumeAsset.id,
|
||||||
service.serviceDefinitionId,
|
service.serviceDefinitionId,
|
||||||
accounts[0])
|
accounts[0]
|
||||||
// run it
|
)
|
||||||
await this.ocean.initializeServiceAgreement(
|
// consume it
|
||||||
|
await this.ocean.assets.consume(
|
||||||
|
agreement,
|
||||||
consumeAsset.id,
|
consumeAsset.id,
|
||||||
service.serviceDefinitionId,
|
service.serviceDefinitionId,
|
||||||
serviceAgreementSignatureResult.serviceAgreementId,
|
accounts[0],
|
||||||
serviceAgreementSignatureResult.serviceAgreementSignature,
|
''
|
||||||
// callback to handle the files we get
|
)
|
||||||
(files) => { console.log('Asset files', files) },
|
|
||||||
accounts[0])
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -84,36 +84,67 @@ window.ethereum.enable()
|
|||||||
|
|
||||||
const asset = {
|
const asset = {
|
||||||
base: {
|
base: {
|
||||||
name: 'Office Humidity',
|
name: "10 Monkey Species Small",
|
||||||
description: 'Weather information of UK including temperature and humidity',
|
dateCreated: "2012-02-01T10:55:11Z",
|
||||||
dateCreated: '2012-02-01T10:55:11+00:00',
|
author: "Mario",
|
||||||
author: 'Met Office',
|
license: "CC0: Public Domain",
|
||||||
size: '3.1bg',
|
contentType: "jpg/txt",
|
||||||
license: 'Public Domain',
|
price: 10,
|
||||||
copyrightHolder: 'Met Office',
|
files: [
|
||||||
contentUrls: [
|
|
||||||
'https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip'
|
|
||||||
],
|
|
||||||
contentType: 'text/csv',
|
|
||||||
links: [
|
|
||||||
{
|
{
|
||||||
name: 'Dataset sample',
|
checksum: "2bf9d229d110d1976cdf85e9f3256c7f",
|
||||||
type: 'sample',
|
checksumType: "MD5",
|
||||||
url:
|
contentLength: 12057507,
|
||||||
'http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/'
|
url: "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/assets/training.zip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checksum: "354d19c0733c47ef3a6cce5b633116b0",
|
||||||
|
checksumType: "MD5",
|
||||||
|
contentLength: 928,
|
||||||
|
url: "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/assets/monkey_labels.txt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/assets/validation.zip"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
tags: 'weather, uk, 2011, temperature, humidity',
|
checksum: "",
|
||||||
price: 5,
|
categories: [
|
||||||
type: 'dataset'
|
"image"
|
||||||
},
|
],
|
||||||
curation: {
|
tags: [
|
||||||
rating: 0,
|
"image data",
|
||||||
numVotes: 0,
|
"classification",
|
||||||
schema: 'Binary Voting'
|
"animals"
|
||||||
},
|
],
|
||||||
additionalInformation: {
|
type: "dataset",
|
||||||
updateFrequency: 'yearly'
|
description: "EXAMPLE ONLY ",
|
||||||
|
size: "3.1gb",
|
||||||
|
copyrightHolder: "Unknown",
|
||||||
|
encoding: "UTF-8",
|
||||||
|
compression: "zip",
|
||||||
|
workExample: "image path, id, label",
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
name: "example model",
|
||||||
|
url: "https://drive.google.com/open?id=1uuz50RGiAW8YxRcWeQVgQglZpyAebgSM"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "example code",
|
||||||
|
type: "example code",
|
||||||
|
url: "https://github.com/slothkong/CNN_classification_10_monkey_species"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/links/discovery/n5151.jpg",
|
||||||
|
name: "n5151.jpg",
|
||||||
|
type: "discovery"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/links/sample/sample.zip",
|
||||||
|
name: "sample.zip",
|
||||||
|
type: "sample"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
inLanguage: "en"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,40 +165,36 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async submitAsset() {
|
async submitAsset() {
|
||||||
const accounts = await this.ocean.getAccounts()
|
const accounts = await this.ocean.accounts.list()
|
||||||
const ddo = await this.ocean.registerAsset(asset, accounts[0])
|
const ddo = await this.ocean.assets.create(asset, accounts[0])
|
||||||
alert('Asset successfully submited: ', JSON.stringify(ddo))
|
alert('Asset successfully submitted: ', JSON.stringify(ddo))
|
||||||
}
|
}
|
||||||
|
|
||||||
async retrieveAssets() {
|
async retrieveAssets() {
|
||||||
this.dbAssets = await this.ocean.searchAssetsByText('Office Humidity')
|
this.dbAssets = await ocean.assets.search("10 Monkey Species Small")
|
||||||
console.log(this.dbAssets)
|
console.log(this.dbAssets)
|
||||||
}
|
}
|
||||||
|
|
||||||
async consumeAsset() {
|
async consumeAsset() {
|
||||||
// get all accounts
|
// get all accounts
|
||||||
const accounts = await this.ocean.getAccounts()
|
const accounts = await this.ocean.accounts.list()
|
||||||
// get first asset
|
// get first asset
|
||||||
const consumeAsset = this.dbAssets[0]
|
const consumeAsset = this.dbAssets[0]
|
||||||
// get service we want to execute
|
// get service we want to execute
|
||||||
const service = consumeAsset.findServiceByType('Access')
|
const service = consumeAsset.findServiceByType('Access')
|
||||||
// sign service
|
// order service agreement
|
||||||
const serviceAgreementSignatureResult = await this.ocean.signServiceAgreement(
|
const agreement = await ocean.assets.order(
|
||||||
consumeAsset.id,
|
consumeAsset.id,
|
||||||
service.serviceDefinitionId,
|
service.serviceDefinitionId,
|
||||||
accounts[0]
|
accounts[0]
|
||||||
)
|
)
|
||||||
// run it
|
// consume it
|
||||||
await this.ocean.initializeServiceAgreement(
|
await ocean.assets.consume(
|
||||||
|
agreement,
|
||||||
consumeAsset.id,
|
consumeAsset.id,
|
||||||
service.serviceDefinitionId,
|
service.serviceDefinitionId,
|
||||||
serviceAgreementSignatureResult.serviceAgreementId,
|
accounts[0],
|
||||||
serviceAgreementSignatureResult.serviceAgreementSignature,
|
''
|
||||||
// callback to handle the files we get
|
|
||||||
files => {
|
|
||||||
console.log('Asset files', files)
|
|
||||||
},
|
|
||||||
accounts[0]
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ Now that we have an asset to submit, we need a function to handle it. Just befor
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
async submitAsset() {
|
async submitAsset() {
|
||||||
const accounts = await this.ocean.getAccounts()
|
const accounts = await this.ocean.accounts.list()
|
||||||
const ddo = await this.ocean.registerAsset(asset, accounts[0])
|
const ddo = await this.ocean.assets.create(asset, accounts[0])
|
||||||
alert('Asset successfully submitted: ', JSON.stringify(ddo))
|
alert('Asset successfully submitted: ', JSON.stringify(ddo))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -199,8 +199,8 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async submitAsset() {
|
async submitAsset() {
|
||||||
const accounts = await this.ocean.getAccounts()
|
const accounts = await this.ocean.accounts.list()
|
||||||
const ddo = await this.ocean.registerAsset(asset, accounts[0])
|
const ddo = await this.ocean.assets.create(asset, accounts[0])
|
||||||
alert('Asset successfully submitted: ', JSON.stringify(ddo))
|
alert('Asset successfully submitted: ', JSON.stringify(ddo))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user