From 888c53f67d0feb45b81666c10f6d1bcac82749e8 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 5 Mar 2020 12:19:40 +0200 Subject: [PATCH] Allow disabling repository detection when calling Task.init() --- trains/backend_interface/logger.py | 2 +- trains/task.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/trains/backend_interface/logger.py b/trains/backend_interface/logger.py index 391921ae..bce167f1 100644 --- a/trains/backend_interface/logger.py +++ b/trains/backend_interface/logger.py @@ -46,7 +46,7 @@ class StdStreamPatch(object): pass # now check if we have loguru and make it re-register the handlers - # because it sores internally the stream.write function, which we cant patch + # because it stores internally the stream.write function, which we cant patch # noinspection PyBroadException try: from loguru import logger diff --git a/trains/task.py b/trains/task.py index e5705cd4..962fa435 100644 --- a/trains/task.py +++ b/trains/task.py @@ -170,7 +170,7 @@ class Task(_Task): Fine grained control is possible by passing a dictionary instead of a Boolean. Missing keys are considered to have True value, empty dictionary is considered as False, full example: auto_connect_frameworks={'matplotlib': True, 'tensorflow': True, 'pytorch': True, - 'xgboost': True, 'scikit': True} + 'xgboost': True, 'scikit': True, 'detect_repository': True} :param auto_resource_monitoring: If true, machine vitals will be sent along side the task scalars, Resources graphs will appear under the title ':resource monitor:' in the scalars tab. :return: Task() object @@ -956,7 +956,8 @@ class Task(_Task): task._dev_worker = None @classmethod - def _create_dev_task(cls, default_project_name, default_task_name, default_task_type, reuse_last_task_id): + def _create_dev_task(cls, default_project_name, default_task_name, default_task_type, reuse_last_task_id, + detect_repo=True): if not default_project_name or not default_task_name: # get project name and task name from repository name and entry_point result, _ = ScriptInfo.get(create_requirements=False, check_uncommitted=False) @@ -1066,12 +1067,13 @@ class Task(_Task): logger.report_text('TRAINS Task: created new task id=%s' % task.id) # update current repository and put warning into logs - if in_dev_mode and cls.__detect_repo_async: - task._detect_repo_async_thread = threading.Thread(target=task._update_repository) - task._detect_repo_async_thread.daemon = True - task._detect_repo_async_thread.start() - else: - task._update_repository() + if detect_repo: + if in_dev_mode and cls.__detect_repo_async: + task._detect_repo_async_thread = threading.Thread(target=task._update_repository) + task._detect_repo_async_thread.daemon = True + task._detect_repo_async_thread.start() + else: + task._update_repository() # make sure everything is in sync task.reload()