Skip to content

Commit

Permalink
Merge pull request #496 from gemini-hlsw/GSCHED-611
Browse files Browse the repository at this point in the history
Added fpu, disperser and filters to Visit and schema
  • Loading branch information
dngomez authored Aug 21, 2024
2 parents f91777c + af08210 commit 6f30dc2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions scheduler/core/plans/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def add(self,
score,
peak_score,
obs.instrument(),
obs.fpu(),
obs.disperser(),
obs.filters(),
f'{atom_end+1}/{len(obs.sequence)}')
self.visits.append(visit)
self._time_slots_left -= time_slots
Expand Down
5 changes: 4 additions & 1 deletion scheduler/core/plans/visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dataclasses import dataclass
from datetime import datetime
from typing import final, Optional
from typing import final, Optional, FrozenSet

from lucupy.minimodel import ObservationID, Resource, ObservationClass, Conditions

Expand All @@ -26,4 +26,7 @@ class Visit:
score: float
peak_score: float
instrument: Optional[Resource]
fpu: Optional[Resource]
disperser: Optional[Resource]
filters: Optional[FrozenSet[Resource]]
completion: str
6 changes: 4 additions & 2 deletions scheduler/core/programprovider/ocs/ocsprogramprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,11 @@ def autocorr_lag(x):
# sets, but we filter below to remove them.
fpu_resources = frozenset([self._sources.origin.resource.fpu_to_barcode(site, fpu, instrument)
for fpu in fpus])
disperser_resources = frozenset([self._sources.origin.resource.lookup_resource(disperser.split('_')[0])
disperser_resources = frozenset([self._sources.origin.resource.lookup_resource(disperser.split('_')[0], resource_type=ResourceType.DISPERSER)
for disperser in dispersers])
resources = frozenset([r for r in fpu_resources | disperser_resources | instrument_resources])
# Adding filters to resources
filter_resources = frozenset([self._sources.origin.resource.lookup_resource(filt, resource_type=ResourceType.FILTER) for filt in filters])
resources = frozenset([r for r in fpu_resources | disperser_resources | instrument_resources | filter_resources])
else:
resources = instrument_resources

Expand Down
6 changes: 6 additions & 0 deletions scheduler/graphql_mid/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class SVisit:
atom_end_idx: int
altitude: List[float]
instrument: str
fpu: str
disperser: str
filters: List[str]
required_conditions: SConditions
obs_class: str
score: float
Expand All @@ -80,6 +83,9 @@ def from_computed_visit(visit: Visit, alt_degs: List[float]) -> 'SVisit':
atom_end_idx=visit.atom_end_idx,
altitude=alt_degs,
instrument=visit.instrument.id if visit.instrument is not None else 'None',
fpu=visit.fpu.id if visit.fpu is not None else 'None',
disperser=visit.disperser.id if visit.disperser is not None else 'None',
filters=[f.id for f in visit.filters] if visit.filters is not None else [],
required_conditions=SConditions.from_computed_conditions(visit.obs_conditions),
score=visit.score,
peak_score=visit.peak_score,
Expand Down

0 comments on commit 6f30dc2

Please sign in to comment.