1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

support for starting a free env compute job

This commit is contained in:
paulo-ocean 2024-11-04 17:44:45 +00:00
parent e1c5194f43
commit 59daaae3d1
2 changed files with 15 additions and 4 deletions

View File

@ -22,6 +22,7 @@ export interface ComputeEnvironment {
storageExpiry: number storageExpiry: number
maxJobDuration: number maxJobDuration: number
lastSeen: number lastSeen: number
free: boolean
} }
export interface ComputeResult { export interface ComputeResult {

View File

@ -615,6 +615,7 @@ export class Provider {
* @param {ComputeAlgorithm} algorithm The algorithm to start compute with. * @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
* @param {AbortSignal} signal abort signal * @param {AbortSignal} signal abort signal
* @param {ComputeOutput} output The compute job output settings. * @param {ComputeOutput} output The compute job output settings.
* @param {boolean} freeEnvironment is it a free environment? uses different route
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs. * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
*/ */
public async computeStart( public async computeStart(
@ -624,7 +625,8 @@ export class Provider {
datasets: ComputeAsset[], datasets: ComputeAsset[],
algorithm: ComputeAlgorithm, algorithm: ComputeAlgorithm,
signal?: AbortSignal, signal?: AbortSignal,
output?: ComputeOutput output?: ComputeOutput,
freeEnvironment?: boolean
): Promise<ComputeJob | ComputeJob[]> { ): Promise<ComputeJob | ComputeJob[]> {
console.log('called new compute start method...') console.log('called new compute start method...')
const providerEndpoints = await this.getEndpoints(providerUri) const providerEndpoints = await this.getEndpoints(providerUri)
@ -632,9 +634,17 @@ export class Provider {
providerUri, providerUri,
providerEndpoints providerEndpoints
) )
const computeStartUrl = this.getEndpointURL(serviceEndpoints, 'computeStart') let computeStartUrl = null
if (freeEnvironment) {
computeStartUrl = this.getEndpointURL(serviceEndpoints, 'freeCompute')
? this.getEndpointURL(serviceEndpoints, 'freeCompute').urlPath
: null
} else {
computeStartUrl = this.getEndpointURL(serviceEndpoints, 'computeStart')
? this.getEndpointURL(serviceEndpoints, 'computeStart').urlPath ? this.getEndpointURL(serviceEndpoints, 'computeStart').urlPath
: null : null
}
const consumerAddress = await consumer.getAddress() const consumerAddress = await consumer.getAddress()
const nonce = ( const nonce = (