Skip to content

Commit

Permalink
add patch to allow new /api endpoints to work while retaining existin… (
Browse files Browse the repository at this point in the history
#52)

* add patch to allow new /api endpoints to work while retaining existing capability

* patch the NotifyCumulus class for new api path

* better way to check if "/api" is in endpoint

* bump netcdf to pass tests
  • Loading branch information
adamscarberry authored Jan 16, 2025
1 parent 7933ff1 commit a977e48
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ boto3==1.34.138
botocore==1.34.138
celery==5.4.0
pyplugs==0.4.0
netCDF4==1.6.5
netCDF4==1.7.2
requests==2.32.3
GDAL[numpy]==3.9.1
psycopg2-binary==2.9.9
Expand Down
10 changes: 8 additions & 2 deletions src/cumulus_geoproc/geoprocess/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""handle the messages coming from the worker thread
"""


import asyncio
import os
from collections import namedtuple
Expand Down Expand Up @@ -115,7 +114,14 @@ def upload_notify(notices: list, bucket: str):
# notify
if len(payload) > 0:
cumulus_api = capi.CumulusAPI(CUMULUS_API_URL, HTTP2)
cumulus_api.endpoint = "productfiles"

# Patch to work with new /api endpoints if present
if cumulus_api.endpoint == "/api":
cumulus_api.endpoint = "api/productfiles"
else:
# Use the old path where there is not /api present
cumulus_api.endpoint = "productfiles"

cumulus_api.query = {"key": APPLICATION_KEY}

logger.debug(f"Payload to POST: {payload}")
Expand Down
10 changes: 9 additions & 1 deletion src/cumulus_geoproc/utils/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections import namedtuple
from urllib.parse import urlencode, urlsplit, urlunsplit

import os
import httpx
from cumulus_geoproc.configurations import APPLICATION_KEY
from cumulus_geoproc import logger
Expand Down Expand Up @@ -98,7 +99,14 @@ class NotifyCumulus(CumulusAPI):

def __init__(self, url, http2=True):
super().__init__(url, http2)
self.endpoint = "productfiles"

# Patch to work with new /api endpoints if present
if self.endpoint == "/api":
self.endpoint = "api/productfiles"
else:
# Use the old path where there is not /api present
self.endpoint = "productfiles"

self.query = {"key": APPLICATION_KEY}

def run(self, payload):
Expand Down

0 comments on commit a977e48

Please sign in to comment.