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

Commit ab98094

Browse files
committed
more clear exception handling + relative import tweak
1 parent 5a9d764 commit ab98094

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

paperspace/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class PresignedUrlUnreachableException(ApplicationException):
1010
pass
1111

1212

13+
class ProjectAccessDeniedException(ApplicationException):
14+
pass
15+
16+
1317
class PresignedUrlAccessDeniedException(ApplicationException):
1418
pass
1519

paperspace/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
from paperspace.cli.cli import cli
4+
from .cli.cli import cli
55
from .jobs import run, print_json_pretty
66
from .login import set_apikey
77
from .version import version

paperspace/workspace.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from paperspace import logger as default_logger
1010

1111
from paperspace.exceptions import S3UploadFailedException, PresignedUrlUnreachableException, \
12-
PresignedUrlAccessDeniedException, PresignedUrlConnectionException
12+
PresignedUrlAccessDeniedException, PresignedUrlConnectionException, ProjectAccessDeniedException
1313

1414

1515
class S3WorkspaceHandler:
@@ -130,10 +130,12 @@ def _upload(self, archive_path, s3_upload_data):
130130
def _get_upload_data(self, file_name, project_handle):
131131
response = self.experiments_api.get("/workspace/get_presigned_url",
132132
params={'workspaceName': file_name, 'projectHandle': project_handle})
133-
if response.status_code == 404:
134-
raise PresignedUrlUnreachableException
133+
if response.status_code == 401:
134+
raise ProjectAccessDeniedException(project_handle)
135135
if response.status_code == 403:
136136
raise PresignedUrlAccessDeniedException
137+
if response.status_code == 404:
138+
raise PresignedUrlUnreachableException
137139
if not response.ok:
138140
raise PresignedUrlConnectionException(response.reason)
139141
return response.json()

0 commit comments

Comments
 (0)