Skip to content

Commit

Permalink
Fix enabled instruments configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jan 15, 2025
1 parent eafe327 commit d82bb5a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/hal/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from clu.tools import cli_coro
from sdsstools.daemonizer import DaemonGroup

from hal import __version__
from hal import __version__, config
from hal.actor import HALActor


Expand Down Expand Up @@ -67,10 +67,11 @@ def hal(
async def actor(ctx: click.Context):
"""Runs the actor."""

default_config_file = os.path.join(os.path.dirname(__file__), "etc/hal.yml")
config_file: str = ctx.obj["config_file"] or default_config_file

hal_obj = HALActor.from_config(config_file)
if ctx.obj["config_file"] is not None:
config_file: str = ctx.obj["config_file"]
hal_obj = HALActor.from_config(config_file)
else:
hal_obj = HALActor.from_config(config)

if ctx.obj["verbose"]:
hal_obj.log.sh.setLevel(0)
Expand Down
2 changes: 1 addition & 1 deletion src/hal/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, *args, **kwargs):

HALActor._instance = self

instruments = self.helpers.macros["expose"].config["enabled_instruments"]
instruments = self.config["enabled_instruments"]
self.log.info(f"Enabled instruments: {instruments!r}")

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion src/hal/actor/commands/expose.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ async def expose(

selected_stages = cast(list[StageType], stages or flatten(macro.__STAGES__.copy()))

enabled_instuments = macro.config["enabled_instruments"]
enabled_instuments = config["enabled_instruments"]
apogee = apogee and "apogee" in enabled_instuments
boss = boss and "boss" in enabled_instuments

Expand Down
3 changes: 2 additions & 1 deletion src/hal/etc/hal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ lamp_warmup:
HgCd: 108
Ne: 20

enabled_instruments: ['apogee', 'boss']

macros:
goto_field:
fvc:
Expand Down Expand Up @@ -148,7 +150,6 @@ macros:
- guide

expose:
enabled_instruments: ['apogee', 'boss']
boss_exptime: null
apogee_exptime: null
count_apogee: null
Expand Down
13 changes: 7 additions & 6 deletions src/hal/macros/goto_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ async def prepare(self):
await self.helpers.cherno.stop_guiding(self.command)

# Ensure the APOGEE shutter is closed but don't wait for it.
asyncio.create_task(
self.helpers.apogee.shutter(
self.command,
open=False,
shutter="apogee",
if "apogee" in self.actor.config["enabled_instruments"]:
asyncio.create_task(
self.helpers.apogee.shutter(
self.command,
open=False,
shutter="apogee",
)
)
)

# Reset cherno offsets.
self.command.debug("Resetting cherno offsets.")
Expand Down

0 comments on commit d82bb5a

Please sign in to comment.