Skip to main content

Impuls

GitHub | Documentation | Issue Tracker | PyPI

Impuls is a framework for processing static public transportation data. The internal model used is very close to GTFS.

The core entity for processing is called a pipeline, which is composed of multiple tasks that do the actual processing work.

The data is stored in an sqlite3 database with a very lightweight wrapper to map Impuls's internal model into SQL and GTFS.

Impuls has first-class support for pulling in data from external sources, using its resource mechanism. Resources are cached before the data is processed, which saves bandwidth if some of the input data has not changed, or even allows to stop the processing early if none of the resources have been modified.

A module for dealing with versioned, or multi-file sources is also provided. It allows for easy and very flexible processing of schedules provided in discrete versions into a single coherent file.

Installation and Compilation

Impuls is mainly written in Python, however a performance-critical part of this library is written in Rust and bundled alongside the shared library. To install, run the following, preferably inside of a virtual environment:

pip install impuls

Pre-built binaries are available for most platforms. To build from source Rust with Cargo and a C compiler needs to be installed.

The LoadBusManMDB task additionally requires mdbtools to be installed. This package is available in most package managers.

Examples

See https://impuls.readthedocs.io/en/stable/example.html for a tutorial and a more detailed walkthrough over Impuls features.

The examples directory contains 4 example configurations, processing data from four sources into a GTFS file. If you wish to run them, consult with the Development section of the readme to set up the environment correctly.

Kraków

Kraków provides decent GTFS files on https://gtfs.ztp.krakow.pl. The example pipeline removes unnecessary, confusing trip data and fixes several user-facing strings.

Run with python -m examples.krakow tram or python -m examples.krakow bus. The result GTFS will be created in _workspace_krakow/krakow.tram.out.zip or _workspace_krakow/krakow.bus.out.zip, accordingly.

PKP IC (PKP Intercity)

PKP Intercity provides their schedules in a single CSV table at ftp://ftps.intercity.pl. Unfortunately, the source data is not openly available. One needs to email PKP Intercity through the contact provided in the Polish MMTIS NAP in order to get the credentials.

The Pipeline starts by manually creating an Agency, loading the CSV data, pulling station data from https://github.com/MKuranowski/PLRailMap, adjusting some user-facing data - most importantly extracting trip legs operated by buses.

Run with python -m examples.pkpic FTP_USERNAME FTP_PASSWORD. The result GTFS will be created at _workspace_pkpic/pkpic.zip

Radom

MZDiK Radom provides schedules in a MDB database at http://mzdik.pl/index.php?id=145. It is the first example to use the multi-file pipeline support, as the source files are published in discrete versions.

Multi-file pipelines consist of four distinct parts:

  • an intermediate provider, which figures out the relevant input ("intermediate") feeds
  • a intermediate tasks factory, which returns the tasks necessary to load an intermediate feed into the SQLite database
  • a final tasks factory, which returns the tasks to perform after merging intermediate feeds
  • any additional resources, required by the intermediate or final tasks

Caching is even more involved - not only the input feeds are kept across runs, but the databases resulting from running intermediate pipelines are also preserved. If 3 of 4 feeds requested by the intermediate provider have already been processed - the intermediate pipeline will run only for the single new file, but the final (merging) pipeline will be run on all of the 4 feeds.

The intermediate provider for Radom scrapes the aforementioned website to find available databases.

Pipeline for processing intermediate feeds is a bit more complex: it involved loading the MDB database, cleaning up the data (removing virtual stops, generating and cleaning calendars) and pulling stop positions from http://rkm.mzdik.radom.pl/.

The final pipeline simply dumps the merged dataset into a GTFS.

Run with python -m examples.radom, the result GTFS will be created at _workspace_radom/radom.zip.

Warsaw

Warsaw is another city which requires multi-file pipelines. ZTM Warsaw publishes distinct input files for pretty much every other day at ftp://rozklady.ztm.waw.pl. The input datasets are in a completely custom text format, requiring quite involved parsing. More details are available at https://www.ztm.waw.pl/pliki-do-pobrania/dane-rozkladowe/ (in Polish).

