Skip to content

Commit

Permalink
Refactor and clean up parts of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
aangelos28 committed Oct 2, 2024
1 parent ae88661 commit b07f6d1
Show file tree
Hide file tree
Showing 29 changed files with 508 additions and 539 deletions.
6 changes: 3 additions & 3 deletions eos/campaigns/campaign_optimizer_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ray.actor import ActorHandle

from eos.campaigns.entities.campaign import CampaignSample
from eos.configuration.plugin_registries.campaign_optimizer_plugin_registry import CampaignOptimizerPluginRegistry
from eos.configuration.configuration_manager import ConfigurationManager
from eos.logging.logger import log
from eos.optimization.sequential_optimizer_actor import SequentialOptimizerActor
from eos.persistence.db_manager import DbManager
Expand All @@ -15,11 +15,11 @@ class CampaignOptimizerManager:
Responsible for managing the optimizers associated with experiment campaigns.
"""

def __init__(self, db_manager: DbManager):
def __init__(self, configuration_manager: ConfigurationManager, db_manager: DbManager):
self._campaign_samples = MongoRepository("campaign_samples", db_manager)
self._campaign_samples.create_indices([("campaign_id", 1), ("experiment_id", 1)], unique=True)

self._campaign_optimizer_plugin_registry = CampaignOptimizerPluginRegistry()
self._campaign_optimizer_plugin_registry = configuration_manager.campaign_optimizers

self._optimizer_actors: dict[str, ActorHandle] = {}

Expand Down
3 changes: 2 additions & 1 deletion eos/cli/orchestrator_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def signal_handler(*_) -> None:
log.info("Shutting down the orchestrator...")
orchestrator.terminate()

log.info("Shutdown complete.")
log.info("EOS shut down.")


async def run_all(orchestrator: Orchestrator, web_api_server: uvicorn.Server) -> None:
Expand Down Expand Up @@ -155,6 +155,7 @@ def start_orchestrator(
orchestrator = Orchestrator(config.user_dir, db_credentials, file_db_credentials)
orchestrator.load_labs(config.labs)
orchestrator.load_experiments(config.experiments)
log.info("EOS initialized.")

# Set up the web API server
logging_config = LoggingConfig(
Expand Down
7 changes: 4 additions & 3 deletions eos/configuration/configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from eos.configuration.exceptions import (
EosConfigurationError,
)
from eos.configuration.package_manager import PackageManager
from eos.configuration.packages.entities import EntityType
from eos.configuration.packages.package_manager import PackageManager
from eos.configuration.plugin_registries.campaign_optimizer_plugin_registry import CampaignOptimizerPluginRegistry
from eos.configuration.plugin_registries.device_plugin_registry import DevicePluginRegistry
from eos.configuration.plugin_registries.task_plugin_registry import TaskPluginRegistry
Expand Down Expand Up @@ -55,7 +56,7 @@ def get_lab_loaded_statuses(self) -> dict[str, bool]:
all_labs = set()

for package in self._package_manager.get_all_packages():
package_labs = self._package_manager.get_labs_in_package(package.name)
package_labs = self._package_manager.get_entities_in_package(package.name, EntityType.LAB)
all_labs.update(package_labs)

return {lab: lab in self.labs for lab in all_labs}
Expand Down Expand Up @@ -128,7 +129,7 @@ def get_experiment_loaded_statuses(self) -> dict[str, bool]:
all_experiments = set()

for package in self._package_manager.get_all_packages():
package_experiments = self._package_manager.get_experiments_in_package(package.name)
package_experiments = self._package_manager.get_entities_in_package(package.name, EntityType.EXPERIMENT)
all_experiments.update(package_experiments)

return {exp: exp in self.experiments for exp in all_experiments}
Expand Down
3 changes: 1 addition & 2 deletions eos/configuration/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
LABS_DIR = "labs"
EXPERIMENTS_DIR = "experiments"
TASKS_DIR = "tasks"
DEVICES_DIR = "devices"
COMMON_DIR = "common"
TASKS_DIR = "tasks"

EXPERIMENT_CONFIG_FILE_NAME = "experiment.yml"
LAB_CONFIG_FILE_NAME = "lab.yml"
Expand Down
13 changes: 12 additions & 1 deletion eos/configuration/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from eos.devices.exceptions import EosDeviceError


class EosConfigurationError(Exception):
pass

Expand Down Expand Up @@ -30,9 +33,17 @@ class EosTaskGraphError(Exception):
pass


class EosTaskHandlerClassNotFoundError(Exception):
class EosTaskImplementationClassNotFoundError(Exception):
pass


class EosCampaignOptimizerImplementationClassNotFoundError(Exception):
pass


class EosCampaignOptimizerNotFoundError(Exception):
pass


class EosDeviceImplementationClassNotFoundError(EosDeviceError):
pass
18 changes: 0 additions & 18 deletions eos/configuration/package.py

This file was deleted.

Loading

0 comments on commit b07f6d1

Please sign in to comment.