diff --git a/src/components/organisms/AssetActions/Compute/index.tsx b/src/components/organisms/AssetActions/Compute/index.tsx index 41b121534..3f9885db2 100644 --- a/src/components/organisms/AssetActions/Compute/index.tsx +++ b/src/components/organisms/AssetActions/Compute/index.tsx @@ -157,7 +157,9 @@ export default function Compute({ source.token ) setDdoAlgorithmList(gueryResults.results) + const datasetComputeService = ddo.findServiceByType('compute') algorithmSelectionList = await transformDDOToAssetSelection( + datasetComputeService?.serviceEndpoint, gueryResults.results, appConfig.metadataCacheUri, [] @@ -384,7 +386,10 @@ export default function Compute({ text="This algorithm has been set to private by the publisher and can't be downloaded. You can run it against any allowed data sets though!" state="info" /> - + ) : ( {type === 'algorithm' && ( - + )} ) diff --git a/src/components/organisms/AssetActions/Edit/FormEditComputeDataset.tsx b/src/components/organisms/AssetActions/Edit/FormEditComputeDataset.tsx index c806e02b2..87c54bd40 100644 --- a/src/components/organisms/AssetActions/Edit/FormEditComputeDataset.tsx +++ b/src/components/organisms/AssetActions/Edit/FormEditComputeDataset.tsx @@ -56,7 +56,9 @@ export default function FormEditComputeDataset({ appConfig.metadataCacheUri, source.token ) + const datasetComputeService = ddo.findServiceByType('compute') const algorithmSelectionList = await transformDDOToAssetSelection( + datasetComputeService?.serviceEndpoint, querryResult.results, appConfig.metadataCacheUri, publisherTrustedAlgorithms diff --git a/src/components/organisms/AssetContent/AlgorithmDatasetsListForCompute.tsx b/src/components/organisms/AssetContent/AlgorithmDatasetsListForCompute.tsx index 7531ef390..09c2f15d8 100644 --- a/src/components/organisms/AssetContent/AlgorithmDatasetsListForCompute.tsx +++ b/src/components/organisms/AssetContent/AlgorithmDatasetsListForCompute.tsx @@ -5,11 +5,14 @@ import { AssetSelectionAsset } from '../../molecules/FormFields/AssetSelection' import AssetComputeList from '../../molecules/AssetComputeList' import { useOcean } from '../../../providers/Ocean' import { useAsset } from '../../../providers/Asset' +import { DDO } from '@oceanprotocol/lib' export default function AlgorithmDatasetsListForCompute({ - algorithmDid + algorithmDid, + dataset }: { algorithmDid: string + dataset: DDO }): ReactElement { const { config } = useOcean() const { type } = useAsset() @@ -18,8 +21,10 @@ export default function AlgorithmDatasetsListForCompute({ useEffect(() => { async function getDatasetsAllowedForCompute() { + const datasetComputeService = dataset.findServiceByType('compute') const datasets = await getAlgorithmDatasetsForCompute( algorithmDid, + datasetComputeService?.serviceEndpoint, config.metadataCacheUri ) setDatasetsForCompute(datasets) diff --git a/src/utils/aquarius.ts b/src/utils/aquarius.ts index 6f094d7b0..e14e5367d 100644 --- a/src/utils/aquarius.ts +++ b/src/utils/aquarius.ts @@ -121,6 +121,7 @@ export async function getAssetsNames( } export async function transformDDOToAssetSelection( + datasetProviderEndpoint: string, ddoList: DDO[], metadataCacheUri: string, selectedAlgorithms?: PublisherTrustedAlgorithm[] @@ -129,14 +130,22 @@ export async function transformDDOToAssetSelection( const didList: string[] = [] const priceList: PriceList = await getAssetsPriceList(ddoList) const symbolList: any = {} + const didProviderEndpointMap: any = {} for (const ddo of ddoList) { didList.push(ddo.id) symbolList[ddo.id] = ddo.dataTokenInfo.symbol + const algoComputeService = ddo.findServiceByType('compute') + algoComputeService?.serviceEndpoint && + (didProviderEndpointMap[ddo.id] = algoComputeService?.serviceEndpoint) } const ddoNames = await getAssetsNames(didList, metadataCacheUri, source.token) const algorithmList: AssetSelectionAsset[] = [] didList?.forEach((did: string) => { - if (priceList[did]) { + if ( + priceList[did] && + (!didProviderEndpointMap[did] || + didProviderEndpointMap[did] === datasetProviderEndpoint) + ) { let selected = false selectedAlgorithms?.forEach((algorithm: PublisherTrustedAlgorithm) => { if (algorithm.did === did) { @@ -165,6 +174,7 @@ export async function transformDDOToAssetSelection( export async function getAlgorithmDatasetsForCompute( algorithmId: string, + datasetProviderUri: string, metadataCacheUri: string ): Promise { const source = axios.CancelToken.source() @@ -186,6 +196,7 @@ export async function getAlgorithmDatasetsForCompute( return [] } const datasets = await transformDDOToAssetSelection( + datasetProviderUri, computeDatasetsForCurrentAlgorithm, metadataCacheUri, []