mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Fix PY2 compatibility
This commit is contained in:
parent
8e31e789b4
commit
e47f570ce5
@ -562,7 +562,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
def completed(self, ignore_errors=True):
|
def completed(self, ignore_errors=True):
|
||||||
# type: (bool) -> ()
|
# type: (bool) -> ()
|
||||||
"""
|
"""
|
||||||
.. note:: Deprecated in 1.1.0
|
.. note:: Deprecated, use mark_completed(...) instead
|
||||||
"""
|
"""
|
||||||
warnings.warn("'completed' is deprecated; use 'mark_completed' instead.", DeprecationWarning)
|
warnings.warn("'completed' is deprecated; use 'mark_completed' instead.", DeprecationWarning)
|
||||||
return self.mark_completed(ignore_errors=ignore_errors)
|
return self.mark_completed(ignore_errors=ignore_errors)
|
||||||
|
@ -104,7 +104,7 @@ class PatchClick:
|
|||||||
if 'args' in kwargs:
|
if 'args' in kwargs:
|
||||||
kwargs['args'] = init_args
|
kwargs['args'] = init_args
|
||||||
else:
|
else:
|
||||||
args = (args[0], init_args, *args[2:])
|
args = (args[0], init_args) + args[2:]
|
||||||
|
|
||||||
ret = original_fn(self, *args, **kwargs)
|
ret = original_fn(self, *args, **kwargs)
|
||||||
|
|
@ -18,7 +18,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from collections import Sequence as CollectionsSequence
|
from collections import Sequence as CollectionsSequence
|
||||||
|
|
||||||
from typing import Optional, Union, Mapping, Sequence, Any, Dict, Iterable, TYPE_CHECKING, Callable
|
from typing import Optional, Union, Mapping, Sequence, Any, Dict, Iterable, TYPE_CHECKING, Callable, Tuple
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import six
|
import six
|
||||||
@ -630,22 +630,22 @@ class Task(_Task):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create(
|
def create(
|
||||||
cls,
|
cls,
|
||||||
project_name=None, # Optional[str]
|
project_name=None, # type: Optional[str]
|
||||||
task_name=None, # Optional[str]
|
task_name=None, # type: Optional[str]
|
||||||
task_type=None, # Optional[str]
|
task_type=None, # type: Optional[str]
|
||||||
repo=None, # Optional[str]
|
repo=None, # type: Optional[str]
|
||||||
branch=None, # Optional[str]
|
branch=None, # type: Optional[str]
|
||||||
commit=None, # Optional[str]
|
commit=None, # type: Optional[str]
|
||||||
script=None, # Optional[str]
|
script=None, # type: Optional[str]
|
||||||
working_directory=None, # Optional[str]
|
working_directory=None, # type: Optional[str]
|
||||||
packages=None, # Optional[Union[bool, Sequence[str]]]
|
packages=None, # type: Optional[Union[bool, Sequence[str]]]
|
||||||
requirements_file=None, # Optional[Union[str, Path]]
|
requirements_file=None, # type: Optional[Union[str, Path]]
|
||||||
docker=None, # Optional[str]
|
docker=None, # type: Optional[str]
|
||||||
docker_args=None, # Optional[str]
|
docker_args=None, # type: Optional[str]
|
||||||
docker_bash_setup_script=None, # Optional[str]
|
docker_bash_setup_script=None, # type: Optional[str]
|
||||||
argparse_args=None, # Optional[Sequence[Tuple[str, str]]]
|
argparse_args=None, # type: Optional[Sequence[Tuple[str, str]]]
|
||||||
base_task_id=None, # Optional[str]
|
base_task_id=None, # type: Optional[str]
|
||||||
add_task_init_call=True, # bool
|
add_task_init_call=True, # type: bool
|
||||||
):
|
):
|
||||||
# type: (...) -> Task
|
# type: (...) -> Task
|
||||||
"""
|
"""
|
||||||
|
@ -7,7 +7,7 @@ from multiprocessing import Lock, Event as ProcessEvent
|
|||||||
from threading import Thread, Event as TrEvent
|
from threading import Thread, Event as TrEvent
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from typing import List, Dict, Optional
|
from typing import List, Dict, Optional
|
||||||
from multiprocessing import Process, get_context
|
from multiprocessing import Process
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
from six.moves.queue import Empty, Queue as TrQueue
|
from six.moves.queue import Empty, Queue as TrQueue
|
||||||
@ -19,11 +19,19 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from multiprocessing.queues import SimpleQueue
|
from multiprocessing.queues import SimpleQueue
|
||||||
|
|
||||||
|
# Windows/MacOS compatibility
|
||||||
try:
|
try:
|
||||||
from multiprocessing.context import ForkContext # noqa
|
from multiprocessing.context import ForkContext # noqa
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ForkContext = None
|
ForkContext = None
|
||||||
|
|
||||||
|
# PY2 compatibility
|
||||||
|
try:
|
||||||
|
from multiprocessing import get_context
|
||||||
|
except ImportError:
|
||||||
|
def get_context(*args, **kwargs):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class ThreadCalls(object):
|
class ThreadCalls(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user