mirror of
https://github.com/clearml/clearml
synced 2025-03-03 18:52:12 +00:00
Add safety guards for Model creation / cache lookup
This commit is contained in:
parent
9f9452ecf4
commit
5fbfa1d6e2
@ -566,7 +566,7 @@ class InputModel(Model):
|
|||||||
if task:
|
if task:
|
||||||
comment = 'Imported by task id: {}'.format(task.id) + ('\n' + comment if comment else '')
|
comment = 'Imported by task id: {}'.format(task.id) + ('\n' + comment if comment else '')
|
||||||
project_id = task.project
|
project_id = task.project
|
||||||
name = name or task.name
|
name = name or 'Imported by {}'.format(task.name or '')
|
||||||
# do not register the Task, because we do not want it listed after as "output model",
|
# do not register the Task, because we do not want it listed after as "output model",
|
||||||
# the Task never actually created the Model
|
# the Task never actually created the Model
|
||||||
task_id = None
|
task_id = None
|
||||||
@ -931,7 +931,7 @@ class OutputModel(BaseModel):
|
|||||||
self._floating_data = create_dummy_model(
|
self._floating_data = create_dummy_model(
|
||||||
design=_Model._wrap_design(config_text),
|
design=_Model._wrap_design(config_text),
|
||||||
labels=label_enumeration or task.get_labels_enumeration(),
|
labels=label_enumeration or task.get_labels_enumeration(),
|
||||||
name=name or task.name,
|
name=name or self._task.name,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
comment='{} by task id: {}'.format('Created' if not base_model_id else 'Overwritten', task.id) +
|
comment='{} by task id: {}'.format('Created' if not base_model_id else 'Overwritten', task.id) +
|
||||||
('\n' + comment if comment else ''),
|
('\n' + comment if comment else ''),
|
||||||
@ -946,7 +946,7 @@ class OutputModel(BaseModel):
|
|||||||
design=self._floating_data.design,
|
design=self._floating_data.design,
|
||||||
task_id=self._task.id,
|
task_id=self._task.id,
|
||||||
project_id=self._task.project,
|
project_id=self._task.project,
|
||||||
name=self._floating_data.name or task.name,
|
name=self._floating_data.name or self._task.name,
|
||||||
comment=('{}\n{}'.format(_base_model.comment, self._floating_data.comment)
|
comment=('{}\n{}'.format(_base_model.comment, self._floating_data.comment)
|
||||||
if (_base_model.comment and self._floating_data.comment and
|
if (_base_model.comment and self._floating_data.comment and
|
||||||
self._floating_data.comment not in _base_model.comment)
|
self._floating_data.comment not in _base_model.comment)
|
||||||
|
@ -136,7 +136,13 @@ class CacheManager(object):
|
|||||||
def get_remote_url(local_copy_path):
|
def get_remote_url(local_copy_path):
|
||||||
if not CacheManager._local_to_remote_url_lookup:
|
if not CacheManager._local_to_remote_url_lookup:
|
||||||
return local_copy_path
|
return local_copy_path
|
||||||
conform_local_copy_path = StorageHelper.conform_url(local_copy_path)
|
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
conform_local_copy_path = StorageHelper.conform_url(str(local_copy_path))
|
||||||
|
except Exception:
|
||||||
|
return local_copy_path
|
||||||
|
|
||||||
return CacheManager._local_to_remote_url_lookup.get(hash(conform_local_copy_path), local_copy_path)
|
return CacheManager._local_to_remote_url_lookup.get(hash(conform_local_copy_path), local_copy_path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -144,10 +150,23 @@ class CacheManager(object):
|
|||||||
# so that we can disable the cache lookup altogether
|
# so that we can disable the cache lookup altogether
|
||||||
if CacheManager._local_to_remote_url_lookup is None:
|
if CacheManager._local_to_remote_url_lookup is None:
|
||||||
return
|
return
|
||||||
remote_url = StorageHelper.conform_url(remote_url)
|
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
remote_url = StorageHelper.conform_url(str(remote_url))
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
|
||||||
if remote_url.startswith('file://'):
|
if remote_url.startswith('file://'):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
local_copy_path = str(local_copy_path)
|
||||||
|
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
local_copy_path = StorageHelper.conform_url(local_copy_path)
|
local_copy_path = StorageHelper.conform_url(local_copy_path)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
CacheManager._local_to_remote_url_lookup[hash(local_copy_path)] = remote_url
|
CacheManager._local_to_remote_url_lookup[hash(local_copy_path)] = remote_url
|
||||||
# protect against overuse, so we do not blowup the memory
|
# protect against overuse, so we do not blowup the memory
|
||||||
if len(CacheManager._local_to_remote_url_lookup) > CacheManager.__local_to_remote_url_lookup_max_size:
|
if len(CacheManager._local_to_remote_url_lookup) > CacheManager.__local_to_remote_url_lookup_max_size:
|
||||||
|
Loading…
Reference in New Issue
Block a user