Resource
The GPP Resource services allows other services in the GPP environment to know what is available in the telescope at a giving night, from gratings to the status of the status of an instrument.
This service act like a client for the real Resource and the emulated version for OCS,
that is based in several text files compiled from old OCS systems.
The original files can be checked at /scheduler/services/resource/srcand the ones
actually used in the Scheduler are in the same path at validation.
Resource structures
scheduler.services.resource.ResourceService(sites=ALL_SITES, subdir='')
Bases: ExternalService
This is to avoid recreating repetitive resources. When we first get a resource ID string, create a Resource for it and store it here. Then fetch the Resources from here if they exist, and if they do not, then create a new one as per the lookup_resource method.
lookup_resource(resource_id, description=None, resource_type=ResourceType.NONE)
This is a helper method that just delegates to the ResourceManager cache. It is designed to minimize code changes and make the ResourceService use the cache transparently.
date_range_for_site(site)
Return the date range (inclusive) for which we have resource data for a site.
get_night_configuration(site, local_date)
Returns the NightConfiguration object for the site for the given local date, which contains the filters and resources for the night.
fpu_to_barcode(site, fpu_name, instrument)
Convert a long FPU name into the barcode, if it exists.
scheduler.services.resource.FileBasedResourceService(sites=ALL_SITES, subdir='')
Bases: ResourceService
This is the base for both OCS and File-uploaded services
lookup_resource(resource_id, description=None, resource_type=ResourceType.NONE)
This is a helper method that just delegates to the ResourceManager cache. It is designed to minimize code changes and make the ResourceService use the cache transparently.
date_range_for_site(site)
Return the date range (inclusive) for which we have resource data for a site.
get_night_configuration(site, local_date)
Returns the NightConfiguration object for the site for the given local date, which contains the filters and resources for the night.
fpu_to_barcode(site, fpu_name, instrument)
Convert a long FPU name into the barcode, if it exists.
load_files(site, fpu_to_barcodes_file, fpus_data, gratings_data, faults_data, eng_tasks_data, weather_closure_data, filters_data, too_data, spreadsheet_file)
Load all files necessaries to the correct functioning of the ResourceManager.
scheduler.services.resource.OcsResourceService(sites=ALL_SITES, subdir='validation')
Bases: FileBasedResourceService
This is a mock for the future Resource service, used for OCS. It reads data regarding availability of instruments, IFUs, FPUs, MOS masks, etc. at each Site for given dates.
It can then be queried to receive a set of Resource (usually with barcode IDs, except for instruments) for a given site on a given night.
It caches and reuses Resources by ID as best as possible to minimize the number of Resource objects existing at any given time. Since Resource is immutable, this should be fine.
Note that this is a Singleton class, so new instances do not need to be created.
Create and initialize the OCS Resource object with the specified sites.
lookup_resource(resource_id, description=None, resource_type=ResourceType.NONE)
This is a helper method that just delegates to the ResourceManager cache. It is designed to minimize code changes and make the ResourceService use the cache transparently.
date_range_for_site(site)
Return the date range (inclusive) for which we have resource data for a site.
get_night_configuration(site, local_date)
Returns the NightConfiguration object for the site for the given local date, which contains the filters and resources for the night.
fpu_to_barcode(site, fpu_name, instrument)
Convert a long FPU name into the barcode, if it exists.
load_files(site, fpu_to_barcodes_file, fpus_data, gratings_data, faults_data, eng_tasks_data, weather_closure_data, filters_data, too_data, spreadsheet_file)
Load all files necessaries to the correct functioning of the ResourceManager.
scheduler.services.resource.resource_manager.ResourceManager()
A singleton class that manages Resource instances to reuse them as per the flyweight design pattern.
Create an empty dictionary of mappings from name to Resource.
lookup_resource(resource_id, description=None, resource_type=ResourceType.NONE)
Function to perform Resource caching and minimize the number of Resource objects by attempting to reuse Resource objects with the same ID.
If resource_id evaluates to False, return None. Otherwise, check if a Resource with id already exists. If it does, return it. If not, create it, add it to the map of all Resources, and then return it.
Note that even if multiple objects do exist with the same ID, they will be considered equal by the Resource equality comparator.
scheduler.services.resource.NightConfiguration(site, local_date, is_lgs, too_status, filter, resources, eng_tasks)
__post_init__()
Calculate values once to avoid recalculation.