@@ -35,8 +35,8 @@ var jobs_show = require('./../jobs/show.js');
3535 * paperspace.jobs.create({
3636 * container: 'http://dockerhub.com/mycontainer',
3737 * machineType: 'P6000',
38- * }, function(err, resp ) {
39- * // handle error or http response
38+ * }, function(err, res ) {
39+ * // handle error or result
4040 * });
4141 * @example
4242 * $ paperspace jobs create \
@@ -213,37 +213,37 @@ function create(params, cb) {
213213 return cb ( err ) ;
214214 }
215215
216- function maybeTailLogs ( err , resp ) {
216+ function maybeTailLogs ( err , res ) {
217217 if ( global . paperspace_cli && ! json && tail ) {
218218 if ( err ) return cb ( err ) ;
219- if ( ! resp . id ) return new Error ( 'Job create failed; job id not found.' ) ;
220- var jobId = resp . id ;
221- console . log ( 'New jobId: ' + resp . id ) ;
222- console . log ( 'Job ' + resp . state ) ;
223- if ( resp . state === 'Pending' ) console . log ( 'Waiting for job to run...' ) ;
224- return jobs_waitfor ( { jobId : jobId , state : 'Running' } , function _waitforCb ( err , resp ) {
219+ if ( ! res . id ) return new Error ( 'Job create failed; job id not found.' ) ;
220+ var jobId = res . id ;
221+ console . log ( 'New jobId: ' + res . id ) ;
222+ console . log ( 'Job ' + res . state ) ;
223+ if ( res . state === 'Pending' ) console . log ( 'Waiting for job to run...' ) ;
224+ return jobs_waitfor ( { jobId : jobId , state : 'Running' } , function _waitforCb ( err , res ) {
225225 if ( err ) return cb ( err ) ;
226- if ( ! resp . state ) return new Error ( 'Job state not found.' ) ;
227- var state = resp . state ;
226+ if ( ! res . state ) return new Error ( 'Job state not found.' ) ;
227+ var state = res . state ;
228228 console . log ( 'Job ' + state ) ;
229229 if ( state !== 'Stopped' && state !== 'Failed' && state !== 'Running' ) {
230- if ( state === 'Error' || resp . jobError ) console . log ( 'Error: ' + resp . jobError ) ;
230+ if ( state === 'Error' || res . jobError ) console . log ( 'Error: ' + res . jobError ) ;
231231 return cb ( ) ;
232232 }
233233 console . log ( 'Awaiting logs...' ) ;
234234 return jobs_logs ( { jobId : jobId , tail : true } , function _logsCb ( err ) {
235235 if ( err ) return cb ( err ) ;
236- return jobs_show ( { jobId : jobId } , function _showCb ( err , resp ) {
236+ return jobs_show ( { jobId : jobId } , function _showCb ( err , res ) {
237237 if ( err ) return cb ( err ) ;
238- if ( ! resp . state ) return new Error ( 'Job state not found.' ) ;
239- console . log ( 'Job ' + resp . state + ( resp . exitCode || resp . exitCode === 0 ? ', exitCode ' + resp . exitCode : '' ) ) ;
240- if ( resp . state === 'Error' || resp . jobError ) console . log ( 'Error: ' + resp . jobError ) ;
238+ if ( ! res . state ) return new Error ( 'Job state not found.' ) ;
239+ console . log ( 'Job ' + res . state + ( res . exitCode || res . exitCode === 0 ? ', exitCode ' + res . exitCode : '' ) ) ;
240+ if ( res . state === 'Error' || res . jobError ) console . log ( 'Error: ' + res . jobError ) ;
241241 return cb ( ) ;
242242 } ) ;
243243 } ) ;
244244 } ) ;
245245 }
246- return cb ( err , resp ) ;
246+ return cb ( err , res ) ;
247247 }
248248
249249 // don't allow zipping of the root directory
@@ -292,10 +292,10 @@ function create(params, cb) {
292292
293293 // save workspace file name as a extra parameter since we are not using multer to parse the files on the server
294294 params . workspaceFileName = path . basename ( params . workspace ) ;
295- return method ( create , params , function _methodCb ( err , resp ) {
295+ return method ( create , params , function _methodCb ( err , res ) {
296296 if ( err ) return cb ( err ) ;
297- if ( resp ) projectConfig . setLastJobId ( resp . project , resp . id ) ;
298- return maybeTailLogs ( err , resp ) ;
297+ if ( res ) projectConfig . setLastJobId ( res . project , res . id ) ;
298+ return maybeTailLogs ( err , res ) ;
299299 } ) ;
300300 } ) ;
301301
@@ -367,10 +367,10 @@ function create(params, cb) {
367367
368368 // save workspace file name as a extra parameter since we are not using multer to parse the files on the server
369369 params . workspaceFileName = path . basename ( params . workspace ) ;
370- return method ( create , params , function _methodCb ( err , resp ) {
370+ return method ( create , params , function _methodCb ( err , res ) {
371371 if ( err ) return cb ( err ) ;
372- if ( resp ) projectConfig . setLastJobId ( resp . project , resp . id ) ;
373- return maybeTailLogs ( err , resp ) ;
372+ if ( res ) projectConfig . setLastJobId ( res . project , res . id ) ;
373+ return maybeTailLogs ( err , res ) ;
374374 } ) ;
375375 }
376376 } else {
@@ -381,10 +381,10 @@ function create(params, cb) {
381381
382382 // don't try to upload it; we normally attempt to upload anything in the workspace param specified in assign() below
383383 delete params . workspace ;
384- return method ( create , params , function _methodCb ( err , resp ) {
384+ return method ( create , params , function _methodCb ( err , res ) {
385385 if ( err ) return cb ( err ) ;
386- if ( resp ) projectConfig . setLastJobId ( resp . project , resp . id ) ;
387- return maybeTailLogs ( err , resp ) ;
386+ if ( res ) projectConfig . setLastJobId ( res . project , res . id ) ;
387+ return maybeTailLogs ( err , res ) ;
388388 } ) ;
389389 }
390390}
0 commit comments