Skip to content
Merged
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
210 changes: 0 additions & 210 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1269,14 +1269,6 @@
"lineCount": 1
}
},
{
"code": "reportReturnType",
"range": {
"startColumn": 11,
"endColumn": 30,
"lineCount": 1
}
},
{
"code": "reportReturnType",
"range": {
Expand Down Expand Up @@ -1847,30 +1839,6 @@
}
],
"./monitoring/mock_uss/scd_injection/routes_injection.py": [
{
"code": "reportReturnType",
"range": {
"startColumn": 11,
"endColumn": 30,
"lineCount": 1
}
},
{
"code": "reportReturnType",
"range": {
"startColumn": 11,
"endColumn": 30,
"lineCount": 1
}
},
{
"code": "reportReturnType",
"range": {
"startColumn": 11,
"endColumn": 58,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
Expand All @@ -1887,14 +1855,6 @@
"lineCount": 1
}
},
{
"code": "reportReturnType",
"range": {
"startColumn": 11,
"endColumn": 30,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
Expand All @@ -1911,14 +1871,6 @@
"lineCount": 1
}
},
{
"code": "reportReturnType",
"range": {
"startColumn": 11,
"endColumn": 30,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
Expand Down Expand Up @@ -4974,30 +4926,6 @@
"endColumn": 69,
"lineCount": 1
}
},
{
"code": "reportPrivateImportUsage",
"range": {
"startColumn": 50,
"endColumn": 55,
"lineCount": 1
}
},
{
"code": "reportPrivateImportUsage",
"range": {
"startColumn": 43,
"endColumn": 48,
"lineCount": 1
}
},
{
"code": "reportPrivateImportUsage",
"range": {
"startColumn": 44,
"endColumn": 49,
"lineCount": 1
}
}
],
"./monitoring/uss_qualifier/main.py": [
Expand Down Expand Up @@ -20312,144 +20240,6 @@
}
}
],
"./monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py": [
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 16,
"endColumn": 20,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 19,
"endColumn": 23,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 84,
"endColumn": 88,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 127,
"endColumn": 131,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 22,
"endColumn": 26,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 31,
"endColumn": 35,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 35,
"endColumn": 39,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 19,
"endColumn": 23,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 60,
"endColumn": 64,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 103,
"endColumn": 107,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 42,
"endColumn": 47,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 12,
"endColumn": 16,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 34,
"endColumn": 38,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 65,
"endColumn": 69,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 108,
"endColumn": 112,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 34,
"endColumn": 39,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 11,
"endColumn": 15,
"lineCount": 1
}
}
],
"./monitoring/uss_qualifier/scenarios/interuss/flight_authorization/general_flight_authorization.py": [
{
"code": "reportOptionalMemberAccess",
Expand Down
28 changes: 12 additions & 16 deletions monitoring/mock_uss/flight_planning/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import uuid
from datetime import timedelta

import arrow
Expand All @@ -12,8 +11,7 @@
from monitoring.mock_uss.app import require_config_value, webapp
from monitoring.mock_uss.auth import requires_scope
from monitoring.mock_uss.config import KEY_BASE_URL
from monitoring.mock_uss.f3548v21.flight_planning import op_intent_from_flightinfo
from monitoring.mock_uss.flights.database import FlightRecord, db
from monitoring.mock_uss.flights.database import db
from monitoring.mock_uss.scd_injection.routes_injection import (
clear_area,
delete_flight,
Expand Down Expand Up @@ -54,7 +52,9 @@ def injection_status() -> tuple[dict, int]:
@webapp.route("/flight_planning/v1/flight_plans/<flight_plan_id>", methods=["PUT"])
@requires_scope(Scope.Plan)
@idempotent_request()
def flight_planning_v1_upsert_flight_plan(flight_plan_id: str) -> tuple[str, int]:
def flight_planning_v1_upsert_flight_plan(
flight_plan_id: str,
) -> tuple[str | flask.Response, int]:
def log(msg: str) -> None:
logger.debug(f"[upsert_plan/{os.getpid()}:{flight_plan_id}] {msg}")

Expand All @@ -73,28 +73,24 @@ def log(msg: str) -> None:
existing_flight = lock_flight(flight_plan_id, log)
try:
info = FlightInfo.from_flight_plan(req_body.flight_plan)
op_intent = op_intent_from_flightinfo(info, str(uuid.uuid4()))
new_flight = FlightRecord(
flight_info=info,
op_intent=op_intent,
mod_op_sharing_behavior=(
req_body.behavior
if "behavior" in req_body and req_body.behavior
else None
),
inject_resp = inject_flight(
flight_plan_id,
info,
req_body.behavior if "behavior" in req_body and req_body.behavior else None,
existing_flight,
)

inject_resp = inject_flight(flight_plan_id, new_flight, existing_flight)

finally:
release_flight_lock(flight_plan_id, log)

resp = api.UpsertFlightPlanResponse(
planning_result=api.PlanningActivityResult(inject_resp.activity_result),
flight_plan_status=api.FlightPlanStatus(inject_resp.flight_plan_status),
)
if "as_planned" in inject_resp and inject_resp.as_planned:
resp.as_planned = inject_resp.as_planned.to_flight_plan()
for k, v in inject_resp.items():
if k not in {"planning_result", "flight_plan_status", "has_conflict"}:
if k not in {"planning_result", "flight_plan_status", "as_planned"}:
resp[k] = v
return flask.jsonify(resp), 200

Expand Down
36 changes: 36 additions & 0 deletions monitoring/mock_uss/flights/planning.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
import json
from collections.abc import Callable
from datetime import UTC, datetime

import arrow
from implicitdict import ImplicitDict

from monitoring.mock_uss.flights.database import DEADLOCK_TIMEOUT, FlightRecord, db
from monitoring.monitorlib.clients.flight_planning.flight_info import FlightInfo
from monitoring.monitorlib.delay import sleep
from monitoring.monitorlib.temporal import Time


def adjust_flight_info(info: FlightInfo) -> FlightInfo:
result: FlightInfo = ImplicitDict.parse(json.loads(json.dumps(info)), FlightInfo)

now = arrow.utcnow()

for v4d in result.basic_information.area:
# Fill in empty start times with now
if "time_start" not in v4d or not v4d.time_start:
v4d.time_start = Time(now)

# Truncate volume start times to current
elif v4d.time_start.datetime < now:
v4d.time_start = Time(now)

# Validate volume times
for i, v4d in enumerate(result.basic_information.area):
if (
"time_start" in v4d
and v4d.time_start
and "time_end" in v4d
and v4d.time_end
and v4d.time_start >= v4d.time_end
):
raise ValueError(
f"Volume {i} start time {v4d.time_start} (originally {info.basic_information.area[i].time_start}) is at or after end time {v4d.time_end}"
)

return result


def lock_flight(flight_id: str, log: Callable[[str], None]) -> FlightRecord:
Expand Down
Loading
Loading