Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nonnontrivial committed Jun 28, 2024
1 parent 3985e43 commit 16594f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pp/pp/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

@dataclass
class PredictionMessage:
utc: str
lat: float
lon: float
utc: str
# magnitudes per square arc second
mpsas: float
# id of the h3 cell
Expand Down
13 changes: 6 additions & 7 deletions pp/pp/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
prediction_endpoint_url = f"{api_protocol}://{api_host}:{api_port}/api/{api_version}/predict"


async def get_prediction_message_for_lat_lon(client: httpx.AsyncClient, lat: float, lon: float) -> PredictionMessage:
async def get_prediction_message(client: httpx.AsyncClient, h3_lat: float, h3_lon: float) -> PredictionMessage:
"""create the object that will get published to rabbitmq."""
res = await client.get(prediction_endpoint_url, params={"lat": lat, "lon": lon})
res = await client.get(prediction_endpoint_url, params={"lat": h3_lat, "lon": h3_lon})
res.raise_for_status()

data = res.json()
if (mpsas := data.get("sky_brightness", None)) is None:
raise ValueError("no sky brightness reading in api response")

message = PredictionMessage(
lat=lat,
lon=lon,
h3_id=h3.geo_to_h3(lat, lon, resolution=0),
lat=h3_lat,
lon=h3_lon,
utc=datetime.utcnow().isoformat(),
mpsas=mpsas,
h3_id=h3.geo_to_h3(h3_lat, h3_lon, resolution=0),
)
return message

Expand All @@ -42,8 +42,7 @@ async def publish_cell_prediction(client: httpx.AsyncClient, h3_coords: Tuple[fl

try:
lat, lon = h3_coords

m = await get_prediction_message_for_lat_lon(client, lat, lon)
m = await get_prediction_message(client, lat, lon)
message_body = asdict(m)

log.info(f"publishing {message_body} to {prediction_queue}")
Expand Down

0 comments on commit 16594f9

Please sign in to comment.