diff --git a/tom_observations/facilities/lco.py b/tom_observations/facilities/lco.py index df516cffa..93c429661 100644 --- a/tom_observations/facilities/lco.py +++ b/tom_observations/facilities/lco.py @@ -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([ @@ -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): diff --git a/tom_observations/facility.py b/tom_observations/facility.py index f6e804e88..93d2d044e 100644 --- a/tom_observations/facility.py +++ b/tom_observations/facility.py @@ -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 @@ -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 diff --git a/tom_observations/management/commands/runcadencestrategies.py b/tom_observations/management/commands/runcadencestrategies.py index 32e575daa..73adbbec8 100644 --- a/tom_observations/management/commands/runcadencestrategies.py +++ b/tom_observations/management/commands/runcadencestrategies.py @@ -1,4 +1,5 @@ import logging +import traceback from django.core.management.base import BaseCommand @@ -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: