1
0
mirror of https://github.com/clearml/clearml synced 2025-05-13 17:10:38 +00:00

Merge pull request from tirkarthi/fix-collections

Import ABC from collections.abc instead of collections for Python 3.9 compatibility
This commit is contained in:
Allegro AI 2020-03-05 00:37:04 +02:00 committed by GitHub
commit cc1508b2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions
trains
backend_interface
task.py

View File

@ -1,6 +1,10 @@
import collections
import json import json
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import six import six
import numpy as np import numpy as np
from threading import Thread, Event from threading import Thread, Event
@ -152,7 +156,7 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
:param iter: Iteration number :param iter: Iteration number
:type value: int :type value: int
""" """
if not isinstance(values, collections.Iterable): if not isinstance(values, Iterable):
raise ValueError('values: expected an iterable') raise ValueError('values: expected an iterable')
ev = VectorEvent(metric=self._normalize_name(title), variant=self._normalize_name(series), values=values, iter=iter) ev = VectorEvent(metric=self._normalize_name(title), variant=self._normalize_name(series), values=values, iter=iter)
self._report(ev) self._report(ev)

View File

@ -1,5 +1,4 @@
""" Backend task management support """ """ Backend task management support """
import collections
import itertools import itertools
import logging import logging
import os import os
@ -7,6 +6,11 @@ from enum import Enum
from threading import Thread from threading import Thread
from multiprocessing import RLock from multiprocessing import RLock
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import six import six
from six.moves.urllib.parse import quote from six.moves.urllib.parse import quote
@ -587,7 +591,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
a single key/value dictionary. a single key/value dictionary.
:param kwargs: Key/value pairs, merged into the parameters dictionary created from `args`. :param kwargs: Key/value pairs, merged into the parameters dictionary created from `args`.
""" """
if not all(isinstance(x, (dict, collections.Iterable)) for x in args): if not all(isinstance(x, (dict, Iterable)) for x in args):
raise ValueError('only dict or iterable are supported as positional arguments') raise ValueError('only dict or iterable are supported as positional arguments')
update = kwargs.pop('__update', False) update = kwargs.pop('__update', False)

View File

@ -5,13 +5,12 @@ import sys
import threading import threading
import time import time
from argparse import ArgumentParser from argparse import ArgumentParser
from collections import Callable
from tempfile import mkstemp from tempfile import mkstemp
try: try:
from collections.abc import Sequence from collections.abc import Callable, Sequence
except ImportError: except ImportError:
from collections import Sequence from collections import Callable, Sequence
from typing import Optional from typing import Optional