Fix documentation and layout (PEP8)

This commit is contained in:
allegroai
2020-05-24 08:16:12 +03:00
parent 70cdb13252
commit 96f899d028
43 changed files with 580 additions and 322 deletions

View File

@@ -16,6 +16,7 @@ class _Arguments(object):
class _ProxyDictWrite(dict):
""" Dictionary wrapper that updates an arguments instance on any item set in the dictionary """
def __init__(self, arguments, *args, **kwargs):
super(_Arguments._ProxyDictWrite, self).__init__(*args, **kwargs)
self._arguments = arguments
@@ -27,6 +28,7 @@ class _Arguments(object):
class _ProxyDictReadOnly(dict):
""" Dictionary wrapper that prevents modifications to the dictionary """
def __init__(self, arguments, *args, **kwargs):
super(_Arguments._ProxyDictReadOnly, self).__init__(*args, **kwargs)
self._arguments = arguments

View File

@@ -16,7 +16,7 @@ buffer_capacity = config.get('log.task_log_buffer_capacity', 100)
class TaskHandler(BufferingHandler):
__flush_max_history_seconds = 30.
__wait_for_flush_timeout = 10.
__max_event_size = 1024*1024
__max_event_size = 1024 * 1024
__once = False
@property

View File

@@ -24,7 +24,7 @@ class ScriptInfoError(Exception):
class ScriptRequirements(object):
_max_requirements_size = 512*1024
_max_requirements_size = 512 * 1024
def __init__(self, root_folder):
self._root_folder = root_folder
@@ -365,7 +365,7 @@ class ScriptInfo(object):
@classmethod
def _get_jupyter_notebook_filename(cls):
if not (sys.argv[0].endswith(os.path.sep+'ipykernel_launcher.py') or
if not (sys.argv[0].endswith(os.path.sep + 'ipykernel_launcher.py') or
sys.argv[0].endswith(os.path.join(os.path.sep, 'ipykernel', '__main__.py'))) \
or len(sys.argv) < 3 or not sys.argv[2].endswith('.json'):
return None

View File

@@ -119,7 +119,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
self._curr_label_stats = {}
self._raise_on_validation_errors = raise_on_validation_errors
self._parameters_allowed_types = (
six.string_types + six.integer_types + (six.text_type, float, list, tuple, dict, type(None))
six.string_types + six.integer_types + (six.text_type, float, list, tuple, dict, type(None))
)
self._app_server = None
self._files_server = None
@@ -683,7 +683,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
"Only builtin types ({}) are allowed for values (got {})".format(
', '.join(t.__name__ for t in self._parameters_allowed_types),
', '.join('%s=>%s' % p for p in not_allowed.items())),
)
)
# force cast all variables to strings (so that we can later edit them in UI)
parameters = {k: str(v) if v is not None else "" for k, v in parameters.items()}
@@ -1300,5 +1300,5 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
def __is_subprocess(cls):
# notice this class function is called from Task.ExitHooks, do not rename/move it.
is_subprocess = PROC_MASTER_ID_ENV_VAR.get() and \
PROC_MASTER_ID_ENV_VAR.get().split(':')[0] != str(os.getpid())
PROC_MASTER_ID_ENV_VAR.get().split(':')[0] != str(os.getpid())
return is_subprocess