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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CommonMetadataType(BaseModel):
last_update: Optional[date] = Field(default=None, description="a timestamp representing the lastUpdate according to ISO 8601 (e.g. 2018-01-30)", alias="lastUpdate")
literature: Optional[StrictStr] = Field(default=None, description="an optional hint to literature about the dataset (e.g. URL or book/article name)")
note: Optional[StrictStr] = Field(default=None, description="an optional note with background information about the dataset")
srid_epsg: Union[StrictFloat, StrictInt] = Field(description="the coordinate reference system of the dataset as EPSG code", alias="sridEPSG")
srid_epsg: Optional[Union[StrictFloat, StrictInt]] = Field(description="the coordinate reference system of the dataset as EPSG code", alias="sridEPSG")
update_interval: StrictStr = Field(alias="updateInterval")
__properties: ClassVar[List[str]] = ["contact", "databasis", "datasource", "description", "lastUpdate", "literature", "note", "sridEPSG", "updateInterval"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import json


from typing import Any, ClassVar, Dict, List
from typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictStr
from pydantic import Field
try:
Expand All @@ -31,7 +31,7 @@ class GeoresourceReferenceType(BaseModel):
"""
a reference to georesource, e.g. a resource that is used to compute the main indicator
""" # noqa: E501
referenced_georesource_description: StrictStr = Field(description="a meaningful description of how the referenced georesource is related to the main indicator", alias="referencedGeoresourceDescription")
referenced_georesource_description: Optional[StrictStr] = Field(description="a meaningful description of how the referenced georesource is related to the main indicator", alias="referencedGeoresourceDescription")
referenced_georesource_id: StrictStr = Field(description="unique identifier of the referenced georesource", alias="referencedGeoresourceId")
referenced_georesource_name: StrictStr = Field(description="the meaningful name of the referenced georesource", alias="referencedGeoresourceName")
__properties: ClassVar[List[str]] = ["referencedGeoresourceDescription", "referencedGeoresourceId", "referencedGeoresourceName"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class IndicatorOverviewType(BaseModel):
"""
IndicatorOverviewType
""" # noqa: E501
abbreviation: StrictStr = Field(description="abbreviated mark of the indicator")
abbreviation: Optional[StrictStr] = Field(description="abbreviated mark of the indicator")
allowed_roles: Optional[List[StrictStr]] = Field(default=None, description="list of role identifiers that have read access rights for this dataset", alias="allowedRoles")
applicable_dates: List[StrictStr] = Field(description="array of applicable dates (year and month and day as YEAR-MONTH-DAY) according to ISO 8601 (e.g. 2018-01-30)", alias="applicableDates")
applicable_spatial_units: List[IndicatorSpatialUnitJoinItem] = Field(description="array of spatial unit levels for which the dataset is applicable", alias="applicableSpatialUnits")
characteristic_value: StrictStr = Field(description="the distuingishing characteristic value of the indicator", alias="characteristicValue")
characteristic_value: Optional[StrictStr] = Field(description="the distuingishing characteristic value of the indicator", alias="characteristicValue")
creation_type: StrictStr = Field(description="indicates if the data is simply inserted (INSERTION), computed by an automated script (COMPUTATION) or automatically aggregated by a script (AGGREGATION)", alias="creationType")
default_classification_mapping: Optional[DefaultClassificationMappingType] = Field(default=None, alias="defaultClassificationMapping")
indicator_id: StrictStr = Field(description="unique identifier of this resource", alias="indicatorId")
Expand All @@ -52,7 +52,7 @@ class IndicatorOverviewType(BaseModel):
lowest_spatial_unit_for_computation: Optional[StrictStr] = Field(default=None, description="identifier/name of the lowest spatial unit for which the indicator can be computed and thus is available (only necessary for computable indicators)", alias="lowestSpatialUnitForComputation")
metadata: CommonMetadataType
ogc_services: List[OgcServicesType] = Field(description="list of available OGC services for that indicator for different spatial units", alias="ogcServices")
process_description: StrictStr = Field(description="description about how the indicator was computed", alias="processDescription")
process_description: Optional[StrictStr] = Field(description="description about how the indicator was computed", alias="processDescription")
reference_date_note: Optional[StrictStr] = Field(default=None, description="an optional note on the reference date of the indicator", alias="referenceDateNote")
display_order: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="an order number to control display order in clients", alias="displayOrder")
referenced_georesources: Optional[List[GeoresourceReferenceType]] = Field(default=None, description="list of references to georesources", alias="referencedGeoresources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import json


from typing import Any, ClassVar, Dict, List
from typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictStr
from pydantic import Field
try:
Expand All @@ -31,7 +31,7 @@ class IndicatorReferenceType(BaseModel):
"""
a reference to another indicator, e.g. a sub-indicator that is used to compute the main indicator
""" # noqa: E501
referenced_indicator_description: StrictStr = Field(description="a meaningful description of how the referenced indicator is related to the main indicator", alias="referencedIndicatorDescription")
referenced_indicator_description: Optional[StrictStr] = Field(description="a meaningful description of how the referenced indicator is related to the main indicator", alias="referencedIndicatorDescription")
referenced_indicator_id: StrictStr = Field(description="unique identifier of the referenced indicator", alias="referencedIndicatorId")
referenced_indicator_name: StrictStr = Field(description="the meaningful name of the referenced indicator", alias="referencedIndicatorName")
__properties: ClassVar[List[str]] = ["referencedIndicatorDescription", "referencedIndicatorId", "referencedIndicatorName"]
Expand Down
13 changes: 7 additions & 6 deletions processor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
from flask import Flask, send_from_directory, request
from werkzeug.utils import secure_filename

from auth import MyIntrospectTokenValidator
from auth import KomMonitorIntrospectTokenValidator

if not os.getenv("PYGEOAPI_CONFIG"):
os.environ["PYGEOAPI_CONFIG"] = os.path.join(os.path.dirname(__file__), "default-config.yml")
if not os.getenv("PYGEOAPI_OPENAPI"):
os.environ["PYGEOAPI_OPENAPI"] = os.path.join(os.path.dirname(__file__), "default-openapi.yml")

from pygeoapi import flask_app
from pygeoapi.flask_app import STATIC_FOLDER, API_RULES, CONFIG, api_, get_response
from pygeoapi.flask_app import STATIC_FOLDER, API_RULES, CONFIG, api_, processes_api, execute_from_flask

require_oauth = ResourceProtector()
require_oauth.register_token_validator(MyIntrospectTokenValidator())
require_oauth.register_token_validator(KomMonitorIntrospectTokenValidator())

APP = Flask(__name__, static_folder=STATIC_FOLDER, static_url_path='/static')
APP.url_map.strict_slashes = API_RULES.strict_slashes
Expand All @@ -35,8 +35,7 @@ def landing_page():
@APP.get('/processes/<process_id>')
@require_oauth()
def get_processes(process_id=None):
return get_response(api_.describe_processes(request, process_id))

return flask_app.get_processes(process_id)

@APP.post('/processes')
@require_oauth()
Expand Down Expand Up @@ -119,6 +118,7 @@ def parse_processes(package: str) -> None:
"""
processes = flask_app.api_.manager.processes
for process in glob.glob(f"process/{package}/*.py"):
print(process)
with open(process) as fh:
root = ast.parse(fh.read())
for node in ast.iter_child_nodes(root):
Expand All @@ -131,6 +131,7 @@ def parse_processes(package: str) -> None:
}
}
flask_app.api_.manager.processes = processes
api_.config['resources'] = processes


async def init():
Expand All @@ -151,9 +152,9 @@ async def init():
# await deployment.apply()
pass

asyncio.run(init())

def run():
asyncio.run(init())

APP.run(debug=False,
host=api_.config['server']['bind']['host'],
Expand Down
2 changes: 1 addition & 1 deletion processor/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
KC_HOSTNAME_PATH = os.getenv('KC_HOSTNAME_PATH', "")


class MyIntrospectTokenValidator(IntrospectTokenValidator):
class KomMonitorIntrospectTokenValidator(IntrospectTokenValidator):
def introspect_token(self, token_string):
url = f"https://{KC_HOSTNAME}{KC_HOSTNAME_PATH}/realms/{KC_REALM_NAME}/protocol/openid-connect/token/introspect"
data = {'token': token_string[7:], 'token_type_hint': 'access_token'}\
Expand Down
3 changes: 0 additions & 3 deletions processor/default-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ server:
languages:
# First language is the default language
- en-US
- fr-CA
# cors: true
pretty_print: true
limit: 10
Expand All @@ -63,10 +62,8 @@ metadata:
identification:
title:
en: pygeoapi default instance
fr: instance par défaut de pygeoapi
description:
en: pygeoapi provides an API to geospatial data
fr: pygeoapi fournit une API aux données géospatiales
keywords:
en:
- geospatial
Expand Down
Loading
Loading