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
206 stars 155 forks source link

Refactor repository out of Docker entrypoint #909

Closed tomkralidis closed 12 months ago

tomkralidis commented 12 months ago

Overview

This PR moves RDBMS specific functionality out of the Docker entrypoint into pycsw.core.repository. This allows for repository backends that are not PostgreSQL/SQLite to spin up as expected (following pycsw.core.repository functions).

This PR also moves the query mappings out of OGC API - Records code into the repository as well.

Finally, PL/Python support is removed, given most PostgreSQL installs currently would have PostGIS more easily.

As a result, pycsw.core.repository is a bit more self-contained.

cc @epifanio

Related Issue / Discussion

None

Additional Information

None

Contributions and Licensing

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

epifanio commented 11 months ago

If the DB is not present in the configuration - the sysytem will not start.

My config for the repository section looks like:

[repository]
database=None
table=None
source=pycsw.plugins.repository.solr_metno.SOLRMETNORepository
filter=http://SOLR-IP:8983/solr/adc
adc_collection=ADC
MMD_XSL_DIR=/usr/local/share/mmd/xslt/
➜  CSW_ADC git:(master) ✗ docker run -it -v $(pwd)/test.cfg:/etc/pycsw/pycsw.cfg epinux/pycsw:master
INFO:pycsw.core.repository:Creating database None
DEBUG:__main__:Could not parse SQLAlchemy URL from string 'None'
DEBUG:pycsw.core.config:Initializing static context
INFO:pycsw.core.repository:creating new engine: None
Traceback (most recent call last):
  File "/usr/local/bin/entrypoint.py", line 144, in <module>
    launch_pycsw(config, workers=workers, reload=args.reload)
  File "/usr/local/bin/entrypoint.py", line 82, in launch_pycsw
    repo = Repository(pycsw_config.get("repository", "database"),
  File "/home/pycsw/pycsw/pycsw/core/repository.py", line 107, in __init__
    self.engine = Repository.create_engine('%s' % self.database)
  File "/home/pycsw/pycsw/pycsw/core/repository.py", line 76, in create_engine
    engine = create_engine('%s' % url, echo=False, pool_pre_ping=True)
  File "<string>", line 2, in create_engine
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 514, in create_engine
    u = _url.make_url(url)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/url.py", line 738, in make_url
    return _parse_url(name_or_url)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/url.py", line 799, in _parse_url
    raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: Could not parse SQLAlchemy URL from string 'None'

@tomkralidis