Fix path limitation on storage services (posix, object storage) when storing target artifacts by limiting length of project name (full path) and task name used for object path (issue #516)

This commit is contained in:
allegroai 2021-12-17 11:58:44 +02:00
parent 6f6c5e9f5e
commit fd2d6c6f5d

View File

@ -503,8 +503,19 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
def _get_output_destination_suffix(self, extra_path=None): def _get_output_destination_suffix(self, extra_path=None):
# type: (Optional[str]) -> str # type: (Optional[str]) -> str
# limit path to support various storage infrastructure limits (such as max path pn posix or object storage)
# project path limit to 256 (including subproject names), and task name limit to 128.
def limit_folder_name(a_name, uuid, max_length, always_add_uuid):
if always_add_uuid:
return '{}.{}'.format(a_name[:max(2, max_length-len(uuid)-1)], uuid)
if len(a_name) < max_length:
return a_name
return '{}.{}'.format(a_name[:max(2, max_length-len(uuid)-1)], uuid)
return '/'.join(quote(x, safe="'[]{}()$^,.; -_+-=") for x in return '/'.join(quote(x, safe="'[]{}()$^,.; -_+-=") for x in
(self.get_project_name(), '%s.%s' % (self.name, self.data.id), extra_path) if x) (limit_folder_name(self.get_project_name(), str(self.project), 256, False),
limit_folder_name(self.name, str(self.data.id), 128, True),
extra_path) if x)
def _reload(self): def _reload(self):
# type: () -> Any # type: () -> Any