@oceanprotocol/lib 6.1.2 → 7.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -5
- package/CodeExamples.md +2 -3
- package/ComputeExamples.md +254 -308
- package/dist/lib.cjs +3 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.modern.js +3 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.mjs +3 -1
- package/dist/lib.module.mjs.map +1 -1
- package/dist/lib.umd.js +3 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types/@types/Compute.d.ts +1 -0
- package/dist/types/@types/File.d.ts +8 -1
- package/dist/types/config/ConfigHelper.d.ts +1 -0
- package/dist/types/services/Aquarius.d.ts +0 -1
- package/dist/types/services/Provider.d.ts +3 -270
- package/dist/types/services/providers/BaseProvider.d.ts +48 -0
- package/dist/types/services/providers/HttpProvider.d.ts +246 -0
- package/dist/types/services/providers/P2pProvider.d.ts +176 -0
- package/dist/types/utils/FetchHelper.d.ts +6 -5
- package/package.json +12 -2
package/ComputeExamples.md
CHANGED
|
@@ -143,6 +143,7 @@ import {
|
|
|
143
143
|
sendTx,
|
|
144
144
|
configHelperNetworks,
|
|
145
145
|
ConfigHelper,
|
|
146
|
+
getNodeEndpointConfig,
|
|
146
147
|
getEventFromTx,
|
|
147
148
|
amountToUnits,
|
|
148
149
|
isDefined,
|
|
@@ -280,8 +281,6 @@ let resolvedAlgorithmDdo: DDO
|
|
|
280
281
|
let computeJobId: string
|
|
281
282
|
let agreementId: string
|
|
282
283
|
|
|
283
|
-
let computeRoutePath: string
|
|
284
|
-
let hasFreeComputeSupport: boolean
|
|
285
284
|
```
|
|
286
285
|
|
|
287
286
|
### 4.3 Helper methods
|
|
@@ -438,9 +437,7 @@ We need to load the configuration. Add the following code into your `run(){ }` f
|
|
|
438
437
|
const config = new ConfigHelper().getConfig(
|
|
439
438
|
parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
|
|
440
439
|
)
|
|
441
|
-
|
|
442
|
-
config.oceanNodeUri = process.env.NODE_URL
|
|
443
|
-
}
|
|
440
|
+
Object.assign(config, getNodeEndpointConfig())
|
|
444
441
|
aquariusInstance = new Aquarius(config?.oceanNodeUri)
|
|
445
442
|
providerUrl = config?.oceanNodeUri
|
|
446
443
|
addresses = JSON.parse(
|
|
@@ -622,126 +619,99 @@ let's check the free compute environment
|
|
|
622
619
|
assert(computeEnv, 'Cannot find the free compute env')
|
|
623
620
|
-->
|
|
624
621
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
Let's prepare the dataset and algorithm assets to be used in the compute job
|
|
639
|
-
```Typescript
|
|
640
|
-
const assets: ComputeAsset[] = [
|
|
641
|
-
{
|
|
642
|
-
documentId: resolvedDatasetDdo.id,
|
|
643
|
-
serviceId: resolvedDatasetDdo.services[0].id
|
|
644
|
-
}
|
|
645
|
-
]
|
|
646
|
-
|
|
647
|
-
const algo: ComputeAlgorithm = {
|
|
648
|
-
documentId: resolvedAlgorithmDdo.id,
|
|
649
|
-
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
650
|
-
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
622
|
+
Let's have 5 minute of compute access
|
|
623
|
+
```Typescript
|
|
624
|
+
const mytime = new Date()
|
|
625
|
+
const computeMinutes = 5
|
|
626
|
+
mytime.setMinutes(mytime.getMinutes() + computeMinutes)
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
Let's prepare the dataset and algorithm assets to be used in the compute job
|
|
630
|
+
```Typescript
|
|
631
|
+
const assets: ComputeAsset[] = [
|
|
632
|
+
{
|
|
633
|
+
documentId: resolvedDatasetDdo.id,
|
|
634
|
+
serviceId: resolvedDatasetDdo.services[0].id
|
|
651
635
|
}
|
|
652
|
-
|
|
636
|
+
]
|
|
653
637
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
consumerAccount,
|
|
659
|
-
computeEnv.id,
|
|
660
|
-
assets,
|
|
661
|
-
algo
|
|
662
|
-
)
|
|
663
|
-
```
|
|
664
|
-
|
|
665
|
-
<!--
|
|
666
|
-
assert(computeJobs, 'Cannot start compute job')
|
|
667
|
-
-->
|
|
668
|
-
|
|
669
|
-
Let's save the compute job it, we re going to use later
|
|
670
|
-
```Typescript
|
|
671
|
-
computeJobId = computeJobs[0].jobId
|
|
672
|
-
// eslint-disable-next-line prefer-destructuring
|
|
673
|
-
agreementId = computeJobs[0].agreementId
|
|
674
|
-
```
|
|
675
|
-
<!--
|
|
676
|
-
} else {
|
|
677
|
-
assert(
|
|
678
|
-
computeRoutePath === null,
|
|
679
|
-
'Route path for free compute is not defined (perhaps because provider does not support it yet?)'
|
|
680
|
-
)
|
|
681
|
-
hasFreeComputeSupport = false
|
|
638
|
+
const algo: ComputeAlgorithm = {
|
|
639
|
+
documentId: resolvedAlgorithmDdo.id,
|
|
640
|
+
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
641
|
+
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
682
642
|
}
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
Let's start the free compute job
|
|
646
|
+
```Typescript
|
|
647
|
+
const computeJobs = await ProviderInstance.freeComputeStart(
|
|
648
|
+
providerUrl,
|
|
649
|
+
consumerAccount,
|
|
650
|
+
computeEnv.id,
|
|
651
|
+
assets,
|
|
652
|
+
algo
|
|
653
|
+
)
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
<!--
|
|
657
|
+
assert(computeJobs, 'Cannot start compute job')
|
|
658
|
+
-->
|
|
659
|
+
|
|
660
|
+
Let's save the compute job it, we re going to use later
|
|
661
|
+
```Typescript
|
|
662
|
+
computeJobId = computeJobs[0].jobId
|
|
663
|
+
// eslint-disable-next-line prefer-destructuring
|
|
664
|
+
agreementId = computeJobs[0].agreementId
|
|
665
|
+
```
|
|
666
|
+
<!--
|
|
683
667
|
}).timeout(40000)
|
|
684
668
|
-->
|
|
685
669
|
|
|
686
670
|
## 11. Check compute status and get download compute results URL
|
|
687
671
|
### 11.1 Check compute status
|
|
688
672
|
<!--
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
Now, let's see the current status of the previously started computer job
|
|
709
|
-
```Typescript
|
|
710
|
-
console.log('Current status of the compute job: ', jobStatus)
|
|
711
|
-
```
|
|
712
|
-
<!--
|
|
713
|
-
}
|
|
673
|
+
|
|
674
|
+
-->
|
|
675
|
+
You can also add various delays so you see the various states of the compute job
|
|
676
|
+
```Typescript
|
|
677
|
+
const jobStatus = await ProviderInstance.computeStatus(
|
|
678
|
+
providerUrl,
|
|
679
|
+
consumerAccount,
|
|
680
|
+
computeJobId,
|
|
681
|
+
agreementId
|
|
682
|
+
)
|
|
683
|
+
```
|
|
684
|
+
<!--
|
|
685
|
+
assert(jobStatus, 'Cannot retrieve compute status!')
|
|
686
|
+
-->
|
|
687
|
+
Now, let's see the current status of the previously started computer job
|
|
688
|
+
```Typescript
|
|
689
|
+
console.log('Current status of the compute job: ', jobStatus)
|
|
690
|
+
```
|
|
691
|
+
<!--
|
|
714
692
|
}).timeout(40000)
|
|
715
693
|
-->
|
|
716
694
|
|
|
717
695
|
### 11.2 Get download compute results URL
|
|
718
696
|
<!--
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
assert(downloadURL, 'Provider getComputeResultUrl failed!')
|
|
738
|
-
-->
|
|
739
|
-
Let's check the compute results url for the specified index
|
|
740
|
-
```Typescript
|
|
741
|
-
console.log(`Compute results URL: ${downloadURL}`)
|
|
742
|
-
```
|
|
743
|
-
<!--
|
|
744
|
-
}
|
|
697
|
+
-->
|
|
698
|
+
```Typescript
|
|
699
|
+
await sleep(10000)
|
|
700
|
+
const downloadURL = await ProviderInstance.getComputeResultUrl(
|
|
701
|
+
providerUrl,
|
|
702
|
+
consumerAccount,
|
|
703
|
+
computeJobId,
|
|
704
|
+
0
|
|
705
|
+
)
|
|
706
|
+
```
|
|
707
|
+
<!--
|
|
708
|
+
assert(downloadURL, 'Provider getComputeResultUrl failed!')
|
|
709
|
+
-->
|
|
710
|
+
Let's check the compute results url for the specified index
|
|
711
|
+
```Typescript
|
|
712
|
+
console.log(`Compute results URL: ${downloadURL}`)
|
|
713
|
+
```
|
|
714
|
+
<!--
|
|
745
715
|
}).timeout(40000)
|
|
746
716
|
-->
|
|
747
717
|
|
|
@@ -764,227 +734,203 @@ let's select compute environment which have free and paid resources
|
|
|
764
734
|
|
|
765
735
|
<!--
|
|
766
736
|
const paymentToken = addresses.Ocean
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
{
|
|
793
|
-
id: 'disk',
|
|
794
|
-
amount: 0
|
|
795
|
-
}
|
|
796
|
-
]
|
|
797
|
-
const assets: ComputeAsset[] = [
|
|
798
|
-
{
|
|
799
|
-
documentId: resolvedDatasetDdo.id,
|
|
800
|
-
serviceId: resolvedDatasetDdo.services[0].id
|
|
801
|
-
}
|
|
802
|
-
]
|
|
803
|
-
const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
|
|
804
|
-
const algo: ComputeAlgorithm = {
|
|
805
|
-
documentId: resolvedAlgorithmDdo.id,
|
|
806
|
-
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
807
|
-
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
737
|
+
|
|
738
|
+
Let's have 5 minute of compute access
|
|
739
|
+
```Typescript
|
|
740
|
+
|
|
741
|
+
const mytime = new Date()
|
|
742
|
+
const computeMinutes = 5
|
|
743
|
+
mytime.setMinutes(mytime.getMinutes() + computeMinutes)
|
|
744
|
+
const computeValidUntil = Math.floor(mytime.getTime() / 1000)
|
|
745
|
+
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
Let's prepare the dataset and algorithm assets to be used in the compute job
|
|
749
|
+
```Typescript
|
|
750
|
+
const resources: ComputeResourceRequest[] = [
|
|
751
|
+
{
|
|
752
|
+
id: 'cpu',
|
|
753
|
+
amount: 2
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
id: 'ram',
|
|
757
|
+
amount: 2
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
id: 'disk',
|
|
761
|
+
amount: 0
|
|
808
762
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
)
|
|
763
|
+
]
|
|
764
|
+
const assets: ComputeAsset[] = [
|
|
765
|
+
{
|
|
766
|
+
documentId: resolvedDatasetDdo.id,
|
|
767
|
+
serviceId: resolvedDatasetDdo.services[0].id
|
|
768
|
+
}
|
|
769
|
+
]
|
|
770
|
+
const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
|
|
771
|
+
const algo: ComputeAlgorithm = {
|
|
772
|
+
documentId: resolvedAlgorithmDdo.id,
|
|
773
|
+
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
774
|
+
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
775
|
+
}
|
|
776
|
+
```
|
|
824
777
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
778
|
+
Triggering initialize compute to see payment options
|
|
779
|
+
```Typescript
|
|
780
|
+
const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
|
|
781
|
+
assets,
|
|
782
|
+
algo,
|
|
783
|
+
computeEnv.id,
|
|
784
|
+
paymentToken,
|
|
785
|
+
computeValidUntil,
|
|
786
|
+
providerUrl,
|
|
787
|
+
consumerAccount,
|
|
788
|
+
resources,
|
|
789
|
+
Number(chainId)
|
|
790
|
+
)
|
|
829
791
|
|
|
830
|
-
|
|
792
|
+
console.log(
|
|
793
|
+
'providerInitializeComputeResults = ',
|
|
794
|
+
JSON.stringify(providerInitializeComputeResults)
|
|
795
|
+
)
|
|
831
796
|
|
|
832
|
-
|
|
833
|
-
assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
|
|
834
|
-
-->
|
|
797
|
+
```
|
|
835
798
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
).toString()
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
)
|
|
873
|
-
|
|
799
|
+
<!--
|
|
800
|
+
assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
|
|
801
|
+
-->
|
|
802
|
+
|
|
803
|
+
Let's check funds for escrow payment
|
|
804
|
+
```Typescript
|
|
805
|
+
const escrow = new EscrowContract(
|
|
806
|
+
getAddress(providerInitializeComputeResults.payment.escrowAddress),
|
|
807
|
+
consumerAccount
|
|
808
|
+
)
|
|
809
|
+
const paymentTokenPublisher = new Datatoken(publisherAccount)
|
|
810
|
+
const balancePublisherPaymentToken = await paymentTokenPublisher.balance(
|
|
811
|
+
paymentToken,
|
|
812
|
+
await publisherAccount.getAddress()
|
|
813
|
+
)
|
|
814
|
+
assert(
|
|
815
|
+
new BigNumber(parseEther(balancePublisherPaymentToken)).isGreaterThan(0),
|
|
816
|
+
'Balance should be higher than 0'
|
|
817
|
+
)
|
|
818
|
+
const tx = await publisherAccount.sendTransaction({
|
|
819
|
+
to: computeEnv.consumerAddress,
|
|
820
|
+
value: parseEther('1.5')
|
|
821
|
+
})
|
|
822
|
+
await tx.wait()
|
|
823
|
+
|
|
824
|
+
await paymentTokenPublisher.transfer(
|
|
825
|
+
paymentToken,
|
|
826
|
+
getAddress(computeEnv.consumerAddress),
|
|
827
|
+
(Number(balancePublisherPaymentToken) / 2).toString()
|
|
828
|
+
)
|
|
829
|
+
const amountToDeposit = (
|
|
830
|
+
providerInitializeComputeResults.payment.amount * 2
|
|
831
|
+
).toString()
|
|
832
|
+
await escrow.verifyFundsForEscrowPayment(
|
|
833
|
+
paymentToken,
|
|
834
|
+
computeEnv.consumerAddress,
|
|
835
|
+
await unitsToAmount(consumerAccount, paymentToken, amountToDeposit),
|
|
836
|
+
providerInitializeComputeResults.payment.amount.toString(),
|
|
837
|
+
providerInitializeComputeResults.payment.minLockSeconds.toString(),
|
|
838
|
+
'10'
|
|
839
|
+
)
|
|
840
|
+
```
|
|
874
841
|
|
|
875
|
-
|
|
876
|
-
|
|
842
|
+
Let's order assets
|
|
843
|
+
```Typescript
|
|
877
844
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
845
|
+
algo.transferTxId = await handleOrder(
|
|
846
|
+
providerInitializeComputeResults.algorithm,
|
|
847
|
+
resolvedAlgorithmDdo.services[0].datatokenAddress,
|
|
848
|
+
consumerAccount,
|
|
849
|
+
computeEnv.consumerAddress,
|
|
850
|
+
0
|
|
851
|
+
)
|
|
852
|
+
for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
|
|
853
|
+
assets[i].transferTxId = await handleOrder(
|
|
854
|
+
providerInitializeComputeResults.datasets[i],
|
|
855
|
+
dtAddressArray[i],
|
|
881
856
|
consumerAccount,
|
|
882
857
|
computeEnv.consumerAddress,
|
|
883
858
|
0
|
|
884
859
|
)
|
|
885
|
-
for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
|
|
886
|
-
assets[i].transferTxId = await handleOrder(
|
|
887
|
-
providerInitializeComputeResults.datasets[i],
|
|
888
|
-
dtAddressArray[i],
|
|
889
|
-
consumerAccount,
|
|
890
|
-
computeEnv.consumerAddress,
|
|
891
|
-
0
|
|
892
|
-
)
|
|
893
|
-
}
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
Let's start compute job
|
|
897
|
-
```Typescript
|
|
898
|
-
const computeJobs = await ProviderInstance.computeStart(
|
|
899
|
-
providerUrl,
|
|
900
|
-
consumerAccount,
|
|
901
|
-
computeEnv.id,
|
|
902
|
-
assets,
|
|
903
|
-
algo,
|
|
904
|
-
computeValidUntil,
|
|
905
|
-
paymentToken,
|
|
906
|
-
resources,
|
|
907
|
-
Number(chainId)
|
|
908
|
-
)
|
|
909
|
-
```
|
|
910
|
-
|
|
911
|
-
<!--
|
|
912
|
-
assert(computeJobs, 'Cannot start compute job')
|
|
913
|
-
-->
|
|
914
|
-
|
|
915
|
-
Let's save the compute job it, we re going to use later
|
|
916
|
-
```Typescript
|
|
917
|
-
computeJobId = computeJobs[0].jobId
|
|
918
|
-
```
|
|
919
|
-
<!--
|
|
920
|
-
} else {
|
|
921
|
-
assert(
|
|
922
|
-
computeRoutePath === null,
|
|
923
|
-
'Route path for free compute is not defined (perhaps because provider does not support it yet?)'
|
|
924
|
-
)
|
|
925
|
-
hasFreeComputeSupport = false
|
|
926
860
|
}
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
Let's start compute job
|
|
864
|
+
```Typescript
|
|
865
|
+
const computeJobs = await ProviderInstance.computeStart(
|
|
866
|
+
providerUrl,
|
|
867
|
+
consumerAccount,
|
|
868
|
+
computeEnv.id,
|
|
869
|
+
assets,
|
|
870
|
+
algo,
|
|
871
|
+
computeValidUntil,
|
|
872
|
+
paymentToken,
|
|
873
|
+
resources,
|
|
874
|
+
Number(chainId)
|
|
875
|
+
)
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
<!--
|
|
879
|
+
assert(computeJobs, 'Cannot start compute job')
|
|
880
|
+
-->
|
|
881
|
+
|
|
882
|
+
Let's save the compute job it, we re going to use later
|
|
883
|
+
```Typescript
|
|
884
|
+
computeJobId = computeJobs[0].jobId
|
|
885
|
+
```
|
|
886
|
+
<!--
|
|
927
887
|
}).timeout(40000)
|
|
928
888
|
-->
|
|
929
889
|
|
|
930
890
|
## 13. Check paid compute job status and get download compute results URL
|
|
931
891
|
### 13.1 Check compute status for paid compute job
|
|
932
892
|
<!--
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
-->
|
|
951
|
-
Now, let's see the current status of the previously started computer job
|
|
952
|
-
```Typescript
|
|
953
|
-
console.log('Current status of the compute job: ', jobStatus)
|
|
954
|
-
```
|
|
955
|
-
<!--
|
|
956
|
-
}
|
|
893
|
+
-->
|
|
894
|
+
You can also add various delays so you see the various states of the compute job
|
|
895
|
+
```Typescript
|
|
896
|
+
const jobStatus = await ProviderInstance.computeStatus(
|
|
897
|
+
providerUrl,
|
|
898
|
+
consumerAccount,
|
|
899
|
+
computeJobId
|
|
900
|
+
)
|
|
901
|
+
```
|
|
902
|
+
<!--
|
|
903
|
+
assert(jobStatus, 'Cannot retrieve compute status!')
|
|
904
|
+
-->
|
|
905
|
+
Now, let's see the current status of the previously started computer job
|
|
906
|
+
```Typescript
|
|
907
|
+
console.log('Current status of the compute job: ', jobStatus)
|
|
908
|
+
```
|
|
909
|
+
<!--
|
|
957
910
|
}).timeout(40000)
|
|
958
911
|
-->
|
|
959
912
|
|
|
960
913
|
### 13.2 Get download compute results URL
|
|
961
914
|
<!--
|
|
962
|
-
|
|
963
|
-
assert(
|
|
964
|
-
computeRoutePath === null,
|
|
965
|
-
'Compute route path for paid compute is not defined (perhaps because provider does not support it yet?)'
|
|
966
|
-
)
|
|
967
|
-
} else {
|
|
968
|
-
-->
|
|
915
|
+
-->
|
|
969
916
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
917
|
+
```Typescript
|
|
918
|
+
await sleep(10000)
|
|
919
|
+
const downloadURL = await ProviderInstance.getComputeResultUrl(
|
|
920
|
+
providerUrl,
|
|
921
|
+
consumerAccount,
|
|
922
|
+
computeJobId,
|
|
923
|
+
0
|
|
924
|
+
)
|
|
925
|
+
```
|
|
926
|
+
<!--
|
|
927
|
+
assert(downloadURL, 'Provider getComputeResultUrl failed!')
|
|
928
|
+
-->
|
|
929
|
+
Let's check the compute results url for the specified index
|
|
930
|
+
```Typescript
|
|
931
|
+
console.log(`Compute results URL: ${downloadURL}`)
|
|
932
|
+
```
|
|
933
|
+
<!--
|
|
988
934
|
}).timeout(40000)
|
|
989
935
|
})
|
|
990
936
|
-->
|