Example #1
0
    def setUp(self):
        # Force tasks autodiscover
        from scheduler import tasks  # noqa
        from hpsearch.tasks import bo, grid, health, hyperband, random  # noqa
        from polyflow import health, tasks  # noqa
        from crons import tasks  # noqa
        from events_handlers import tasks  # noqa
        from k8s_events_handlers import tasks  # noqa
        from logs_handlers import tasks  # noqa

        # Flushing all redis databases
        redis.StrictRedis(connection_pool=RedisPools.JOB_CONTAINERS).flushall()
        redis.StrictRedis(connection_pool=RedisPools.TO_STREAM).flushall()
        # Mock dirs
        settings.REPOS_MOUNT_PATH = tempfile.mkdtemp()
        settings.UPLOAD_MOUNT_PATH = tempfile.mkdtemp()
        settings.PERSISTENCE_LOGS['mountPath'] = tempfile.mkdtemp()
        settings.PERSISTENCE_OUTPUTS['outputs'][
            'mountPath'] = tempfile.mkdtemp()
        settings.ARCHIVES_ROOT_REPOS = tempfile.mkdtemp()
        settings.ARCHIVES_ROOT_ARTIFACTS = tempfile.mkdtemp()
        settings.DOWNLOADS_ROOT_ARTIFACTS = tempfile.mkdtemp()
        settings.DOWNLOADS_ROOT_LOGS = tempfile.mkdtemp()
        settings.ARCHIVES_ROOT_LOGS = tempfile.mkdtemp()
        # Flush cache
        cache.clear()
        # Mock celery default sent task
        self.mock_send_task()
        conf.setup()
        ownership.setup()

        if self.DISABLE_RUNNER:
            self.disable_experiment_groups_runner()
            self.disable_experiments_runner()
            self.plugin_jobs_runner()

        super().setUp()

        if not self.DISABLE_EXECUTOR or not self.DISABLE_AUDITOR:
            auditor.validate()
            auditor.setup()
        if not self.DISABLE_AUDITOR:
            tracker.validate()
            tracker.setup()
            activitylogs.validate()
            activitylogs.setup()
            notifier.validate()
            notifier.setup()
        if not self.DISABLE_EXECUTOR:
            executor.validate()
            executor.setup()
Example #2
0
    def setup_auditor_services(self) -> None:
        if not self.is_testing_env:
            import activitylogs
            import auditor
            import executor
            import notifier
            import tracker

            auditor.validate()
            auditor.setup()
            tracker.validate()
            tracker.setup()
            if self._enable_activitylogs:
                activitylogs.validate()
                activitylogs.setup()
            if self._enable_notifier:
                notifier.validate()
                notifier.setup()
            executor.validate()
            executor.setup()