Fix various CI and tests issues

This commit is contained in:
allegroai 2023-11-05 21:00:04 +02:00
parent 2f05a830b5
commit d6d8aa9318
7 changed files with 21 additions and 20 deletions

View File

@ -142,7 +142,7 @@ class PipelineController(object):
try: try:
self.job.task.reload() self.job.task.reload()
self.job_ended = self.job_started + self.job.task.data.active_duration self.job_ended = self.job_started + self.job.task.data.active_duration
except Exception as e: except Exception:
pass pass
def set_job_started(self): def set_job_started(self):
@ -154,7 +154,6 @@ class PipelineController(object):
except Exception: except Exception:
pass pass
def __init__( def __init__(
self, self,
name, # type: str name, # type: str
@ -2733,7 +2732,7 @@ class PipelineController(object):
if node_failed and self._abort_running_steps_on_failure and not node.continue_on_fail: if node_failed and self._abort_running_steps_on_failure and not node.continue_on_fail:
nodes_failed_stop_pipeline.append(node.name) nodes_failed_stop_pipeline.append(node.name)
elif node.timeout: elif node.timeout:
node.set_job_started() started = node.job.task.data.started
if (datetime.now().astimezone(started.tzinfo) - started).total_seconds() > node.timeout: if (datetime.now().astimezone(started.tzinfo) - started).total_seconds() > node.timeout:
node.job.abort() node.job.abort()
completed_jobs.append(j) completed_jobs.append(j)

View File

@ -178,8 +178,9 @@ class IdObjectBase(InterfaceBase):
# noinspection PyBroadException # noinspection PyBroadException
try: try:
self._data = self._reload() self._data = self._reload()
except Exception: except Exception as ex:
self.log.error("Failed reloading task {}".format(self.id)) self.log.error("Failed reloading {} {}".format(type(self).__name__.lower(), self.id))
self.log.debug("Failed reloading {} {}: {}".format(type(self).__name__.lower(), self.id, ex))
@classmethod @classmethod
def normalize_id(cls, id): def normalize_id(cls, id):

View File

@ -1,7 +1,6 @@
import io import io
import sys import sys
from functools import partial from functools import partial
import yaml
from ..config import running_remotely, get_remote_task_id, DEV_TASK_NO_REUSE from ..config import running_remotely, get_remote_task_id, DEV_TASK_NO_REUSE
from ..debugging.log import LoggerRoot from ..debugging.log import LoggerRoot

View File

@ -1,9 +1,8 @@
import abc import abc
import os import os
import tarfile
import zipfile import zipfile
import shutil import shutil
from tempfile import mkdtemp, mkstemp from tempfile import mkstemp
import six import six
import math import math

View File

@ -1524,6 +1524,7 @@ class Task(_Task):
specified, then a path to a local configuration file is returned. Configuration object. specified, then a path to a local configuration file is returned. Configuration object.
""" """
pathlib_Path = None # noqa pathlib_Path = None # noqa
cast_Path = Path
if not isinstance(configuration, (dict, list, Path, six.string_types)): if not isinstance(configuration, (dict, list, Path, six.string_types)):
try: try:
from pathlib import Path as pathlib_Path # noqa from pathlib import Path as pathlib_Path # noqa
@ -1532,6 +1533,8 @@ class Task(_Task):
if not pathlib_Path or not isinstance(configuration, pathlib_Path): if not pathlib_Path or not isinstance(configuration, pathlib_Path):
raise ValueError("connect_configuration supports `dict`, `str` and 'Path' types, " raise ValueError("connect_configuration supports `dict`, `str` and 'Path' types, "
"{} is not supported".format(type(configuration))) "{} is not supported".format(type(configuration)))
if pathlib_Path and isinstance(configuration, pathlib_Path):
cast_Path = pathlib_Path
multi_config_support = Session.check_min_api_version('2.9') multi_config_support = Session.check_min_api_version('2.9')
if multi_config_support and not name: if multi_config_support and not name:
@ -1599,7 +1602,7 @@ class Task(_Task):
# it is a path to a local file # it is a path to a local file
if not running_remotely() or not (self.is_main_task() or self._is_remote_main_task()): if not running_remotely() or not (self.is_main_task() or self._is_remote_main_task()):
# check if not absolute path # check if not absolute path
configuration_path = Path(configuration) configuration_path = cast_Path(configuration)
if not configuration_path.is_file(): if not configuration_path.is_file():
ValueError("Configuration file does not exist") ValueError("Configuration file does not exist")
try: try:
@ -1626,7 +1629,7 @@ class Task(_Task):
"Using default configuration: {}".format(name, str(configuration))) "Using default configuration: {}".format(name, str(configuration)))
# update back configuration section # update back configuration section
if multi_config_support: if multi_config_support:
configuration_path = Path(configuration) configuration_path = cast_Path(configuration)
if configuration_path.is_file(): if configuration_path.is_file():
with open(configuration_path.as_posix(), 'rt') as f: with open(configuration_path.as_posix(), 'rt') as f:
configuration_text = f.read() configuration_text = f.read()
@ -1638,15 +1641,13 @@ class Task(_Task):
config_text=configuration_text) config_text=configuration_text)
return configuration return configuration
configuration_path = Path(configuration) configuration_path = cast_Path(configuration)
fd, local_filename = mkstemp(prefix='clearml_task_config_', fd, local_filename = mkstemp(prefix='clearml_task_config_',
suffix=configuration_path.suffixes[-1] if suffix=configuration_path.suffixes[-1] if
configuration_path.suffixes else '.txt') configuration_path.suffixes else '.txt')
with open(fd, "w") as f: with open(fd, "w") as f:
f.write(configuration_text) f.write(configuration_text)
if pathlib_Path: return cast_Path(local_filename) if isinstance(configuration, cast_Path) else local_filename
return pathlib_Path(local_filename)
return Path(local_filename) if isinstance(configuration, Path) else local_filename
def connect_label_enumeration(self, enumeration): def connect_label_enumeration(self, enumeration):
# type: (Dict[str, int]) -> Dict[str, int] # type: (Dict[str, int]) -> Dict[str, int]

