Skip to content

Commit

Permalink
Merge branch 'dev' into fix/ocs_facility_status
Browse files Browse the repository at this point in the history
  • Loading branch information
phycodurus authored Sep 15, 2023
2 parents 678c13e + 96aa38c commit 2ebfc80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 11 additions & 5 deletions tom_observations/facilities/lco.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,17 @@ def layout(self):
)

def get_instruments(self):
"""Filter the instruments from the OCSBaseObservationForm.get_instruments()
(i.e. the super class) in an LCO-specifc way.
"""
instruments = super().get_instruments()
return {
code: instrument for (code, instrument) in instruments.items() if (
'IMAGE' == instrument['type'] and 'MUSCAT' not in code and 'SOAR' not in code)
filtered_instruments = {
code: instrument
for (code, instrument) in instruments.items()
if (instrument['type'] in ['IMAGE', 'SPECTRA'] and
('MUSCAT' not in code and 'SOAR' not in code))
}
return filtered_instruments

def all_optical_element_choices(self, use_code_only=False):
return sorted(set([
Expand All @@ -433,8 +439,8 @@ def _build_instrument_configs(self):
'filter': self.cleaned_data['filter']
}
}

return [instrument_config]
instrument_configs = [instrument_config]
return instrument_configs


class LCOFullObservationForm(OCSFullObservationForm):
Expand Down
4 changes: 3 additions & 1 deletion tom_observations/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_service_classes():
try:
clazz = import_string(service)
except (ImportError, AttributeError):
raise ImportError('Could not import {}. Did you provide the correct path?'.format(service))
raise ImportError(f'Could not import {service}. Did you provide the correct path?')
service_choices[clazz.name] = clazz
return service_choices

Expand Down Expand Up @@ -241,6 +241,8 @@ def validate_observation(self, observation_payload):
"""
Same thing as submit_observation, but a dry run. You can
skip this in different modules by just using "pass"
Typically called by the ObservationForm.is_valid() method.
"""
pass

Expand Down
9 changes: 8 additions & 1 deletion tom_observations/management/commands/runcadencestrategies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import traceback

from django.core.management.base import BaseCommand

Expand Down Expand Up @@ -26,7 +27,13 @@ def handle(self, *args, **kwargs):
for cg in cadenced_groups:
try:
strategy = get_cadence_strategy(cg.cadence_strategy)(cg)
new_observations = strategy.run()
try:
new_observations = strategy.run()
except Exception as e:
logger.error((f'Unable to run cadence_group: {cg}; strategy {strategy};'
f' with id {cg.id} due to error: {e}'))
logger.error(f'{traceback.format_exc()}')
continue
if not new_observations:
logger.log(msg=f'No changes from dynamic cadence {cg}', level=logging.INFO)
else:
Expand Down

0 comments on commit 2ebfc80

Please sign in to comment.