Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1600 allow providing default value in config #1604

Conversation

ricardogsilva
Copy link
Member

@ricardogsilva ricardogsilva commented Mar 20, 2024

Overview

This PR implements allowing default values for config variables that can come from the environment. Most notably it becomes possible to combine several env variables in a single config value.

For the most common case of having the full variable correspond to some env value or else a default value, the syntax is myvar: ${MY_VAR:-some default}, as shown below:

server:
    host: ${MY_HOST:-localhost}
    port: ${MY_PORT:-5000}
    combined: ${MY_HOST:-localhost} - ${MY_PORT:-5000}

UPDATE: With the latest commit, this paragraph below is no longer relevant - no need to use the !env YAML tag

For cases where the env variable is being used as part of a config variable and it shows up in the middle of the variable it becomes mandatory to use the !env YAML tag:

metadata:
    identification:
        title:
            en: !env This is pygeoapi host ${MY_HOST} and port ${MY_PORT:-5000}, nice to meet you!

Related Issue / discussion

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@ricardogsilva
Copy link
Member Author

Failing CI seems to be due to ubuntugis-ppa being unavailable, it is not related to the changes in this PR, which do not touch any CI or dependency-related things

@kalxas
Copy link
Member

kalxas commented Mar 20, 2024

Launchpad is down for a few hours for maintenance reasons

https://twitter.com/launchpadstatus/status/1770482383453577682

@tomkralidis
Copy link
Member

Looks like Launchpad came back. @ricardogsilva can you check/fix the latest CI failures?

@ricardogsilva
Copy link
Member Author

@tomkralidis I'm not able to ask for a re-run of the failed CI workflow - can you please do it?

@tomkralidis
Copy link
Member

The CI was already re-run, and had some unit test errors. I've re-run them just now: https://github.com/geopython/pygeoapi/actions/runs/8365396387/job/22911691167?pr=1604#step:20:134

@ricardogsilva
Copy link
Member Author

@tomkralidis fixed CI failures

@tomkralidis tomkralidis merged commit 2abb943 into geopython:master Mar 22, 2024
4 checks passed
@tomkralidis tomkralidis added this to the 0.18.0 milestone Mar 22, 2024
@tomkralidis tomkralidis self-requested a review March 22, 2024 22:47
tomkralidis pushed a commit to totycro/pygeoapi that referenced this pull request Mar 25, 2024
tomkralidis added a commit that referenced this pull request Apr 5, 2024
* Move api to subdirectory

* Move processes api to own file

* Adapt processes view methods

* Move openapi definition to processes api

* Use processes api in flask

* Linter

* Fix import issues

* Allow calling refactored views from starlette

* Allow calling refactored views from django

* Linter

* Move edr api to own file

* Adapt edr api to new style

* Fix typo in django views

* Move maps api to own file

* Adapt maps api to new style

* Move edr openapi to edr api file

* Move maps openapi to maps api file

* Move stac views to own file

* Refactor stac views to new file

* Move stac openapi to stac api file

* Move tiles api to own file

* Adapt tiles api to new style

* Also move tilematrixset to tiles api

* Adapt tilesetmatrix views to new style

NOTE: I had to remove one tilematrixsets test because
it tested that an invalid format would produce an error.
This now happens by default for all views, but the actual
code is outside of the endpoint function.

* update features, records, coverages

* update release version

* switch back to dev

* backport of #1313

* backport of #1313 fix

* backport of #1585

* Flask: sanitize OGC schema pathing (#1593)

* update release version

* switch back to dev

* backport of #1596

* Port test_gzip_csv test

Note that apply_gzip is now called by the web framework adapters,
so to test it in general, we have to call it in the test manually

* Add empty conformance class list to stac api

* Fix queryables call in starlette

* fix ref

* Unify request validity checking

The default case is handled by the web framework adapters. If custom
format handling is required, the check in the adapter must be skipped.

* Fix imports in django views

* backport #1598

* Remove test about format handling in endpoint

This is now handled outside of the endpoint function

* add docstring to base process manager (#1603)

* backport of #1601

* Port api ogr tests to new style

* Move processes tests to own file

* Run api tests from new dir in CI

* Move edr tests to own file

* Move maps tests to own file

* Move tiles tests to own file

* Actually hide hidden layers in openapi

* 1600 allow providing default value in config (#1604)

* move coverages tests to own file

* move itemtypes to own file, move core into init test

* fix OpenAPI output

* update tests

* add missing descriptions to OpenAPI admin responses

* update tests

* fix tests autodiscovery

* remove unused logging in tests

* address PR comments

* test with xarray 2024.2.0

* remove unneeded file

* safeguard xarray error

* unpin xarray

* fix OpenAPI generation

* fix schema endpoint in Flask and Starlette

* Safely serialize configuration JSON (#1605)

* Safely serialize configuration JSON

Co-Authored-By: Tom Kralidis <tomkralidis@gmail.com>

* Revert "Safely serialize configuration JSON"

This reverts commit 36feb06.

* Add test for datetime with Admin API

* Safely serialize configuration JSON

---------

Co-authored-by: Tom Kralidis <tomkralidis@gmail.com>

* backport #1611

* Also fix schema endpoint for django

Fix is analogous to e72d4ba

* address additional PR comments

---------

Co-authored-by: Tom Kralidis <tomkralidis@gmail.com>
Co-authored-by: Angelos Tzotsos <gcpp.kalxas@gmail.com>
Co-authored-by: Ricardo Garcia Silva <ricardo.garcia.silva@gmail.com>
Co-authored-by: Benjamin Webb <40066515+webb-ben@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants