You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 6, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: lib/jobs/create.js
+81-14Lines changed: 81 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,21 @@
3
3
varmethod=require('./../method');
4
4
varassign=require('lodash.assign');
5
5
varpath=require('path');
6
+
varmkdirp=require('mkdirp');
6
7
varasync=require('async');
7
8
varos=require('os');
8
9
varfs=require('fs');
9
10
vararchiver=require('archiver');
10
11
varProgressBar=require('progress');
11
12
varprojectConfig=require('./../projectConfig');
13
+
varjobs_logs=require('./../jobs/logs.js');
14
+
varjobs_waitfor=require('./../jobs/waitfor.js');
15
+
varjobs_show=require('./../jobs/show.js');
12
16
13
17
/**
14
18
* @memberof jobs
15
19
* @method create
16
-
* @description Create a new Paperspace job.
20
+
* @description Create a new Paperspace job, and tail its log output if run at the command line. To disable the tailing behavior specify '--tail false'. Note: if a project is not defined for the current working directory, and you are running in command line mode, a project configuration settings file will be created. Use '--init false' or specify '--project [projectname]' to override this behavior.
* @param {string} params.container - A required reference to a container name or container link to be used for the job.
19
23
* @param {string} [params.machineType] - An optional machine type to run the job on: either 'GPU+', 'P4000', 'P5000', 'P6000', 'V100', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', or 'C10'.<p>Defaults to 'GPU+'.
@@ -23,6 +27,7 @@ var projectConfig = require('./../projectConfig');
23
27
* @param {string} [params.command] - An optional command to run within the workspace or container.
24
28
* @param {string} [params.workspace] - An optional path to a workspace, or link to a git repository to upload and merge with the container. If a zip file name is provided it is uploaded instead. If no workspace is provided the current directory is zipped up and transferred. If the workspace is 'none', no workspace is merged and the container is run as-is.
25
29
* @param {string} [params.dataset] - An optional reference to a dataset to be merged with the container.
30
+
* @param {boolean} [params.tail] - Optional; defaults to true in command line mode only. Specify false to disable automatic tailing.
26
31
* @param {boolean} [params.json] - Optional; if true, do not write progress to standard out. '--json' with no value is equivalent to true.
27
32
* @param {function} cb - Node-style error-first callback function
28
33
* @returns {object} job - The created job JSON object
@@ -118,6 +123,27 @@ function directorySize(path, cb, size) {
118
123
varMAX_UPLOAD_SIZE=104857600;// 100MB
119
124
120
125
functioncreate(params,cb){
126
+
varjson=false;
127
+
if(params.json){
128
+
json=true;
129
+
// Note: we don't delete params.json because lib/request.js needs to examine it to determine if upload progress should be displayed
130
+
}
131
+
varinit=true;
132
+
if(params.init){
133
+
init=params.init;
134
+
deleteparams.init;
135
+
}
136
+
vartail=global.paperspace_cli&&!json;// tail defaults to true in cli mode, false otherwise;
137
+
if(typeofparams.tail==='boolean'){
138
+
tail=params.tail;
139
+
deleteparams.tail;
140
+
}
141
+
142
+
// XXX TODO trim leading/trailing spaces from input paths
143
+
// XXX TODO whitelist git services
144
+
// XXX TODO convert to gzip
145
+
// XXX TODO stream compress
146
+
121
147
varcwd=process.cwd();
122
148
if(!params.project&&!params.projectId){
123
149
// default to name of project in .ps_project/config.json or name of current directory
@@ -127,18 +153,28 @@ function create(params, cb) {
127
153
if(params.project==='/'){
128
154
returnifCliPrintErrorOnly(newError('Error: cannot create project from root dir. Please create a project dir and run from there.'));
0 commit comments