Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 20ce0af

Browse files
committed
create_job init
2 parents 17dea50 + 14db572 commit 20ce0af

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

paperspace/cli/jobs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ def list_jobs(api_key, **filters):
6060
jobs_api = client.API(config.CONFIG_HOST, api_key=api_key)
6161
command = jobs_commands.ListJobsCommand(api=jobs_api)
6262
command.execute(filters)
63+
64+
65+
@jobs_group.command("create", help="Create job")
66+
@common.api_key_option
67+
def create_job(api_key, **kwargs):
68+
jobs_api = client.API(config.CONFIG_HOST, api_key=api_key)
69+
command = jobs_commands.CreateJobCommand(api=jobs_api)
70+
command.execute(kwargs)

paperspace/commands/jobs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from paperspace.commands import CommandBase
66
from paperspace.utils import get_terminal_lines
7+
from paperspace.workspace import S3WorkspaceHandler
78

89

910
class JobsCommandBase(CommandBase):
@@ -82,3 +83,16 @@ def _make_table(jobs):
8283
ascii_table = terminaltables.AsciiTable(data)
8384
table_string = ascii_table.table
8485
return table_string
86+
87+
88+
class CreateJobCommand(JobsCommandBase):
89+
def __init__(self, workspace_handler=None, **kwargs):
90+
super(CreateJobCommand, self).__init__(**kwargs)
91+
self.workspace_handler = workspace_handler or S3WorkspaceHandler(api=self.api, logger=self.logger)
92+
93+
def execute(self, json_):
94+
url = "/jobs/createJob/"
95+
response = self.api.post(url, json_)
96+
self._log_message(response,
97+
"Job created",
98+
"Unknown error while creating job")

0 commit comments

Comments
 (0)