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
3 changes: 2 additions & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ To run the server, please execute the following from the root directory:

```bash
pip3 install -r requirements.txt
PYTHONPATH=src uvicorn openapi_server.main:app --host 0.0.0.0 --port 8080
cd unity-sps-ogc-processes-api/app
PYTHONPATH=src uvicorn unity_sps_ogc_processes_api.main:app --host 0.0.0.0 --port 8008
```

and open your browser at `http://localhost:8080/docs/` to see the docs.
Expand Down
23 changes: 15 additions & 8 deletions app/src/openapi_server/impl/dru_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,29 @@ def replace(self, processId: str, ogcapppkg: Ogcapppkg) -> None:
detail=f"DAG file for process {processId} not found in the catalog",
)

# Optionally, you might want to refresh the DAG in Airflow
# Update the DAG in Airflow
ems_api_auth = HTTPBasicAuth(
self.settings.EMS_API_AUTH_USERNAME,
self.settings.EMS_API_AUTH_PASSWORD.get_secret_value(),
)
response = requests.post(
f"{self.settings.EMS_API_URL}/dags/{processId}/dagRuns",

# Determine if DAG is paused and retain state
response = requests.get(
f"{self.settings.EMS_API_URL}/dags/{ogcapppkg.process_description.id}",
auth=ems_api_auth,
)
data = response.json()
is_paused = data.get("is_paused", False)

# Request to replace the DAG in Airflow
response = requests.patch(
f"{self.settings.EMS_API_URL}/dags/{processId}",
auth=ems_api_auth,
json={"is_paused": False}, # Unpause the DAG if it was paused
json={"is_paused": is_paused}, # Unpause the DAG if it was paused
)
response.raise_for_status()

return Response(
status_code=status.HTTP_204_NO_CONTENT,
content=f"Process {processId} replaced successfully",
)
return Response(status_code=status.HTTP_204_NO_CONTENT)
except LockError:
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
Expand Down