Skip to content

Commit 3878221

Browse files
committed
Add warn size and make max size configurable
1 parent 9fa910a commit 3878221

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

polyaxon_client/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,9 @@
135135
VALIDATION_UNKNOWN_BEHAVIOUR = config.get_string('POLYAXON_VALIDATION_UNKNOWN_BEHAVIOUR',
136136
is_optional=True,
137137
default=RAISE)
138+
WARN_UPLOAD_SIZE = config.get_int('POLYAXON_WARN_UPLOAD_SIZE',
139+
is_optional=True,
140+
default=1024 * 1024 * 10)
141+
MAX_UPLOAD_SIZE = config.get_int('POLYAXON_MAX_UPLOAD_SIZE',
142+
is_optional=True,
143+
default=1024 * 1024 * 150)

polyaxon_client/transport/http_transport.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
class HttpTransportMixin(object):
2020
"""HTTP operations transport."""
21-
MAX_UPLOAD_SIZE = 1024 * 1024 * 150
22-
2321
@property
2422
def session(self):
2523
if not hasattr(self, '_session'):
@@ -119,13 +117,23 @@ def upload(self,
119117
headers=None,
120118
session=None):
121119

122-
if files_size > self.MAX_UPLOAD_SIZE:
120+
if files_size > settings.WARN_UPLOAD_SIZE:
121+
logger.warning(
122+
"You are uploading %s, there's a hard limit of %s.\n"
123+
"If you have data files in the current directory, "
124+
"please make sure to add them to .polyaxonignore or "
125+
"add them directly to your data volume, or upload them "
126+
"separately using `polyaxon data` command and remove them from here.\n",
127+
self.format_sizeof(settings.WARN_UPLOAD_SIZE),
128+
self.format_sizeof(settings.MAX_UPLOAD_SIZE))
129+
130+
if files_size > settings.MAX_UPLOAD_SIZE:
123131
raise PolyaxonShouldExitError(
124132
"Files too large to sync, please keep it under {}.\n"
125133
"If you have data files in the current directory, "
126134
"please add them directly to your data volume, or upload them "
127135
"separately using `polyaxon data` command and remove them from here.\n".format(
128-
self.format_sizeof(self.MAX_UPLOAD_SIZE)))
136+
self.format_sizeof(settings.MAX_UPLOAD_SIZE)))
129137

130138
files = to_list(files)
131139
if json_data:

0 commit comments

Comments
 (0)