diff --git a/src/environment_provider/__init__.py b/src/environment_provider/__init__.py index 5526fee..e714bdd 100644 --- a/src/environment_provider/__init__.py +++ b/src/environment_provider/__init__.py @@ -27,7 +27,9 @@ DEV = os.getenv("DEV", "false").lower() == "true" ENVIRONMENT = "development" if DEV else "production" -setup_logging("ETOS Environment Provider Worker", VERSION, ENVIRONMENT) +# Disable extra logging, if the environment provider is imported instead of executed via celery +if os.getenv("ENVIRONMENT_PROVIDER_DISABLE_LOGGING", "false") == "false": + setup_logging("ETOS Environment Provider Worker", VERSION, ENVIRONMENT) # JSONTas would print all passwords as they are encrypted, # which is not safe, so we disable propagation on the loggers. # Propagation needs to be set to 0 instead of disabling the diff --git a/src/environment_provider/environment_provider.py b/src/environment_provider/environment_provider.py index ba63e9c..8a13677 100644 --- a/src/environment_provider/environment_provider.py +++ b/src/environment_provider/environment_provider.py @@ -69,11 +69,12 @@ class EnvironmentProvider: # pylint:disable=too-many-instance-attributes task_track_started = True # Make celery task report 'STARTED' state lock = Lock() - def __init__(self, suite_id: str, suite_runner_ids: list[str]) -> None: + def __init__(self, suite_id: str, suite_runner_ids: list[str], copy: bool = True) -> None: """Initialize ETOS, dataset, provider registry and splitter. :param suite_id: Suite ID to get an environment for :param suite_runner_ids: IDs from the suite runner to correlate sub suites. + :param copy: Whether or not to copy the etos config. Set to False if not running celery. """ FORMAT_CONFIG.identifier = suite_id self.logger.info("Initializing EnvironmentProvider task.") @@ -89,7 +90,8 @@ def __init__(self, suite_id: str, suite_runner_ids: list[str]) -> None: # configuration dictionary. # The impact of not doing this is that the environment provider would re-use # another workers configuration instead of using its own. - self.etos.config.config = deepcopy(self.etos.config.config) + if copy: + self.etos.config.config = deepcopy(self.etos.config.config) self.reset() self.splitter = Splitter(self.etos, {}) diff --git a/src/environment_provider_api/__init__.py b/src/environment_provider_api/__init__.py index 3757f09..810b34e 100644 --- a/src/environment_provider_api/__init__.py +++ b/src/environment_provider_api/__init__.py @@ -26,4 +26,6 @@ DEV = os.getenv("DEV", "false").lower() == "true" ENVIRONMENT = "development" if DEV else "production" -setup_logging("ETOS Environment Provider API", VERSION, ENVIRONMENT) +# Disable extra logging, if the environment provider is imported instead of executed via celery +if os.getenv("ENVIRONMENT_PROVIDER_DISABLE_LOGGING", "false") == "false": + setup_logging("ETOS Environment Provider API", VERSION, ENVIRONMENT)