Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Jan 8, 2024
1 parent 59c726c commit 02a4bb5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 92 deletions.
69 changes: 20 additions & 49 deletions monitoring/monitorlib/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
import json
import os
import uuid
import jwt
from typing import Dict, Optional, List, Union

from enum import Enum
from typing import Dict, Optional, List, Union
from urllib.parse import urlparse

import flask
from loguru import logger
import jwt
import requests
import urllib3
import yaml
from implicitdict import ImplicitDict, StringBasedDateTime
from loguru import logger
from yaml.representer import Representer

from implicitdict import ImplicitDict, StringBasedDateTime
from monitoring.monitorlib import infrastructure
from monitoring.monitorlib.errors import stacktrace_string
from monitoring.monitorlib.rid import RIDVersion
Expand Down Expand Up @@ -180,8 +179,8 @@ def describe_flask_response(resp: flask.Response, elapsed_s: float):


class QueryType(str, Enum):

# ASTM F3411-19 and F3411-22a (RID)
# DSS endpoints
F3411v19DSSSearchIdentificationServiceAreas = (
"astm.f3411.v19.dss.searchIdentificationServiceAreas"
)
Expand Down Expand Up @@ -217,9 +216,6 @@ class QueryType(str, Enum):
"astm.f3411.v22a.dss.deleteIdentificationServiceArea"
)

F3411v19DSSSearchFlights = "astm.f3411.v19.dss.searchFlights"
F3411v22aDSSSearchFlights = "astm.f3411.v22a.dss.searchFlights"

F3411v19DSSSearchSubscriptions = "astm.f3411.v19.dss.searchSubscriptions"
F3411v22aDSSSearchSubscriptions = "astm.f3411.v22a.dss.searchSubscriptions"

Expand All @@ -235,26 +231,19 @@ class QueryType(str, Enum):
F3411v19DSSDeleteSubscription = "astm.f3411.v19.dss.deleteSubscription"
F3411v22aDSSDeleteSubscription = "astm.f3411.v22a.dss.deleteSubscription"

# USS endpoints
F3411v19USSSearchFlights = "astm.f3411.v19.uss.searchFlights"
F3411v22aUSSearchFlights = "astm.f3411.v22a.uss.searchFlights"

F3411v19USSPostIdentificationServiceArea = (
"astm.f3411.v19.uss.postIdentificationServiceArea"
)
F3411v22aUSSPostIdentificationServiceArea = (
"astm.f3411.v22a.uss.postIdentificationServiceArea"
)

# Flight injection (test harness)

F3411v19USSCreateTest = "rid.f3411.v19.sp.createTest"
F3411v22aUSSCreateTest = "rid.f3411.v22a.sp.createTest"

F3411v19USSDeleteTest = "rid.f3411.v19.sp.deleteTest"
F3411v22aUSSDeleteTest = "rid.f3411.v22a.sp.deleteTest"

# RID flight details endpoint that a USS provides (!= DSS)
F3411v22aUSSGetDisplayData = "rid.f3411.v22a.sp.getDisplayData"
F3411v19USSGetDisplayData = "rid.f3411.v19.sp.getDisplayData"
F3411v22aUSSGetFlightDetails = "rid.f3411.v22a.sp.getDetails"
F3411v19USSGetFlightDetails = "rid.f3411.v19.sp.getDetails"
F3411v22aUSSGetFlightDetails = "astm.f3411.v22a.uss.getFlightDetails"
F3411v19USSGetFlightDetails = "astm.f3411.v19.uss.getFlightDetails"

# ASTM F3548-21
F3548v21DSSQueryOperationalIntentReferences = (
Expand Down Expand Up @@ -333,18 +322,18 @@ class QueryType(str, Enum):
"interuss.automated_testing.rid.v1.observation.getDetails"
)

# Flight injection (test harness)
InterussRIDAutomatedTestingV1CreateTest = (
"interuss.automated_testing.rid.v1.injection.createTest"
)

InterussRIDAutomatedTestingV1DeleteTest = (
"interuss.automated_testing.rid.v1.injection.deleteTest"
)

def __str__(self):
return self.value

@staticmethod
def flight_details(rid_version: RIDVersion):
if rid_version == RIDVersion.f3411_19:
return QueryType.F3411v19USSGetFlightDetails
elif rid_version == RIDVersion.f3411_22a:
return QueryType.F3411v22aUSSGetFlightDetails
else:
raise ValueError(f"Unsupported RID version: {rid_version}")

