Skip to content

Commit

Permalink
Merge pull request #3125 from lonvia/warm-to-python
Browse files Browse the repository at this point in the history
Port warm and export functions to Python
  • Loading branch information
lonvia authored Jul 26, 2023
2 parents 261e0cf + 8cba658 commit 1c6f426
Show file tree
Hide file tree
Showing 28 changed files with 383 additions and 661 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ if (BUILD_API OR BUILD_IMPORTER)
else()
message (STATUS "Using PHP binary " ${PHP_BIN})
endif()
if (NOT PHPCGI_BIN)
find_program (PHPCGI_BIN php-cgi)
endif()
# sanity check if PHP binary exists
if (NOT EXISTS ${PHPCGI_BIN})
message(WARNING "php-cgi binary not found. nominatim tool will not provide query functions.")
set (PHPCGI_BIN "")
else()
message (STATUS "Using php-cgi binary " ${PHPCGI_BIN})
endif()
endif()

#-----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions cmake/tool-installed.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ from nominatim import version
version.GIT_COMMIT_HASH = '@GIT_HASH@'

exit(cli.nominatim(module_dir='@NOMINATIM_LIBDIR@/module',
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql',
phpcgi_path='@PHPCGI_BIN@'))
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql'))
3 changes: 1 addition & 2 deletions cmake/tool.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ from nominatim import version
version.GIT_COMMIT_HASH = '@GIT_HASH@'

exit(cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module',
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql',
phpcgi_path='@PHPCGI_BIN@'))
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql'))
1 change: 0 additions & 1 deletion docs/admin/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ For running Nominatim:
* [PHP](https://php.net) (7.3+)
* PHP-pgsql
* PHP-intl (bundled with PHP)
* PHP-cgi (for running queries from the command line)

For running continuous updates:

Expand Down
190 changes: 0 additions & 190 deletions lib-php/admin/export.php

This file was deleted.

115 changes: 0 additions & 115 deletions lib-php/admin/warm.php

This file was deleted.

2 changes: 1 addition & 1 deletion man/create-manpage.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ sys.path.append('@PROJECT_SOURCE_DIR@')
from nominatim.cli import get_set_parser

def get_parser():
parser = get_set_parser(phpcgi_path='@PHPCGI_BIN@')
parser = get_set_parser()

return parser.parser
1 change: 1 addition & 0 deletions nominatim/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from .core import (NominatimAPI as NominatimAPI,
NominatimAPIAsync as NominatimAPIAsync)
from .connection import (SearchConnection as SearchConnection)
from .status import (StatusResult as StatusResult)
from .types import (PlaceID as PlaceID,
OsmID as OsmID,
Expand Down
11 changes: 8 additions & 3 deletions nominatim/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""
from typing import Mapping, Optional, Any, AsyncIterator, Dict, Sequence, List, Tuple
import asyncio
import sys
import contextlib
from pathlib import Path

Expand All @@ -32,11 +33,15 @@ class NominatimAPIAsync:
""" API loader asynchornous version.
"""
def __init__(self, project_dir: Path,
environ: Optional[Mapping[str, str]] = None) -> None:
environ: Optional[Mapping[str, str]] = None,
loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
self.config = Configuration(project_dir, environ)
self.server_version = 0

self._engine_lock = asyncio.Lock()
if sys.version_info >= (3, 10):
self._engine_lock = asyncio.Lock()
else:
self._engine_lock = asyncio.Lock(loop=loop) # pylint: disable=unexpected-keyword-arg
self._engine: Optional[sa_asyncio.AsyncEngine] = None
self._tables: Optional[SearchTables] = None
self._property_cache: Dict[str, Any] = {'DB:server_version': 0}
Expand Down Expand Up @@ -274,7 +279,7 @@ class NominatimAPI:
def __init__(self, project_dir: Path,
environ: Optional[Mapping[str, str]] = None) -> None:
self._loop = asyncio.new_event_loop()
self._async_api = NominatimAPIAsync(project_dir, environ)
self._async_api = NominatimAPIAsync(project_dir, environ, loop=self._loop)


def close(self) -> None:
Expand Down
Loading

0 comments on commit 1c6f426

Please sign in to comment.