Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit 70780b2

Browse files
committed
update job create to support dockerfile logic
1 parent 4663ac6 commit 70780b2

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/jobs/create.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const chalk = require('chalk');
2121
* @method create
2222
* @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.
2323
* @param {object} params - Job creation parameters
24-
* @param {string} params.container - A required reference to a docker image in a public or private docker registry, or a container name provided by Paperspace. Docker image repository references must be in lowercase and may include a tag and a hostname prefix followed by a slash; if ommitted the hostname defaults to that of the public Docker Hub registry. An example docker image reference: 'docker.io/mynamespace/myimage:mytag'. A container name may be mixed case. (Designated container names are currently only provided as part of various Gradient tutorials and samples.)
24+
* @param {string} params.container - A reference to a docker image in a public or private docker registry, or a container name provided by Paperspace. Docker image repository references must be in lowercase and may include a tag and a hostname prefix followed by a slash; if ommitted the hostname defaults to that of the public Docker Hub registry. An example docker image reference: 'docker.io/mynamespace/myimage:mytag'. A container name may be mixed case. (Designated container names are currently only provided as part of various Gradient tutorials and samples.)
2525
* @param {string} [params.cluster] - An optional cluster name of a cluster to run the job on. Only one of cluster or clusterId may be specified.
2626
* @param {string} [params.clusterId] - An optional cluster id of a cluster to run the job on. Only one of cluster or clusterId may be specified.
2727
* @param {string} [params.machineType] - An optional machine type to run the job on: either 'GPU+', 'P4000', 'P5000', 'P6000', 'V100', 'K80', 'P100', 'TPU', or 'GradientNode'.<p>Defaults to 'K80'. <P>Note: the 'K80', 'P100', and 'TPU' machineTypes run on Google Cloud Platform (GCP). The other machineTypes run on the Paperspace Cloud. Google Cloud platform and Paperspace Cloud have distict Job Storage spaces; Job storage is not currently shared between these two cloud environments.
@@ -196,7 +196,11 @@ function create(params, cb) {
196196
delete params.tail;
197197
}
198198

199-
params.command = Buffer.from(params.command).toString('base64');
199+
if (params.useDockerfile && params.buildOnly) {
200+
params.command = null
201+
} else {
202+
params.command = Buffer.from(params.command).toString('base64');
203+
}
200204

201205
// XXX TODO trim leading/trailing spaces from input paths
202206
// XXX TODO whitelist git services
@@ -239,7 +243,7 @@ function create(params, cb) {
239243

240244
projectConfig.setMachineType(params.project, params.machineType);
241245

242-
projectConfig.setContainer(params.project, params.container);
246+
projectConfig.setContainer(params.project, params.container, params.useDockerfile);
243247

244248
projectConfig.setCommand(params.project, params.command);
245249

@@ -249,7 +253,7 @@ function create(params, cb) {
249253

250254
projectConfig.setCluster(params.project, params.cluster);
251255

252-
if (!params.container) return ifCliPrintErrorOnly(new Error('Missing required parameter `container`'));
256+
if (!params.container && !params.useDockerfile) return ifCliPrintErrorOnly(new Error('Missing required parameter `container`'));
253257

254258
if (!params.workspace) params.workspace = cwd;
255259

@@ -516,9 +520,6 @@ assign(create, {
516520
name: 'create',
517521
method: 'post',
518522
route: '/jobs/createJob',
519-
requires: {
520-
container: 'string',
521-
},
522523
file: 'workspace',
523524
returns: {},
524525
});

lib/projectConfig.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ function getContainer(project, container) {
7474
return container;
7575
}
7676

77-
function setContainer(project, container) {
77+
function setContainer(project, container, useDockerfile) {
78+
if (useDockerfile) {
79+
return
80+
}
7881
if (container) {
7982
if ((!project || config.project === project) && config.container !== container) {
8083
config.container = container;

0 commit comments

Comments
 (0)