Source code for laborchestrator.start_up.cli
"""
Startup logic for the orchestrator.
"""
import time
import typer
from laborchestrator.gui import SMDashApp
from laborchestrator.orchestrator_implementation import Orchestrator
from laborchestrator.logging_manager import StandardLogger as Logger
from .config_loader import load_config
app = typer.Typer(add_completion=False)
[docs]
@app.command()
def run(
config: str | None = typer.Option(
None,
"-c",
"--config",
help="Path to config.py",
show_default=False,
)
):
config = load_config(config)
orchestrator = Orchestrator(
reader=config.reader,
worker_type=config.worker_type,
)
orchestrator.schedule_manager.time_limit_short = (
config.default_scheduling_time
)
if config.db_client:
orchestrator.inject_db_interface(config.db_client)
if config.device_colors is not None:
orchestrator.jssp.device_colors = config.device_colors
dash_app = SMDashApp(
orchestrator,
port=config.dash_port,
process_module=config.process_module,
arm_open=config.arm_open,
db_open=config.db_open,
browser_open=config.browser_open,
)
dash_app.run()
if config.lab_config_file:
orchestrator.schedule_manager.lab_config_file = config.lab_config_file
try:
from labscheduler.sila_server import Client as SchedulerClient
scheduler = SchedulerClient.discover(insecure=True, timeout=5)
#with open(config.lab_config_file, "r") as reader:
# content = reader.read()
#scheduler.LabConfigurationController.LoadJobShopFromFile(
# content
#)
if config.scheduling_algorithm:
scheduler.SchedulingService.SelectAlgorithm(
config.scheduling_algorithm
)
Logger.info("Configured scheduler")
except Exception as e:
Logger.warning(f"Scheduler configuration failed: {e}")
while True:
time.sleep(1)
[docs]
def main():
typer.run(run)