From 59932e4f4ce5ae9caf2de24e2dbe614e2f4b10b9 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 18 Sep 2022 14:18:40 +0300 Subject: [PATCH] Fix python 2.7 support --- clearml/backend_config/utils.py | 2 +- clearml/backend_interface/task/repo/scriptinfo.py | 4 +++- clearml/backend_interface/task/task.py | 3 ++- clearml/datasets/dataset.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/clearml/backend_config/utils.py b/clearml/backend_config/utils.py index 2ed4f6b8..098a2216 100644 --- a/clearml/backend_config/utils.py +++ b/clearml/backend_config/utils.py @@ -1,7 +1,7 @@ import base64 import os from os.path import expandvars, expanduser -from pathlib import Path +from pathlib2 import Path from typing import List, TYPE_CHECKING from ..utilities.pyhocon import HOCONConverter, ConfigTree diff --git a/clearml/backend_interface/task/repo/scriptinfo.py b/clearml/backend_interface/task/repo/scriptinfo.py index bd17251c..03870da5 100644 --- a/clearml/backend_interface/task/repo/scriptinfo.py +++ b/clearml/backend_interface/task/repo/scriptinfo.py @@ -705,11 +705,13 @@ class ScriptInfo(object): @classmethod def _get_entry_point(cls, repo_root, script_path): repo_root = Path(repo_root).absolute() + script_path = Path(script_path) try: # Use os.path.relpath as it calculates up dir movements (../) entry_point = os.path.relpath( - str(os.path.realpath(script_path)), str(cls._get_working_dir(repo_root, return_abs=True))) + str(os.path.realpath(script_path.as_posix())), + str(cls._get_working_dir(repo_root, return_abs=True))) except ValueError: # Working directory not under repository root entry_point = script_path.relative_to(repo_root) diff --git a/clearml/backend_interface/task/task.py b/clearml/backend_interface/task/task.py index db538c3d..376d3cd9 100644 --- a/clearml/backend_interface/task/task.py +++ b/clearml/backend_interface/task/task.py @@ -2206,7 +2206,8 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin): # make sure we have str as values: for key in requirements.keys(): - if requirements[key] and not isinstance(requirements[key], str): + # fix python2 support (str/unicode) + if requirements[key] and not isinstance(requirements[key], six.string_types): requirements[key] = '\n'.join(requirements[key]) # protection, Old API might not support it diff --git a/clearml/datasets/dataset.py b/clearml/datasets/dataset.py index e10b92a6..8aac6a98 100644 --- a/clearml/datasets/dataset.py +++ b/clearml/datasets/dataset.py @@ -1558,7 +1558,8 @@ class Dataset(object): raise ValueError("Dataset selection criteria not met. Didn't provide id/name/project/tags correctly.") if not alias: LoggerRoot.get_base_logger().info( - "Dataset.get() did not specify alias. Dataset information won’t be automatically logged in ClearML Server.") + "Dataset.get() did not specify alias. Dataset information " + "will not be automatically logged in ClearML Server.") mutually_exclusive(dataset_id=dataset_id, dataset_project=dataset_project, _require_at_least_one=False) mutually_exclusive(dataset_id=dataset_id, dataset_name=dataset_name, _require_at_least_one=False)