Fix set artifacts storage destination with output_uri

This commit is contained in:
allegroai 2019-09-14 13:55:17 +03:00
parent 648a972199
commit 2ba372560e
5 changed files with 10 additions and 5 deletions

View File

@ -286,6 +286,9 @@ class UploadEvent(MetricsEventAdapter):
storage_key_prefix = self._override_storage_key_prefix storage_key_prefix = self._override_storage_key_prefix
key = '/'.join(x for x in (storage_key_prefix, self.metric, self.variant, filename.strip('/')) if x) key = '/'.join(x for x in (storage_key_prefix, self.metric, self.variant, filename.strip('/')) if x)
url = '/'.join(x.strip('/') for x in (e_storage_uri, key)) url = '/'.join(x.strip('/') for x in (e_storage_uri, key))
# make sure we preserve local path root
if e_storage_uri.startswith('/'):
url = '/'+url
return key, url return key, url

View File

@ -434,7 +434,7 @@ class ScriptInfo(object):
plugin = next((p for p in cls.plugins if p.exists(script_dir)), None) plugin = next((p for p in cls.plugins if p.exists(script_dir)), None)
repo_info = DetectionResult() repo_info = DetectionResult()
if not plugin: if not plugin:
_log("expected one of: {}", ", ".join((p.name for p in cls.plugins))) log.info("No repository found, storing script code instead")
else: else:
try: try:
repo_info = plugin.get_info(str(script_dir), include_diff=check_uncommitted) repo_info = plugin.get_info(str(script_dir), include_diff=check_uncommitted)

View File

@ -240,11 +240,12 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
return res.response.id return res.response.id
def _set_storage_uri(self, value): def _set_storage_uri(self, value):
value = value.rstrip('/') value = value.rstrip('/') if value else None
self._storage_uri = StorageHelper.conform_url(value) self._storage_uri = StorageHelper.conform_url(value)
self.data.output.destination = self._storage_uri self.data.output.destination = self._storage_uri
self._edit(output_dest=self._storage_uri) self._edit(output_dest=self._storage_uri or '')
self.output_model.upload_storage_uri = self._storage_uri if self._storage_uri or self._output_model:
self.output_model.upload_storage_uri = self._storage_uri
@property @property
def storage_uri(self): def storage_uri(self):

View File

@ -307,7 +307,7 @@ class Artifacts(object):
""" """
Upload local file and return uri of the uploaded file (uploading in the background) Upload local file and return uri of the uploaded file (uploading in the background)
""" """
upload_uri = self._task.get_logger().get_default_upload_destination() upload_uri = self._task.output_uri or self._task.get_logger().get_default_upload_destination()
if not isinstance(local_file, Path): if not isinstance(local_file, Path):
local_file = Path(local_file) local_file = Path(local_file)
ev = UploadEvent(metric='artifacts', variant=name, ev = UploadEvent(metric='artifacts', variant=name,

View File

@ -413,6 +413,7 @@ class Task(_Task):
task.set_model_config(config_text='') task.set_model_config(config_text='')
task.set_model_label_enumeration({}) task.set_model_label_enumeration({})
task.set_artifacts([]) task.set_artifacts([])
task._set_storage_uri(None)
except (Exception, ValueError): except (Exception, ValueError):
# we failed reusing task, create a new one # we failed reusing task, create a new one