Driver¶
- class lsst.ts.scheduler.driver.Driver(models: Dict[str, Any], raw_telemetry: Dict[str, Any], parameters: DriverParameters | None = None, log: Logger | None = None)¶
Bases:
object
The Scheduler Driver is the module that normalizes the interface between any scheduling algorithm to the LSST Scheduler CSC. The interface implements three main behaviours; configure an underlying algorithm, request targets and register successful observations.
If the Scheduler algorithm requires a specific set of parameters the user must subclass
DriverParameters
, in the same module as theDriver
, and add the appropriate parameters using the LSST pexConfig module.Access to the telemetry stream and models are also interfaced by
Driver
. The full list of default available telemetry data is shown in the scheduler_csc module. Nevertheless, the full list of telemetry may vary depending on the models used. The user has control over this while configuring the Scheduler CSC.- Parameters:
- models: `dict`
A dictionary with models available for the scheduling algorithm.
- raw_telemetry: `dict`
A dictionary with available raw telemetry.
- parameters: `DriverParameters`, optional
Input functional parameters for the scheduling algorithm.
- log: `Logger`
Parent logger class.
- Attributes:
- log: `Logger`
Logger class.
- parameters: `DriverParameters`
Store functional driver parameters.
- models: `dict`
Dictionary with models.
- raw_telemetry: `dict`
Dictionary with raw telemetry data.
- target_id: `int`
Counter of the number of targets generated by the scheduler since it was last instantiated.
- default_observing_script_name: `str`
Name of the default SAL Script. This will be used if no overriding script is provided by the
DriverTarget
class.- default_observing_script_is_standard: `bool`
Specify if the default observing script is standard.
- stop_tracking_script_name: `str`
Name of a SAL Script that can be used to stop the observatory. This is, in general, queued by the Driver when it fails to select an obsevation.
- stop_tracking_script_is_standard: `bool`
Specify if the stop tracking script is standard.
- is_night: `bool`
Track if it is night time.
- night: `int`
Count the number of nights from the start of the survey.
- current_sunset: `float`
Timestamp for the current sunset.
- current_sunrise: `float`
Timestamp for the current sunrise.
Methods Summary
assert_survey_observing_script
(survey_name)Assert that the input survey name has a dedicated observing script.
cold_start
(observations)Rebuilds the internal state of the scheduler from a list of observations.
configure_scheduler
(config)This method is responsible for running the scheduler configuration and returning the survey topology, which specifies the number, name and type of projects running by the scheduler.
Configure survey-based observing script.
Convert EFD dataframe into list of driver targets.
Get the current state of the scheduling algorithm as a file object.
get_survey_observing_script
(survey_name)Return the appropriate survey observing script.
get_survey_topology
(config)Get the survey topology.
load
(config)Load a modifying configuration.
parse_observation_database
(filename)Parse an observation database into a list of observations.
register_observation
(target)Register observations.
register_observed_target
(target)Validates observed target and returns an observation.
reset_from_state
(filename)Load the state from a file.
Save the current state of the scheduling algorithm to a file.
Picks a target and returns it as a target object.
Select a list of targets.
Update driver internal conditions.
Methods Documentation
- assert_survey_observing_script(survey_name: str) None ¶
Assert that the input survey name has a dedicated observing script.
- Parameters:
- survey_name
str
Name of the survey.
- survey_name
- Raises:
- AssertError:
If
survey_name
is not in the list of valid survey observing scripts.
- cold_start(observations: List[Observation]) None ¶
Rebuilds the internal state of the scheduler from a list of observations.
- Parameters:
- observationslist of Observation objects
- configure_scheduler(config: SimpleNamespace) SurveyTopology ¶
This method is responsible for running the scheduler configuration and returning the survey topology, which specifies the number, name and type of projects running by the scheduler.
By default it will just return a test survey topology.
- Parameters:
- config
types.SimpleNamespace
Configuration, as described by
schema/Scheduler.yaml
- config
- Returns:
- survey_topology
SurveyTopology
Survey topology.
- survey_topology
- configure_survey_observing_script(survey_observing_script: Dict[str, Any]) None ¶
Configure survey-based observing script.
- Parameters:
- survey_observing_script
dict
Dictionary with survey name as key and a dictionary with observing_script_name (string) and observing_script_is_standard (boolean) values.
- survey_observing_script
See also
get_survey_observing_script
Returns survey-specific observing script.
- convert_efd_observations_to_targets(efd_observations: DataFrame) List[DriverTarget] ¶
Convert EFD dataframe into list of driver targets.
- Parameters:
- efd_observations
pandas.DataFrame
Data frame returned from a query to the EFD for observations.
- efd_observations
- get_state_as_file_object() BytesIO ¶
Get the current state of the scheduling algorithm as a file object.
- Returns:
- file_object
io.BytesIO
File object with the current.
- file_object
- get_stop_tracking_target() DriverTarget ¶
- get_survey_observing_script(survey_name: str) Tuple[str, bool] ¶
Return the appropriate survey observing script.
If the script contains a especial script, return it, if not, return defaults.
- Parameters:
- survey_name
str
Name of the survey.
- survey_name
- Returns:
See also
configure_survey_observing_script
Configure survey specific observing script.
- get_survey_topology(config: SimpleNamespace) SurveyTopology ¶
Get the survey topology.
- Parameters:
- config
types.SimpleNamespace
Configuration, as described by
schema/Scheduler.yaml
- config
- Returns:
- survey_topology
SurveyTopology
Survey topology.
- survey_topology
- load(config: str) None ¶
Load a modifying configuration.
The input is a file that the Driver must be able to parse. It should contain that the driver can parse to reconfigure the current scheduler algorithm. For instance, it could contain new targets to add to a queue or project.
Each Driver must implement its own load method. This method just checks that the file exists.
- Parameters:
- config
str
Configuration to load
- config
- Raises:
- RuntimeError:
If input configuration file does not exists.
- parse_observation_database(filename: str) None ¶
Parse an observation database into a list of observations.
- register_observation(target: DriverTarget) None ¶
Register observations.
This method should store the observation in a way that can be retrieved afterwards by the driver.
The default implementation is not implemented.
- Parameters:
- target
DriverTarget
Observation to register.
- target
- register_observed_target(target: DriverTarget) Observation ¶
Validates observed target and returns an observation.
- Parameters:
- target
DriverTarget
Observed target to register.
- target
- Returns:
Observation
Registered observation.
- save_state() None ¶
Save the current state of the scheduling algorithm to a file.
- Returns:
- filename:
str
The name of the file with the state.
- filename:
- select_next_target() DriverTarget ¶
Picks a target and returns it as a target object.
By default it will just return a dummy test target.
- Returns:
DriverTarget