mirror of
https://github.com/clearml/clearml
synced 2025-03-03 10:42:00 +00:00
PEP8
This commit is contained in:
parent
94d28ed44f
commit
0bc43a31f4
@ -12,7 +12,7 @@ from .datasets import Dataset
|
||||
TaskTypes = Task.TaskTypes
|
||||
|
||||
if not PY2:
|
||||
from .automation.controller import PipelineController
|
||||
from .automation.controller import PipelineController # noqa: F401
|
||||
|
||||
__all__ = [
|
||||
"__version__",
|
||||
|
@ -660,7 +660,7 @@ class LocalClearmlJob(ClearmlJob):
|
||||
|
||||
if not user_aborted:
|
||||
self.task.mark_failed(force=True)
|
||||
|
||||
|
||||
return exit_code
|
||||
|
||||
def status(self, force=False):
|
||||
|
@ -204,7 +204,7 @@ class LogUniformParameterRange(UniformParameterRange):
|
||||
"""
|
||||
super().__init__(name, min_value, max_value, step_size=step_size, include_max_value=include_max_value)
|
||||
self.base = base
|
||||
|
||||
|
||||
def get_value(self):
|
||||
"""
|
||||
Return uniformly logarithmic sampled value based on object sampling definitions.
|
||||
@ -213,11 +213,11 @@ class LogUniformParameterRange(UniformParameterRange):
|
||||
"""
|
||||
values_dict = super().get_value()
|
||||
return {self.name: self.base**v for v in values_dict.values()}
|
||||
|
||||
|
||||
def to_list(self):
|
||||
values_list = super().to_list()
|
||||
return [{self.name: self.base**v[self.name]} for v in values_list]
|
||||
|
||||
|
||||
|
||||
class UniformIntegerParameterRange(Parameter):
|
||||
"""
|
||||
|
@ -265,7 +265,7 @@ class Session(TokenManager):
|
||||
print("Failed getting vaults: {}".format(ex))
|
||||
|
||||
def _apply_config_sections(self, local_logger):
|
||||
# type: (_LocalLogger) -> None
|
||||
# type: (_LocalLogger) -> None # noqa: F821
|
||||
default = self.config.get("sdk.apply_environment", False)
|
||||
if ENV_ENABLE_ENV_CONFIG_SECTION.get(default=default):
|
||||
try:
|
||||
@ -753,8 +753,8 @@ class Session(TokenManager):
|
||||
)
|
||||
|
||||
class _LocalLogger:
|
||||
def __init__(self, l):
|
||||
self.logger = l
|
||||
def __init__(self, local_logger):
|
||||
self.logger = local_logger
|
||||
|
||||
def __call__(self):
|
||||
if not self.logger:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ....config import config, deferred_config
|
||||
from ....config import deferred_config
|
||||
|
||||
|
||||
class TaskStopReason(object):
|
||||
|
@ -3,7 +3,7 @@ from threading import Thread, Event
|
||||
|
||||
from time import time
|
||||
|
||||
from ....config import config, deferred_config
|
||||
from ....config import deferred_config
|
||||
from ....backend_interface.task.development.stop_signal import TaskStopSignal
|
||||
from ....backend_api.services import tasks
|
||||
|
||||
|
@ -476,7 +476,7 @@ if __name__ == '__main__':
|
||||
if not v or not k.startswith('{input_artifact_section}/'):
|
||||
continue
|
||||
k = k.replace('{input_artifact_section}/', '', 1)
|
||||
task_id, artifact_name = v.split('.', 1)
|
||||
task_id, artifact_name = v.split('.', 1)
|
||||
kwargs[k] = Task.get_task(task_id=task_id).artifacts[artifact_name].get()
|
||||
results = {function_name}(**kwargs)
|
||||
result_names = {function_return}
|
||||
@ -484,7 +484,7 @@ if __name__ == '__main__':
|
||||
if not isinstance(results, (tuple, list)) or (len(result_names) == 1 and len(results) != 1):
|
||||
results = [results]
|
||||
for name, artifact in zip(result_names, results):
|
||||
task.upload_artifact(name=name, artifact_object=artifact)
|
||||
task.upload_artifact(name=name, artifact_object=artifact)
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
|
@ -13,7 +13,7 @@ from threading import Thread, Event
|
||||
|
||||
from .util import get_command_output, remove_user_pass_from_url
|
||||
from ....backend_api import Session
|
||||
from ....config import config, deferred_config
|
||||
from ....config import deferred_config
|
||||
from ....debugging import get_logger
|
||||
from .detectors import GitEnvDetector, GitDetector, HgEnvDetector, HgDetector, Result as DetectionResult
|
||||
|
||||
|
@ -71,7 +71,7 @@ def cli():
|
||||
|
||||
create = subparsers.add_parser('create', help='Create a new dataset')
|
||||
create.add_argument('--parents', type=str, nargs='*',
|
||||
help='[Optional] Specify dataset parents IDs (i.e. merge all parents). '
|
||||
help='[Optional] Specify dataset parents IDs (i.e. merge all parents). '
|
||||
'Example: a17b4fID1 f0ee5ID2 a17b4f09eID3')
|
||||
create.add_argument('--project', type=str, required=False, default=None, help='Dataset project name')
|
||||
create.add_argument('--name', type=str, required=True, default=None, help='Dataset name')
|
||||
@ -100,7 +100,7 @@ def cli():
|
||||
help='Local folder to sync (support for wildcard selection). '
|
||||
'Example: ~/data/*.jpg')
|
||||
sync.add_argument('--parents', type=str, nargs='*',
|
||||
help='[Optional] Specify dataset parents IDs (i.e. merge all parents). '
|
||||
help='[Optional] Specify dataset parents IDs (i.e. merge all parents). '
|
||||
'Example: a17b4fID1 f0ee5ID2 a17b4f09eID3')
|
||||
sync.add_argument('--project', type=str, required=False, default=None,
|
||||
help='[Optional] Dataset project name')
|
||||
|
@ -63,7 +63,8 @@ def deferred_config(key=None, default=Config._MISSING, transform=None, multi=Non
|
||||
next((ConfigSDKWrapper.get(*a) for a in multi if ConfigSDKWrapper.get(*a)), None))
|
||||
if transform is None
|
||||
else (transform() if key is None else transform(ConfigSDKWrapper.get(key, default) if not multi else # noqa
|
||||
next((ConfigSDKWrapper.get(*a) for a in multi if ConfigSDKWrapper.get(*a)), None)))
|
||||
next((ConfigSDKWrapper.get(*a) for a in multi
|
||||
if ConfigSDKWrapper.get(*a)), None)))
|
||||
)
|
||||
|
||||
|
||||
|
@ -1798,7 +1798,7 @@ class Dataset(object):
|
||||
if self._dependency_chunk_lookup is None:
|
||||
self._dependency_chunk_lookup = self._build_dependency_chunk_lookup()
|
||||
return self._dependency_chunk_lookup
|
||||
|
||||
|
||||
def _build_chunk_selection(self, part, num_parts):
|
||||
# type: (int, int) -> Dict[str, int]
|
||||
"""
|
||||
@ -1806,11 +1806,11 @@ class Dataset(object):
|
||||
Notice that for a specific part, one can only get the chunks from parent versions (not including this one)
|
||||
:param part: Current part index (between 0 and num_parts-1)
|
||||
:param num_parts: Total number of parts to divide the dataset into
|
||||
:return: Dict of Dataset ID and their respected chunks used for this part number
|
||||
:return: Dict of Dataset ID and their respected chunks used for this part number
|
||||
"""
|
||||
# get the chunk dependencies
|
||||
dependency_chunk_lookup = self._get_dependency_chunk_lookup()
|
||||
|
||||
|
||||
# first collect the total number of chunks
|
||||
total_chunks = sum(dependency_chunk_lookup.values())
|
||||
|
||||
|
@ -174,9 +174,9 @@ class CacheManager(object):
|
||||
|
||||
# check if someone else holds the lock file
|
||||
locks = lock_files.get(f.name, [])
|
||||
for l in locks:
|
||||
for lck in locks:
|
||||
try:
|
||||
a_lock = FileLock(filename=l)
|
||||
a_lock = FileLock(filename=lck)
|
||||
a_lock.acquire(timeout=0)
|
||||
a_lock.release()
|
||||
a_lock.delete_lock_file()
|
||||
|
@ -50,8 +50,8 @@ from .binding.matplotlib_bind import PatchedMatplotlib
|
||||
from .binding.hydra_bind import PatchHydra
|
||||
from .binding.click_bind import PatchClick
|
||||
from .config import (
|
||||
config, DEV_TASK_NO_REUSE, get_is_master_node, DEBUG_SIMULATE_REMOTE_TASK, PROC_MASTER_ID_ENV_VAR,
|
||||
DEV_DEFAULT_OUTPUT_URI, deferred_config, )
|
||||
config, DEV_TASK_NO_REUSE, get_is_master_node, DEBUG_SIMULATE_REMOTE_TASK, DEV_DEFAULT_OUTPUT_URI,
|
||||
deferred_config, )
|
||||
from .config import running_remotely, get_remote_task_id
|
||||
from .config.cache import SessionCache
|
||||
from .debugging.log import LoggerRoot
|
||||
@ -1889,10 +1889,10 @@ class Task(_Task):
|
||||
Set task's script.
|
||||
|
||||
Examples:
|
||||
task.set_script(repository="https://github.com/allegroai/clearml.git",
|
||||
branch="master",
|
||||
working_dir="examples/reporting",
|
||||
entry_point="artifacts.py")
|
||||
task.set_script(repository='https://github.com/allegroai/clearml.git,
|
||||
branch='master',
|
||||
working_dir='examples/reporting',
|
||||
entry_point='artifacts.py')
|
||||
|
||||
:param repository: URL of remote repository.
|
||||
:param branch: Select specific repository branch / tag.
|
||||
|
@ -40,24 +40,26 @@ class Unparser:
|
||||
self.f.flush()
|
||||
|
||||
def fill(self, text=""):
|
||||
"Indent a piece of text, according to the current indentation level"
|
||||
"""Indent a piece of text, according to the current indentation level"""
|
||||
self.f.write("\n" + " " * self._indent + text)
|
||||
|
||||
def write(self, text):
|
||||
"Append a piece of text to the current line."
|
||||
"""Append a piece of text to the current line."""
|
||||
self.f.write(six.text_type(text))
|
||||
|
||||
def enter(self):
|
||||
"Print ':', and increase the indentation."
|
||||
"""Print ':', and increase the indentation."""
|
||||
self.write(":")
|
||||
self._indent += 1
|
||||
|
||||
def leave(self):
|
||||
"Decrease the indentation level."
|
||||
"""Decrease the indentation level."""
|
||||
self._indent -= 1
|
||||
|
||||
def dispatch(self, tree):
|
||||
"Dispatcher function, dispatching tree type T to method _T."
|
||||
"""
|
||||
Dispatcher function, dispatching tree type T to method _T.
|
||||
"""
|
||||
if isinstance(tree, list):
|
||||
for t in tree:
|
||||
self.dispatch(t)
|
||||
@ -65,12 +67,14 @@ class Unparser:
|
||||
meth = getattr(self, "_" + tree.__class__.__name__)
|
||||
meth(tree)
|
||||
|
||||
"""
|
||||
############### Unparsing methods ######################
|
||||
# There should be one method per concrete grammar type #
|
||||
# Constructors should be grouped by sum type. Ideally, #
|
||||
# this would follow the order in the grammar, but #
|
||||
# currently doesn't. #
|
||||
########################################################
|
||||
"""
|
||||
|
||||
def _Module(self, tree):
|
||||
for stmt in tree.body:
|
||||
|
Loading…
Reference in New Issue
Block a user