@@ -7,6 +7,7 @@ import { homedir } from 'os'
77
88import { dirname } from 'path'
99import { fileURLToPath } from 'url'
10+ import { ProviderInstance } from "../node_modules/@oceanprotocol/lib/dist/types/index" ;
1011
1112const execPromise = util . promisify ( exec ) ;
1213
@@ -158,25 +159,29 @@ describe("Ocean CLI Compute", function() {
158159 expect ( firstEnv ) . to . have . property ( "resources" ) . that . is . an ( "array" ) ;
159160
160161 computeEnvId = firstEnv . id ;
161- console . log ( `firstEnv.resources: ${ JSON . stringify ( firstEnv . resources ) } ` )
162+
163+ console . log ( `Fetched Compute Env ID: ${ computeEnvId } ` ) ;
164+ } ) ;
165+
166+ it ( "should initialize compute on compute dataset and algorithm" , async function ( ) {
167+ const computeEnvs = await ProviderInstance . getComputeEnvironments ( 'http://127.0.0.1:8001' ) ;
168+ const env = computeEnvs [ 0 ] ;
169+ console . log ( `env: ${ JSON . stringify ( env ) } ` )
162170 resources = [
163171 {
164172 id : 'cpu' ,
165- amount : firstEnv . resources [ 0 ] . max - firstEnv . resources [ 0 ] . inUse - 1
173+ amount : env . resources [ 0 ] . max - env . resources [ 0 ] . inUse - 1
166174 } ,
167175 {
168176 id : 'ram' ,
169- amount : firstEnv . resources [ 1 ] . max - firstEnv . resources [ 1 ] . inUse - 1000
177+ amount : env . resources [ 1 ] . max - env . resources [ 1 ] . inUse - 1000
170178 } ,
171179 {
172180 id : 'disk' ,
173181 amount : 0
174182 }
175183 ]
176- console . log ( `Fetched Compute Env ID: ${ computeEnvId } ` ) ;
177- } ) ;
178-
179- it ( "should initialize compute on compute dataset and algorithm" , async function ( ) {
184+ console . log ( `resources: ${ JSON . stringify ( resources ) } ` )
180185 const paymentToken = getAddresses ( ) . Ocean
181186 const output = await runCommand ( `npm run cli initializeCompute ${ computeDatasetDid } ${ jsAlgoDid } ${ computeEnvId } 900 ${ paymentToken } ${ JSON . stringify ( resources ) } ` ) ;
182187 const jsonMatch = output . match ( / i n i t i a l i z e c o m p u t e d e t a i l s : \s * ( [ \s \S ] * ) / ) ;
@@ -206,7 +211,7 @@ describe("Ocean CLI Compute", function() {
206211 const jsonMatch = output . match ( / J o b I D : \s * ( [ \s \S ] * ) / ) ;
207212 if ( ! jsonMatch ) {
208213 console . error ( "Raw output:" , output ) ;
209- throw new Error ( "Could not find initialize response in the output" ) ;
214+ throw new Error ( "Could not find start compute response in the output" ) ;
210215 }
211216 const match = jsonMatch [ 0 ] . match ( / J o b I D : \s * ( .* ) / s) ;
212217 const result = match ? match [ 1 ] . trim ( ) : null ;
0 commit comments