compute fix

This commit is contained in:
mihaisc 2020-05-27 17:12:24 +03:00
parent 0c1724726c
commit ca2a0ec0d4
2 changed files with 34 additions and 23 deletions

View File

@ -3,6 +3,7 @@ import { DID, MetaDataAlgorithm, Logger } from '@oceanprotocol/squid'
import { useOcean } from '../../providers'
import { ComputeValue } from './ComputeOptions'
import { feedback } from './../../utils'
import { LoggerInstance } from '@oceanprotocol/squid/dist/node/utils/Logger'
interface UseCompute {
compute: (
did: DID | string,
@ -59,15 +60,13 @@ function useCompute(): UseCompute {
owner: accountId,
secretStoreUri: config.secretStoreUri
}
Logger.debug('useCompute computeOutput', computeOutput)
const agreement = await ocean.compute
.order(account, did as string)
.next((step: number) => {
setComputeStep(step)
setComputeStepText(computeFeedback[step])
})
Logger.debug('useCompute agreement', agreement)
rawAlgorithmMeta.container = computeContainer
rawAlgorithmMeta.rawcode = algorithmRawCode
setComputeStep(4)

View File

@ -65,13 +65,17 @@ function useSearch(): UseSearch {
const consumed = await ocean.assets.consumerAssets(accountId)
const consumedItems = await Promise.all(
consumed.map(async (did) => {
const ddo = await ocean.assets.resolve(did)
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) return ddo
try {
const ddo = await ocean.assets.resolve(did)
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) return ddo
}
} catch (err) {
Logger.error(err)
}
})
)
@ -87,25 +91,33 @@ function useSearch(): UseSearch {
const computeItems = await Promise.all(
jobList.map(async (job) => {
if (!job) return
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
job.agreementId
)
try {
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
job.agreementId
)
const ddo = await ocean.assets.resolve(did)
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) {
return { job, ddo }
const ddo = await ocean.assets.resolve(did)
if (
did ===
'0x0000000000000000000000000000000000000000000000000000000000000000'
)
return
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) {
return { job, ddo }
}
}
} catch (err) {
Logger.error(err)
}
})
)
const filteredComputeItems = computeItems.filter(
(value) => typeof value.ddo !== 'undefined'
(value) => value !== undefined && typeof value.ddo !== 'undefined'
)
return filteredComputeItems
}