Skip to main content

osm2pgsql-tuner project recommends an osm2pgsql command based on available system resources and the size of the input PBF file.

Project description

osm2pgsql-tuner

The osm2pgsql-tuner project recommends an osm2pgsql command based on available system resources and the size of the input PBF file. The recommendations made by this program are targeted for:

  • osm2pgsql v1.5.0 and newer
  • Flex output
  • No stage 2 processing

Stage 2 processing has less predictable RAM consumption per this discussion on GitHub.

API Documentation available.

Using osm2pgsql via Python

To use the osm2pgsql recommendation without using the API/website, the osm2pgsql_tuner package can be used.

Install osm2pgsql-tuner within an virtual environment.

pip install osm2pgsql-tuner

Import osm2pgsql_tuner and create an instance of the recommendation class.

import osm2pgsql_tuner
rec = osm2pgsql_tuner.Recommendation(system_ram_gb=8,
                                     osm_pbf_gb=0.5,
                                     pgosm_layer_set='run')
pbf_path = '~/pgosm-data/example_file.osm.pbf'
osm2pgsql_command = rec.get_osm2pgsql_command(pbf_path=pbf_path)
print(osm2pgsql_command)

Returns.

osm2pgsql -d $PGOSM_CONN  --create  --output=flex --style=./run.lua  ~/pgosm-data/example_file.osm.pbf

Deployment Instructions

Note: Need to update the sub-version of Python over time. Can use simply python3 but that can lead to using older unsupported versions based on distribution defaults.

cd ~/venv
python3.8 -m venv osm2pgsql-tuner
source ~/venv/osm2pgsql-tuner/bin/activate

Install requirements.

source ~/venv/osm2pgsql-tuner/bin/activate
cd ~/git/osm2pgsql-tuner
pip install -r requirements.txt

Run web server w/ uWSGI.

source ~/venv/osm2pgsql-tuner/bin/activate
cd ~/git/osm2pgsql-tuner
python run_server.py

Unit tests

Run unit tests.

python -m unittest tests/*.py

Or run unit tests with coverage.

coverage run -m unittest tests/*.py

Generate report.

coverage report -m osm2pgsql_tuner/*.py

Run pylint.

pylint --rcfile=./.pylintrc -f parseable \
    ./osm2pgsql_tuner/*.py

Used by

This project is used by PgOSM Flex to automate commands in the PgOSM Flex Docker image.

Development install

pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osm2pgsql_tuner-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osm2pgsql_tuner-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file osm2pgsql_tuner-0.1.1.tar.gz.

File metadata

  • Download URL: osm2pgsql_tuner-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for osm2pgsql_tuner-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2836f5deb0cc8b98e4effb430b89520c45828e8108934990d32efb7c3fc51d43
MD5 94fb5761bd013d474df7f74e5ae8027d
BLAKE2b-256 01df91d5d1ec7ea02babb324a2463d17db253aa9ea9ffc9aff5057b49aa7e6b1

See more details on using hashes here.

File details

Details for the file osm2pgsql_tuner-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for osm2pgsql_tuner-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5d79e0d0ef3b6e83d3dd33d894ce95e9a586e24c488c52c2a718372f0af1a1a
MD5 c3f4fa6cb25a3db9bc60780ec8997bd7
BLAKE2b-256 2053bb35112b7ed1726582817e819ffe21f0677cba8e39959c9c5cf8725cca82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page