Skip to content

Commit

Permalink
Merge pull request #74 from citysciencelab/add-providers
Browse files Browse the repository at this point in the history
Add providers endpoint
  • Loading branch information
hwbllmnn authored Nov 12, 2024
2 parents fd16733 + 24b2943 commit 1f90d0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ump/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ modelserver-1:
process-1:
result-storage: "geoserver"
result-path: simulation_geometry
graph-properties:
root-path: results.simulation_results
anonymous-access: True
process-2
result-storage: "remote"
deterministic: True
process-3
exclude: True
```

For each process, it is possible to choose from result-storage options. If the attribute `result-storage` is set to `remote`, no results will be stored in the UMP itself, but provided directly from the model server. In case it is set to `geoserver`, UMP will load the geoserver component and tries to store the result data in a specific Geoserver layer. You can specify the object path to the feature collection using `result-path`. Use dots to separate a path with several components: `result-path: result.some_obj.some_features`.

Processes configured with `anonymous-access: True` can be seen and run by anonymous users. Jobs and layers created by anonymous users will be cleaned up after some time (this can be configured in `config.py`).

Process can be configured with `deterministic: True`. If so, jobs will be cached based on a hash of the input parameters, the process version and the user id.
Processes can be configured with `deterministic: True`. If so, jobs will be cached based on a hash of the input parameters, the process version and the user id.

With `graph-properties` and the sub-properties `root-path`, `x-path` and `y-path` you can configure processes to simplify graph configuration in the UI.

## Keycloak

Expand Down
19 changes: 19 additions & 0 deletions src/ump/api/routes/processes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import asyncio
import copy
import json

from apiflask import APIBlueprint
from flask import Response, g, request

import ump.api.providers as providers
from ump.api.process import Process
from ump.api.processes import all_processes

Expand All @@ -27,3 +29,20 @@ def execute(process_id_with_prefix=None):
process = Process(process_id_with_prefix)
result = process.execute(request.json, None if auth is None else auth['sub'])
return Response(json.dumps(result), status=201, mimetype="application/json")

@processes.route("/providers", methods=["GET"])
def get_providers():
"""Returns the providers config"""
response = copy.deepcopy(providers.PROVIDERS)
for key in response:
if 'authentication' in response[key]:
del response[key]['authentication']
del response[key]['url']
if 'timeout' in response[key]:
del response[key]['timeout']
for process in response[key]['processes']:
if 'deterministic' in response[key]['processes'][process]:
del response[key]['processes'][process]['deterministic']
if 'anonymous-access' in response[key]['processes'][process]:
del response[key]['processes'][process]['anonymous-access']
return response

0 comments on commit 1f90d0a

Please sign in to comment.