diff --git a/aiopslab/config.yml.example b/aiopslab/config.yml.example index 3da81468..98df84c1 100644 --- a/aiopslab/config.yml.example +++ b/aiopslab/config.yml.example @@ -13,3 +13,8 @@ qualitative_eval: false # Flag to enable/disable printing the session print_session: false + +# Batch mode settings +batch_mode: false # Optimizes for running multiple problems sequentially: +# - Caches Docker images locally to avoid re-pulling +# - Keeps infrastructure (OpenEBS, Prometheus) running between problems diff --git a/aiopslab/orchestrator/orchestrator.py b/aiopslab/orchestrator/orchestrator.py index cdf109f1..5c54e1c1 100644 --- a/aiopslab/orchestrator/orchestrator.py +++ b/aiopslab/orchestrator/orchestrator.py @@ -3,7 +3,6 @@ """Orchestrator class that interfaces with the agent and the environment.""" -from aiopslab.service.helm import Helm from aiopslab.service.kubectl import KubeCtl from aiopslab.session import Session from aiopslab.orchestrator.problems.registry import ProblemRegistry @@ -11,6 +10,7 @@ from aiopslab.utils.status import * from aiopslab.utils.critical_section import CriticalSection from aiopslab.service.telemetry.prometheus import Prometheus +from aiopslab.paths import config import time import inspect import asyncio @@ -203,7 +203,8 @@ async def start_problem(self, max_steps: int): # if not self.session.problem.sys_status_after_recovery(): self.session.problem.app.cleanup() - if self.session.problem.namespace != "docker": + # In batch mode, keep infrastructure running between problems + if self.session.problem.namespace != "docker" and not config.get("batch_mode", False): self.prometheus.teardown() print("Uninstalling OpenEBS...") self.kubectl.exec_command("kubectl delete sc openebs-hostpath openebs-device --ignore-not-found") diff --git a/aiopslab/service/apps/flight_ticket.py b/aiopslab/service/apps/flight_ticket.py index 62e06839..3392ad29 100644 --- a/aiopslab/service/apps/flight_ticket.py +++ b/aiopslab/service/apps/flight_ticket.py @@ -4,7 +4,6 @@ from aiopslab.service.helm import Helm from aiopslab.service.kubectl import KubeCtl from aiopslab.service.apps.base import Application -from aiopslab.paths import TARGET_MICROSERVICES from aiopslab.paths import FLIGHT_TICKET_METADATA diff --git a/aiopslab/service/apps/train_ticket.py b/aiopslab/service/apps/train_ticket.py index efc1fcb3..d1247799 100644 --- a/aiopslab/service/apps/train_ticket.py +++ b/aiopslab/service/apps/train_ticket.py @@ -4,7 +4,6 @@ from aiopslab.service.helm import Helm from aiopslab.service.kubectl import KubeCtl from aiopslab.service.apps.base import Application -from aiopslab.paths import TARGET_MICROSERVICES from aiopslab.paths import TRAIN_TICKET_METADATA diff --git a/aiopslab/service/helm.py b/aiopslab/service/helm.py index 2cc2c8f6..5574e17b 100644 --- a/aiopslab/service/helm.py +++ b/aiopslab/service/helm.py @@ -4,9 +4,9 @@ """Interface for helm operations""" import subprocess -import time from aiopslab.service.kubectl import KubeCtl +from aiopslab.paths import config class Helm: @@ -27,8 +27,13 @@ def install(**args): chart_path = args.get("chart_path") namespace = args.get("namespace") version = args.get("version") - extra_args = args.get("extra_args") + extra_args = args.get("extra_args", []) remote_chart = args.get("remote_chart", False) + + # Apply batch mode if enabled + if config.get("batch_mode", False): + extra_args = extra_args or [] + extra_args.append("--set global.imagePullPolicy=IfNotPresent") if not remote_chart: # Install dependencies for chart before installation diff --git a/aiopslab/service/telemetry/prometheus.py b/aiopslab/service/telemetry/prometheus.py index 721e659a..d8955116 100644 --- a/aiopslab/service/telemetry/prometheus.py +++ b/aiopslab/service/telemetry/prometheus.py @@ -4,7 +4,6 @@ import os import json import yaml -import time from subprocess import CalledProcessError from aiopslab.service.helm import Helm from aiopslab.service.kubectl import KubeCtl