View File

@ -2,9 +2,11 @@ clearml
jsonschema==3.2.0 ; python_version <= '3.5' jsonschema==3.2.0 ; python_version <= '3.5'
matplotlib matplotlib
pytorch-ignite pytorch-ignite
tensorboard>=1.14.0 tensorboard<=2.11.2 ; python_version <= '3.7'
tensorboard>2.11.2 ; python_version > '3.7'
tensorboardX tensorboardX
torch>=1.1.0 torch>=1.1.0
torchvision>=0.3.0 torchvision>=0.3.0
tqdm tqdm
protobuf>=4.21.1 protobuf==3.20.* ; python_version <= '3.7'
protobuf>=4.21.1 ; python_version > '3.7'

View File

@ -21,14 +21,14 @@ task = Task.init(project_name='FirstTrial', task_name='config_files_example')
config_file = task.connect_configuration(Path("data_samples") / "sample.json", name='json config file') config_file = task.connect_configuration(Path("data_samples") / "sample.json", name='json config file')
with open(config_file, "rt") as f: with open(config_file.as_posix(), "rt") as f:
config_json = json.load(f) config_json = json.load(f)
print(config_json) print(config_json)
config_file = task.connect_configuration(Path("data_samples") / "config_yaml.yaml", name='yaml config file') config_file = task.connect_configuration(Path("data_samples") / "config_yaml.yaml", name='yaml config file')
with open(config_file, "rt") as f: with open(config_file.as_posix(), "rt") as f:
config_yaml = yaml.load(f, Loader=yaml.SafeLoader) config_yaml = yaml.load(f, Loader=yaml.SafeLoader)
print(config_yaml) print(config_yaml)