The intermediate provider picks out relevant files from the aforementioned FTP server.

Processing of intermediate feeds starts with the import of the text file into the database. Rather uniquely, this step also prettifies stop names - as this would be hard to do in a separate task, due to the presence of indicators (two-digit codes uniquely identifying a stop around an intersection) in the name field. The pipeline continues by adding version meta-data, merging railway stations into a single stops.txt entry (ZTM separates railway departures into virtual stops) and attribute prettifying (namely trip_headsign and stop_lat,stop_lon - not all stops have positions in the input file). Last steps involve cleaning up unused entities from the database.

The final pipeline simply dumps the merged dataset into a GTFS, yet again.

Additional data for stop positions and edge-cases for prettifying stop names comes from https://github.com/MKuranowski/WarsawGTFS/blob/master/data_curated/stop_names.json.

Run with python -m examples.warsaw, the result GTFS will be created at _workspace_warsaw/warsaw.zip.

License

Impuls is distributed under GNU GPL v3 (or any later version).

© Copyright 2022-2026 Mikołaj Kuranowski

Impuls is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

Impuls is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Impuls. If not, see http://www.gnu.org/licenses/.

Impuls pre-built binaries come with sqlite3, which is placed in the public domain.

Development

Impuls uses meson-python. The project layout is quite unorthodox, as Impuls in neither a pure-python module, nor a project with a bog-standard C/C++ extension. Instead, the Rust code is compiled into a shared library which is bundled alongside the Python module.

Development requires Python, Rust with Cargo, a C compiler, and mdbtools (usually all will be available in your package manager repositories) to be installed. To then set up the environment on Linux, run:

$ python -m venv --upgrade-deps .venv
$ . .venv/bin/activate
$ pip install -Ur requirements.dev.txt
$ pip install --no-build-isolation -Cbuild-dir=builddir --editable .
$ ln -s ../../builddir/libextern.so impuls/extern

On MacOS, change the shared library file extension to .dylib. On Windows, change the extension of the shared library to .dll.

To run Python tests, simply execute pytest. To run Rust tests, run meson test -C builddir, or cargo test in the <impuls/extern/> subdirectory.

To run the examples, install their dependencies first (pip install -Ur requirements.examples.txt), then execute the example module, e.g. python -m examples.krakow.

meson-python will automatically recompile the Rust library whenever an editable Impuls install is imported; set the MESONPY_EDITABLE_VERBOSE environment variable to 1 to see meson logs for build details.

By default, the extern Rust library will be built in debug mode. To change that, run meson configure --buildtype=release builddir (buildtype can also be set to debug). To recompile the library, run meson compile -C builddir.

Unfortunately, meson-python requires all Python and Rust source files listed in meson.build. Python files need to be listed for packaging to work, while Rust source files need to be listed for the build backend to properly detect whether libextern needs to be recompiled.

Building wheels

Thanks to cargo-zigbuild and cargo-xwin wheels can be automatically cross-compiled to all major platforms.