@staticmethod
def dss_get_isa(rid_version: RIDVersion):
if rid_version == RIDVersion.f3411_19:
Expand Down Expand Up @@ -381,24 +370,6 @@ def dss_delete_isa(rid_version: RIDVersion):
else:
raise ValueError(f"Unsupported RID version: {rid_version}")

@staticmethod
def sp_create_test(rid_version: RIDVersion):
if rid_version == RIDVersion.f3411_19:
return QueryType.F3411v19USSCreateTest
elif rid_version == RIDVersion.f3411_22a:
return QueryType.F3411v22aUSSCreateTest
else:
raise ValueError(f"Unsupported RID version: {rid_version}")

@staticmethod
def sp_delete_test(rid_version: RIDVersion):
if rid_version == RIDVersion.f3411_19:
return QueryType.F3411v19USSDeleteTest
elif rid_version == RIDVersion.f3411_22a:
return QueryType.F3411v22aUSSDeleteTest
else:
raise ValueError(f"Unsupported RID version: {rid_version}")


class Query(ImplicitDict):
request: RequestDescription
Expand Down
8 changes: 0 additions & 8 deletions monitoring/monitorlib/fetch/rid.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,6 @@ def set_participant_id(self, participant_id: str) -> None:
else:
raise NotImplementedError(f"Cannot set participant_id")

def set_query_type(self, query_type: QueryType) -> None:
if self.v19_query is not None:
self.v19_query.query_type = query_type
elif self.v22a_query is not None:
self.v22a_query.query_type = query_type
else:
raise NotImplementedError(f"Cannot set query_type")


