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

Commit cfdef94

Browse files
committed
workspaces tweak, some minor renamings
1 parent b1a6809 commit cfdef94

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

paperspace/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def get_path(self, url):
3030

3131
def post(self, url, json=None, params=None, files=None, data=None):
3232
path = self.get_path(url)
33-
logger.debug("POST request sent to: {} \n\theaders: {}\n\tjson: {}\n\tparams: {}\n\tdata: {}"
34-
.format(path, self.headers, json, params, data))
33+
logger.debug("POST request sent to: {} \n\theaders: {}\n\tjson: {}\n\tparams: {}\n\tfiles: {}\n\tdata: {}"
34+
.format(path, self.headers, json, params, files, data))
3535
response = requests.post(path, json=json, params=params, headers=self.headers, files=files, data=data)
3636
logger.debug("Response status code: {}".format(response.status_code))
3737
logger.debug("Response content: {}".format(response.content))

paperspace/commands/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import terminaltables
44
from click import style
55

6-
from paperspace import config, client
76
from paperspace.commands import common
87
from paperspace.exceptions import BadResponseError
98
from paperspace.utils import get_terminal_lines
10-
from paperspace.workspace import S3WorkspaceHandler, WorkspaceHandler
9+
from paperspace.workspace import WorkspaceHandler
1110

1211

1312
class JobsCommandBase(common.CommandBase):
@@ -144,6 +143,7 @@ def execute(self, json_):
144143

145144
self.set_project(json_)
146145

146+
self.logger.log("Creating job...")
147147
response = self.api.post(url, params=json_, files=files)
148148
self._log_message(response,
149149
"Job created",

paperspace/workspace.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
class MultipartEncoder(object):
1717
def __init__(self, fields):
18-
s3_encoder = encoder.MultipartEncoder(fields=fields)
19-
self.monitor = encoder.MultipartEncoderMonitor(s3_encoder, callback=self._create_callback(s3_encoder))
18+
mp_encoder = encoder.MultipartEncoder(fields=fields)
19+
self.monitor = encoder.MultipartEncoderMonitor(mp_encoder, callback=self._create_callback(mp_encoder))
2020

2121
def get_monitor(self):
2222
return self.monitor
@@ -103,9 +103,14 @@ def handle(self, input_data):
103103
if workspace_url:
104104
return # nothing to do
105105

106+
# Should be removed as soon it won't be necessary by PS_API
107+
if workspace_path == 'none':
108+
return 'none'
106109
if workspace_archive:
107110
archive_path = os.path.abspath(workspace_archive)
108111
else:
112+
self.logger.log('Archiving your working directory for upload as your experiment workspace...'
113+
'(See https://docs.paperspace.com/gradient/experiments/run-experiments for more information.)')
109114
archive_path = self._zip_workspace(workspace_path, ignore_files)
110115
self.archive_path = archive_path
111116
self.archive_basename = os.path.basename(archive_path)
@@ -137,21 +142,9 @@ def __init__(self, experiments_api, logger=None):
137142
self.experiments_api = experiments_api
138143

139144
def handle(self, input_data):
140-
workspace_archive, workspace_path, workspace_url = self._validate_input(input_data)
141-
ignore_files = input_data.get('ignore_files')
142-
143-
if workspace_url:
144-
return # nothing to do
145-
146-
# Should be removed as soon it won't be necessary by PS_API
147-
if workspace_path == 'none':
148-
return 'none'
149-
if workspace_archive:
150-
archive_path = os.path.abspath(workspace_archive)
151-
else:
152-
self.logger.log('Archiving your working directory for upload as your experiment workspace...'
153-
'(See https://docs.paperspace.com/gradient/experiments/run-experiments for more information.)')
154-
archive_path = self._zip_workspace(workspace_path, ignore_files)
145+
archive_path = super(S3WorkspaceHandler, self).handle(input_data)
146+
if archive_path in ['none', None]:
147+
return archive_path
155148

156149
file_name = os.path.basename(archive_path)
157150
project_handle = input_data['projectHandle']

0 commit comments

Comments
 (0)