mirror of
https://github.com/oceanprotocol/react-tutorial
synced 2024-11-22 01:36:58 +01:00
use RawCode to start a job
This commit is contained in:
parent
e9f5496ca1
commit
34976679d4
@ -8,7 +8,8 @@ export default function Compute({ ocean, web3 }) {
|
|||||||
const [jobId, setJobId] = useState('')
|
const [jobId, setJobId] = useState('')
|
||||||
const [agreementId, setAgreementId] = useState('')
|
const [agreementId, setAgreementId] = useState('')
|
||||||
const [ddoAlgorithmId, setDdoAlgorithmId] = useState('')
|
const [ddoAlgorithmId, setDdoAlgorithmId] = useState('')
|
||||||
|
const [divAlgoStyle, setdivAlgoStyle] = useState('')
|
||||||
|
const [textRawAlgo, settextRawAlgo] = useState('')
|
||||||
// publish a dataset and an algorithm
|
// publish a dataset and an algorithm
|
||||||
async function publish() {
|
async function publish() {
|
||||||
try {
|
try {
|
||||||
@ -63,7 +64,7 @@ export default function Compute({ ocean, web3 }) {
|
|||||||
accounts[0],
|
accounts[0],
|
||||||
agreement,
|
agreement,
|
||||||
algorithmId,
|
algorithmId,
|
||||||
algorithmMeta
|
JSON.stringify(algorithmMeta)
|
||||||
)
|
)
|
||||||
setJobId(status.jobId)
|
setJobId(status.jobId)
|
||||||
console.log(status)
|
console.log(status)
|
||||||
@ -80,6 +81,7 @@ export default function Compute({ ocean, web3 }) {
|
|||||||
|
|
||||||
// order and start the compute service with a passed raw algorithm
|
// order and start the compute service with a passed raw algorithm
|
||||||
async function startWithRawAlgo() {
|
async function startWithRawAlgo() {
|
||||||
|
rawAlgoMeta.rawcode = textRawAlgo
|
||||||
return startCompute(undefined, rawAlgoMeta)
|
return startCompute(undefined, rawAlgoMeta)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +97,18 @@ export default function Compute({ ocean, web3 }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function showDivAlgo() {
|
||||||
|
if (divAlgoStyle === 'none') setdivAlgoStyle('block')
|
||||||
|
else setdivAlgoStyle('none')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateRawAlgoCode(event) {
|
||||||
|
settextRawAlgo(event.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateDdoAssetId(event) {
|
||||||
|
setDdoAssetId(event.target.value)
|
||||||
|
}
|
||||||
if (!web3) {
|
if (!web3) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -105,7 +119,7 @@ export default function Compute({ ocean, web3 }) {
|
|||||||
<ComputeSection>
|
<ComputeSection>
|
||||||
<button onClick={publish}>Publish dataset with compute service</button>
|
<button onClick={publish}>Publish dataset with compute service</button>
|
||||||
Asset DID:
|
Asset DID:
|
||||||
<input type="text" value={ddoAssetId} readOnly />
|
<input type="text" value={ddoAssetId} onChange={updateDdoAssetId} />
|
||||||
</ComputeSection>
|
</ComputeSection>
|
||||||
<ComputeSection>
|
<ComputeSection>
|
||||||
<button onClick={publishalgo}>Publish algorithm</button>
|
<button onClick={publishalgo}>Publish algorithm</button>
|
||||||
@ -122,6 +136,15 @@ export default function Compute({ ocean, web3 }) {
|
|||||||
<button onClick={startWithRawAlgo} disabled={!ddoAssetId}>
|
<button onClick={startWithRawAlgo} disabled={!ddoAssetId}>
|
||||||
Order and start compute service with raw algorithm
|
Order and start compute service with raw algorithm
|
||||||
</button>
|
</button>
|
||||||
|
<button onClick={showDivAlgo}>Show/Hide Raw Algo</button>
|
||||||
|
<div style={{ display: divAlgoStyle }}>
|
||||||
|
<textarea
|
||||||
|
rows="20"
|
||||||
|
cols="120"
|
||||||
|
value={textRawAlgo}
|
||||||
|
onChange={updateRawAlgoCode}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
Job ID:
|
Job ID:
|
||||||
<input type="text" value={jobId} readOnly />
|
<input type="text" value={jobId} readOnly />
|
||||||
</ComputeSection>
|
</ComputeSection>
|
||||||
|
Loading…
Reference in New Issue
Block a user