class FetchedISA(RIDQuery):
"""Version-independent representation of an ISA read from the DSS."""
Expand Down
3 changes: 1 addition & 2 deletions monitoring/uss_qualifier/resources/netrid/observers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def observe_system(
url,
scope=Scope.Observe,
participant_id=self.participant_id,
query_type=QueryType.flight_details(rid_version),
query_type=QueryType.InterUSSRIDObservationV1GetDetails,
)
try:
result = (
Expand Down Expand Up @@ -77,7 +77,6 @@ def observe_flight_details(
)
# Record query metadata for later use in the aggregate checks
query.participant_id = self.participant_id
query.query_type = QueryType.flight_details(rid_version)
try:
result = (
ImplicitDict.parse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def submit_test(
json=request,
scope=SCOPE_RID_QUALIFIER_INJECT,
participant_id=self.participant_id,
query_type=fetch.QueryType.sp_create_test(rid_version),
query_type=fetch.QueryType.InterussRIDAutomatedTestingV1CreateTest,
)

def delete_test(
Expand All @@ -82,7 +82,7 @@ def delete_test(
url=f"/tests/{test_id}/{version}",
scope=SCOPE_RID_QUALIFIER_INJECT,
participant_id=self.participant_id,
query_type=fetch.QueryType.sp_delete_test(rid_version),
query_type=fetch.QueryType.InterussRIDAutomatedTestingV1DeleteTest,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,12 @@ def _isa_missing_outline(self, create_isa_url: str, json_body: Dict[str, Any]):
url=create_isa_url,
scope=self.write_scope,
json=payload,
query_type=QueryType.dss_create_isa(self._dss.rid_version),
)
if self._dss.rid_version == RIDVersion.f3411_19:
rid_query = ChangedISA(v19_query=q)
rid_query.set_query_type(
QueryType.F3411v19DSSCreateIdentificationServiceArea
)
elif self._dss.rid_version == RIDVersion.f3411_22a:
rid_query = ChangedISA(v22a_query=q)
rid_query.set_query_type(
QueryType.F3411v22aDSSCreateIdentificationServiceArea
)
else:
raise ValueError(f"Unknown RID version: {self._dss.rid_version}")

Expand Down Expand Up @@ -287,17 +282,12 @@ def _isa_missing_volume(self, create_isa_url: str, json_body: Dict[str, Any]):
url=create_isa_url,
scope=self.write_scope,
json=payload,
query_type=QueryType.dss_create_isa(self._dss.rid_version),
)
if self._dss.rid_version == RIDVersion.f3411_19:
rid_query = ChangedISA(v19_query=q)
rid_query.set_query_type(
QueryType.F3411v19DSSCreateIdentificationServiceArea
)
elif self._dss.rid_version == RIDVersion.f3411_22a:
rid_query = ChangedISA(v22a_query=q)
rid_query.set_query_type(
QueryType.F3411v22aDSSCreateIdentificationServiceArea
)
else:
raise ValueError(f"Unknown RID version: {self._dss.rid_version}")

Expand All @@ -324,17 +314,12 @@ def _isa_missing_extents(self, create_isa_url: str, json_body: Dict[str, Any]):
url=create_isa_url,
scope=self.write_scope,
json=payload,
query_type=QueryType.dss_create_isa(self._dss.rid_version),
)
if self._dss.rid_version == RIDVersion.f3411_19:
rid_query = ChangedISA(v19_query=q)
rid_query.set_query_type(
QueryType.F3411v19DSSCreateIdentificationServiceArea
)
elif self._dss.rid_version == RIDVersion.f3411_22a:
rid_query = ChangedISA(v22a_query=q)
rid_query.set_query_type(
QueryType.F3411v22aDSSCreateIdentificationServiceArea
)
else:
raise ValueError(f"Unknown RID version: {self._dss.rid_version}")

Expand Down
4 changes: 2 additions & 2 deletions monitoring/uss_qualifier/scenarios/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
QueryType.F3411v19USSPostIdentificationServiceArea,
QueryType.F3411v22aUSSPostIdentificationServiceArea,
# When querying for display data and flight details, we don't always know the participant ID
QueryType.F3411v19USSGetDisplayData,
QueryType.F3411v22aUSSGetDisplayData,
QueryType.InterUSSRIDObservationV1GetDisplayData,
QueryType.InterUSSRIDObservationV1GetDetails,
QueryType.F3411v19USSGetFlightDetails,
QueryType.F3411v22aUSSGetFlightDetails,
]
Expand Down
18 changes: 7 additions & 11 deletions schemas/monitoring/monitorlib/fetch/Query.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
"astm.f3411.v22a.dss.updateIdentificationServiceArea",
"astm.f3411.v19.dss.deleteIdentificationServiceArea",
"astm.f3411.v22a.dss.deleteIdentificationServiceArea",
"astm.f3411.v19.dss.searchFlights",
"astm.f3411.v22a.dss.searchFlights",
"astm.f3411.v19.dss.searchSubscriptions",
"astm.f3411.v22a.dss.searchSubscriptions",
"astm.f3411.v19.dss.getSubscription",
Expand All @@ -39,16 +37,12 @@
"astm.f3411.v22a.dss.updateSubscription",
"astm.f3411.v19.dss.deleteSubscription",
"astm.f3411.v22a.dss.deleteSubscription",
"astm.f3411.v19.uss.searchFlights",
"astm.f3411.v22a.uss.searchFlights",
"astm.f3411.v19.uss.postIdentificationServiceArea",
"astm.f3411.v22a.uss.postIdentificationServiceArea",
"rid.f3411.v19.sp.createTest",
"rid.f3411.v22a.sp.createTest",
"rid.f3411.v19.sp.deleteTest",
"rid.f3411.v22a.sp.deleteTest",
"rid.f3411.v22a.sp.getDisplayData",
"rid.f3411.v19.sp.getDisplayData",
"rid.f3411.v22a.sp.getDetails",
"rid.f3411.v19.sp.getDetails",
"astm.f3411.v22a.uss.getFlightDetails",
"astm.f3411.v19.uss.getFlightDetails",
"astm.f3548.v21.dss.queryOperationalIntentReferences",
"astm.f3548.v21.dss.getOperationalIntentReference",
"astm.f3548.v21.dss.createOperationalIntentReference",
Expand Down Expand Up @@ -79,7 +73,9 @@
"interuss.automated_testing.flight_planning.v1.UpsertFlightPlan",
"interuss.automated_testing.flight_planning.v1.DeleteFlightPlan",
"interuss.automated_testing.rid.v1.observation.getDisplayData",
"interuss.automated_testing.rid.v1.observation.getDetails"
"interuss.automated_testing.rid.v1.observation.getDetails",
"interuss.automated_testing.rid.v1.injection.createTest",
"interuss.automated_testing.rid.v1.injection.deleteTest"
],
"type": [
"string",
Expand Down

0 comments on commit 02a4bb5

Please sign in to comment.