mirror of
https://github.com/clearml/clearml
synced 2025-04-18 21:34:41 +00:00
Improve Windows support
This commit is contained in:
parent
d8e54b466c
commit
1bfee56977
@ -87,6 +87,9 @@ class MetricsEventAdapter(object):
|
|||||||
""" Get information for a file that should be uploaded before this event is sent """
|
""" Get information for a file that should be uploaded before this event is sent """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_iteration(self):
|
||||||
|
return self._iter
|
||||||
|
|
||||||
def update(self, task=None, **kwargs):
|
def update(self, task=None, **kwargs):
|
||||||
""" Update event properties """
|
""" Update event properties """
|
||||||
if task:
|
if task:
|
||||||
@ -175,6 +178,10 @@ class UploadEvent(MetricsEventAdapter):
|
|||||||
_metric_counters_lock = Lock()
|
_metric_counters_lock = Lock()
|
||||||
_image_file_history_size = int(config.get('metrics.file_history_size', 5))
|
_image_file_history_size = int(config.get('metrics.file_history_size', 5))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _replace_slash(part):
|
||||||
|
return part.replace('\\', '/').strip('/').replace('/', '.slash.')
|
||||||
|
|
||||||
def __init__(self, metric, variant, image_data, local_image_path=None, iter=0, upload_uri=None,
|
def __init__(self, metric, variant, image_data, local_image_path=None, iter=0, upload_uri=None,
|
||||||
image_file_history_size=None, delete_after_upload=False, **kwargs):
|
image_file_history_size=None, delete_after_upload=False, **kwargs):
|
||||||
# param override_filename: override uploaded file name (notice extension will be added from local path
|
# param override_filename: override uploaded file name (notice extension will be added from local path
|
||||||
@ -194,6 +201,11 @@ class UploadEvent(MetricsEventAdapter):
|
|||||||
self._filename = '%s_%s_%08d' % (metric, variant, self._count)
|
self._filename = '%s_%s_%08d' % (metric, variant, self._count)
|
||||||
else:
|
else:
|
||||||
self._filename = '%s_%s_%08d' % (metric, variant, self._count % image_file_history_size)
|
self._filename = '%s_%s_%08d' % (metric, variant, self._count % image_file_history_size)
|
||||||
|
|
||||||
|
# make sure we have to '/' in the filename because it might access other folders,
|
||||||
|
# and we don't want that to occur
|
||||||
|
self._filename = self._replace_slash(self._filename)
|
||||||
|
|
||||||
self._upload_uri = upload_uri
|
self._upload_uri = upload_uri
|
||||||
self._delete_after_upload = delete_after_upload
|
self._delete_after_upload = delete_after_upload
|
||||||
|
|
||||||
@ -288,7 +300,8 @@ class UploadEvent(MetricsEventAdapter):
|
|||||||
filename = self._upload_filename
|
filename = self._upload_filename
|
||||||
if self._override_storage_key_prefix or not storage_key_prefix:
|
if self._override_storage_key_prefix or not storage_key_prefix:
|
||||||
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._replace_slash(self.metric),
|
||||||
|
self._replace_slash(self.variant), self._replace_slash(filename)) 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
|
# make sure we preserve local path root
|
||||||
if e_storage_uri.startswith('/'):
|
if e_storage_uri.startswith('/'):
|
||||||
|
@ -211,6 +211,22 @@ class _Arguments(object):
|
|||||||
task_arguments[k] = v
|
task_arguments[k] = v
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
elif current_action and current_action.type == bool:
|
||||||
|
# parser.set_defaults cannot cast string `False`/`True` to boolean properly,
|
||||||
|
# so we have to do it manually here
|
||||||
|
strip_v = str(v).lower().strip()
|
||||||
|
if strip_v == 'false' or not strip_v:
|
||||||
|
v = False
|
||||||
|
elif strip_v == 'true':
|
||||||
|
v = True
|
||||||
|
else:
|
||||||
|
# else, try to cast to integer
|
||||||
|
try:
|
||||||
|
v = int(strip_v)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
task_arguments[k] = v
|
||||||
|
|
||||||
# add as default
|
# add as default
|
||||||
try:
|
try:
|
||||||
if current_action and isinstance(current_action, _SubParsersAction):
|
if current_action and isinstance(current_action, _SubParsersAction):
|
||||||
|
Loading…
Reference in New Issue
Block a user