Cross-compilation however required multiple extra dependencies: Zig, clang and llvm-tools (mostly llvm-lib and llvm-strip). Rust should also be installed through rustup, along with all of the targets from cross/*.ini files added with rustup add target XXX.

Two extra dependencies need to be installed in the venv as well: pip install -U build wheel.

To build the wheels, simply run python build_wheels.py.

See python build_wheels.py --help for all available options. To debug failed builds, run python build_wheels.py --verbose --jobs 1 FAILED_CONFIG_NAME.

See CONFIGURATION in build_wheels.py for available configurations.

To build the source distribution, run python -m build -so dist.

Download files

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

Source Distribution

impuls-2.5.1.tar.gz (2.4 MB view details)

Uploaded Source

Built Distributions

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

impuls-2.5.1-py3-none-win_arm64.whl (1.2 MB view details)

Uploaded Python 3Windows ARM64

impuls-2.5.1-py3-none-win_amd64.whl (1.2 MB view details)

Uploaded Python 3Windows x86-64

impuls-2.5.1-py3-none-musllinux_1_1_x86_64.whl (1.3 MB view details)

Uploaded Python 3musllinux: musl 1.1+ x86-64

impuls-2.5.1-py3-none-musllinux_1_1_aarch64.whl (1.2 MB view details)

Uploaded Python 3musllinux: musl 1.1+ ARM64

impuls-2.5.1-py3-none-manylinux_2_17_x86_64.whl (1.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

impuls-2.5.1-py3-none-manylinux_2_17_aarch64.whl (1.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

impuls-2.5.1-py3-none-macosx_11_0_x86_64.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

impuls-2.5.1-py3-none-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file impuls-2.5.1.tar.gz.

File metadata

  • Download URL: impuls-2.5.1.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for impuls-2.5.1.tar.gz
Algorithm Hash digest
SHA256 069c5c2b13442ab615ba7b0d1d5eebab660cb8c0055aff924683cae72f138e32
MD5 8a60e7ad4ed6be9927a2029f28439523
BLAKE2b-256 08835fc7e7c24c18eb72d7c6d88f88d630b6b7eacd278b1acd7ce9eacba1d3e4

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-win_arm64.whl.

File metadata

  • Download URL: impuls-2.5.1-py3-none-win_arm64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for impuls-2.5.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 a283e6526d5b17365f2c70a165ea8245451661dd966047f36bca82e0db7f2e9b
MD5 cb545a8000ad598e724f3c2f5ec7852c
BLAKE2b-256 5d6899d56685b036b1895d27398a7e702ec8e2c1f6e47172ca7a376221a748ba

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: impuls-2.5.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for impuls-2.5.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1444faf217a2375f1645ffca52fd385c1bf75633e57dd4199f3a77ced5b1174b
MD5 997435a477df136b8ebf336a59a38bc4
BLAKE2b-256 05369c5092498a6708aa32b256b22ebdde46b5af999aa1ea6ae35514f6201fc0

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for impuls-2.5.1-py3-none-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c50eec5d062e4796d1b36737ce508f2f46318da7d0e763f0dc3b707960f5a837
MD5 8ff8ca669ee44fc6ca21f3d57f557f4a
BLAKE2b-256 62239349a513d56ed23eea53260ddde4902c2ab2b4f9ed555e176e283d50e103

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for impuls-2.5.1-py3-none-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 8326d9db7c899d7df6ffaec92eefccbca195c02b7a3c7614216ebb7b0867a3da
MD5 9f13fcd3941c6adf1e92426277947128
BLAKE2b-256 774c31a4bdab38b367a71bd94dd6c8e9bb16f77f46c74e3f671379c59b26087a

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for impuls-2.5.1-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 b5e7aec7a707d9eb14d007a54ca5269ba3d69928d28c15539019c4aee83a3be7
MD5 1bc0a400b5ff1fad91c7c57c379ecf28
BLAKE2b-256 68630ac46ec8def9d34bd773aa9e8be034d50a491dc24c7579f530b201c953eb

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for impuls-2.5.1-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 24996c6c1bd3a3f4e55e550565bf3bddb5b44fb87b805cf8f47a3cd4374408b0
MD5 8b1bad8f6518f66ae234f9e16babbcd1
BLAKE2b-256 9fa9207c8be2efabbadeccb1de4b51958de18e69fbd13a4136344cbb3a371e09

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for impuls-2.5.1-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 72b1247ddbf28dc0dadaba251cbff05c270a8d5ac693c0ad8141634e87516333
MD5 9a9e72358db5ad5cd32e2c6d4f70b404
BLAKE2b-256 fcdb9752969ee46d6aa90720735a817305e481fae3419c875c400aa4b6608b5d

See more details on using hashes here.

File details

Details for the file impuls-2.5.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for impuls-2.5.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52c994baacae03315bcc4fa1de37d3a576a7e4e8deeb7f2f16a6968021411331
MD5 ec4092bdb64011bccc4c62986f178569
BLAKE2b-256 187338f1f500bc8ee50f69f12aa13de1e730295f757a7b3a681e037046324725

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 Sentry Error logging StatusPage Status page