Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ local shape = {
f3548: {
create_subscription: {
subscription: {
subscription_id: '16b87239-6063-47d4-a2ff-%d05086859f32' % (sub_index - 1),
subscription_id: '3bdb0b88-a522-4286-9499-%d60e56c953bb' % (sub_index - 1),
duration: '23h',
area: {
lat_min: 34 - 0.00001,
Expand All @@ -99,7 +99,7 @@ local shape = {
name: 'Delete subscription %d' % sub_index,
f3548: {
delete_subscription: {
subscription_id: '16b87239-6063-47d4-a2ff-%d05086859f32' % (sub_index - 1),
subscription_id: '3bdb0b88-a522-4286-9499-%d60e56c953bb' % (sub_index - 1),
mode: 'GetDeleteIfExist',
},
},
Expand Down Expand Up @@ -132,16 +132,7 @@ local shape = {
dss_selection_strategy: 'Random',
subscription_strategy: {
single_subscription: {
subscription_id: '3bdb0b88-a522-4286-9499-160e56c953bb',
duration: '23h',
area: {
lat_min: 34 - 0.00001,
lng_min: -118 - 0.00001,
lat_max: 34 + 0.00001,
lng_max: -118 + 0.00001,
},
min_alt: {value: 0, units: 'M', reference: 'W84'},
max_alt: {value: 3000, units: 'M', reference: 'W84'},
subscription_id: '3bdb0b88-a522-4286-9499-060e56c953bb',
},
},
op_intent_ref_creation_strategy: {
Expand Down
19 changes: 4 additions & 15 deletions monitoring/benchmarker/configurations/user/astm/scd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@

from monitoring.benchmarker.configurations.user.astm.dss import ASTMDSSSelectionStrategy
from monitoring.benchmarker.engine.coordination import CoordinationGroupID
from monitoring.monitorlib.geo import Altitude, LatLngBoundingBox
from monitoring.uss_qualifier.resources.definitions import ResourceID


class SingleSubscription(ImplicitDict):
subscription_id: SubscriptionID
"""ID of the single subscription to create, or ensure exists."""

duration: StringBasedTimeDelta
"""Duration of the subscription, from the time it is created."""

area: LatLngBoundingBox
"""Horizontal area this subscription should cover."""

min_alt: Altitude
"""Altitude below which this subscription should not apply."""

max_alt: Altitude
"""Altitude above which this subscription should not apply."""
"""ID of the single subscription to use when creating operational intents."""


class ImplicitSubscription(ImplicitDict):
Expand All @@ -32,7 +19,9 @@ class ImplicitSubscription(ImplicitDict):

class SubscriptionStrategy(ImplicitDict):
single_subscription: Optional[SingleSubscription]
"""Planner ensures there is a single subscription, established at the start of operations, covering all their flights."""
"""Planner expects there to be a single subscription established at the start of operations covering all their flights.

A configuration specifying this strategy must separately ensure this subscription exists, such as via an f3548.create_subscription action."""

implicit_subscription: Optional[ImplicitSubscription]
"""Planner has the DSS establish an implicit subscription for each individual flight."""
Expand Down
81 changes: 1 addition & 80 deletions monitoring/benchmarker/engine/users/flight_planner/scd.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class SCDHandler(CoordinationSubscriber):

random: Random

subscription_checked: bool = False
op_intent_refs: dict[FlightID, api.OperationalIntentReference]

key: list[api.EntityOVN]
Expand Down Expand Up @@ -199,85 +198,7 @@ def select_dss_instance(self) -> DSSInstance:
)

def get_utm_actions(self, flight: Flight) -> Iterable[FlightAction]:
if (
not self.subscription_checked
and "single_subscription" in self.subscription_strategy
and self.subscription_strategy.single_subscription is not None
):
yield FlightAction(
timestamp=datetime.now(UTC),
start=partial(
self.ensure_subscription_exists,
flight,
self.subscription_strategy.single_subscription.subscription_id,
),
run_on_shutdown=False,
)
else:
yield from self.get_create_actions(flight)

async def ensure_subscription_exists(
self,
flight: Flight,
subscription_id: api.SubscriptionID,
) -> list[FlightAction]:
t0 = datetime.now(UTC)
if not self.subscription_strategy.single_subscription:
raise RuntimeError(
"ensure_subscription_exists called even though single_subscription was undefined"
)

start_time = t0
end_time = (
t0 + self.subscription_strategy.single_subscription.duration.timedelta
)
area = self.subscription_strategy.single_subscription.area.to_latlngrect()
min_alt = self.subscription_strategy.single_subscription.min_alt.to_w84_m()
max_alt = self.subscription_strategy.single_subscription.max_alt.to_w84_m()

dss_instance = self.select_dss_instance()
uss_base_url = make_fake_url()

mutated_sub = dss_instance.upsert_subscription(
area_vertices=area,
start_time=start_time,
end_time=end_time,
base_url=uss_base_url,
sub_id=subscription_id,
notify_for_op_intents=True,
notify_for_constraints=False,
min_alt_m=min_alt,
max_alt_m=max_alt,
)
success = None
self.user.record_query(mutated_sub, True)

if mutated_sub.status_code == 409:
# Subscription already exists
success = True

if success is None and not mutated_sub.success:
success = False

if success is None:
try:
_ = mutated_sub.subscription
success = True
except ValueError:
success = False

flight.completed_actions.append(
CompletedFlightAction(
type=FlightActionType.UpsertSCDSubscription,
initiated_at=t0,
causes_flight_failure=not success,
)
)
self.subscription_checked = True
if success:
return list(self.get_create_actions(flight))
else:
return []
yield from self.get_create_actions(flight)

def get_create_actions(self, flight: Flight) -> Iterable[FlightAction]:
op_intent_id = api.EntityID(uuid.uuid4())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,12 @@
"description": "Path to content that replaces the $ref",
"type": "string"
},
"area": {
"$ref": "../../../../../monitorlib/geo/LatLngBoundingBox.json",
"description": "Horizontal area this subscription should cover."
},
"duration": {
"description": "Duration of the subscription, from the time it is created.",
"format": "duration",
"type": "string"
},
"max_alt": {
"$ref": "../../../../../monitorlib/geo/Altitude.json",
"description": "Altitude above which this subscription should not apply."
},
"min_alt": {
"$ref": "../../../../../monitorlib/geo/Altitude.json",
"description": "Altitude below which this subscription should not apply."
},
"subscription_id": {
"description": "ID of the single subscription to create, or ensure exists.",
"description": "ID of the single subscription to use when creating operational intents.",
"type": "string"
}
},
"required": [
"area",
"duration",
"max_alt",
"min_alt",
"subscription_id"
],
"type": "object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]
},
"single_subscription": {
"description": "Planner ensures there is a single subscription, established at the start of operations, covering all their flights.",
"description": "Planner expects there to be a single subscription established at the start of operations covering all their flights.\n\nA configuration specifying this strategy must separately ensure this subscription exists, such as via an f3548.create_subscription action.",
"oneOf": [
{
"type": "null"
Expand Down
Loading