geopython / pycsw

pycsw is an OGC CSW server implementation written in Python. pycsw fully implements the OpenGIS Catalogue Service Implementation Specification [Catalogue Service for the Web]. Initial development started in 2010 (more formally announced in 2011). The project is certified OGC Compliant, and is an OGC Reference Implementation. pycsw allows for the publishing and discovery of geospatial metadata via numerous APIs (CSW 2/CSW 3, OpenSearch, OAI-PMH, SRU). Existing repositories of geospatial metadata can also be exposed, providing a standards-based metadata and catalogue component of spatial data infrastructures. pycsw is Open Source, released under an MIT license, and runs on all major platforms (Windows, Linux, Mac OS X). Please read the docs at https://pycsw.org/docs for more information.
https://pycsw.org
MIT License
198 stars 153 forks source link

run PostgreSQL/SQLite workflow only if configured #907

Closed tomkralidis closed 10 months ago

tomkralidis commented 10 months ago

Overview

Replaces #829. Only execute pycsw RDBMS codepath is pycsw is configured with PostgreSQL or SQLite.

cc @epifanio for validation (and whose pycsw backend is SOLR).

Related Issue / Discussion

None

Additional Information

None

Contributions and Licensing

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

tomkralidis commented 10 months ago

I guess a simpler

if db_handler is not None:
    db_handler(...)

would work here instead of the rest of the changes, but regardless I'm definitely +1!

Just a small question: since this change is being made in order to accommodate SOLR backends, don't these also require some sort of handling too? Even if just waiting to see if the SOLR service is responding?

In any case, its +1 from me

+1, I've made the change above. Thanks @ricardogsilva !

Thinking more, perhaps pycsw.admin.setup_db should turn into pycsw.core.repository.setup, with the default being RDBMS, to which other repository plugins can update accordingly. Then docker/entrypoint.py simply calls a repository function. Thoughts?

Having said this, my next task further abstracting the OGC API - Records code away from RDBMS, at which point the above will likely be addressed.

@epifanio: once you also can validate this PR, I'll merge accordingly.

epifanio commented 10 months ago

This PR handles the DB settings in the entrypoint but the problem in "not using a DB as backend" persist when running the CSW Flask APP. As the FLASK app still depends on a DB connection.

In the Flask APP, the API class from pycsw.ogc.api.records: api_ = API(APP.config['PYCSW_CONFIG']) will make a new call to the DB from which it will build the query_mappings

Full traceback

epifanio commented 10 months ago

I tested with the last commit it now works as expected, by running the WSGI app instead of the default Flask app.

@tomkralidis thanks!