A Jupyter Notebook workspace for exploring GTFS data via SQLite3 and optionally Python. Configured and provided via Nix.
Warning
Using this method, you cannot save your progress.
Use the Local Quick Start method if you wish to save your progress.
This method is great for quickly getting the notebook up and running with all data populated, but not great for learners who wish to save their progress.
This is because the notebook will be downloaded to the nix store and will be read-only.
Using Nix, we can start JupyterLab and load the notebook with a single command.
: nix run github:firestack/gtfs_onboarding.nix#interactive-read-onlyThis command does the following:
- Runs the nix flake app named
interactive-read-onlywhich- downloads the flake repository
into the nix store then:
- builds the jupyter lab and kernels needed.
- downloads the associated GTFS data and:
- creates a SQLite3 database using the downloaded GTFS data.
- starts
jupyter-labin a directory containing:- the notebooks and associated data.
- the GTFS SQLite database.
- downloads the flake repository
into the nix store then:
- next, follow the instructions in the section: opening the notebook.
- Clone this repository
: git clone https://github.com/firestack/gtfs_onboarding.nix.git - Enter the directory
: cd ./gtfs_onboarding.nix
-
- Run via nix flakes
: nix run
- Run via nix flakes
-
-
load the necessary dependencies into your shell using
direnv: direnv allow -
Then run the
jupyter-labcommand to start the notebook server.: jupyter-lab
-
- In the terminal output, find and click on link with authentication token
Tip
afterwards, you can just navigate to
localhost:8888 in that same
browser.
Here's an example of the links to look out for in the terminal window.
To access the server, open this file in a browser: file:///.jupyter/runtime/jpserver-00000-open.html Or copy and paste one of these URLs: http://localhost:8888/lab?token=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa http://127.0.0.1:8888/lab?token=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- Open file
GTFS Onboarding.sqlite3.ipynb- For a Python notebook, you can also open
GTFS Onboarding.python.ipynb
- For a Python notebook, you can also open
- Enjoy!
Runs the notebook with only the SQLite kernel loaded. This will skip downloading the python dependencies and building the Python environment.
: nix run .#lab-sqliteRuns the notebook with only the Python kernel loaded. This will download the Python dependencies and configure the Python environment and will not download or build the SQLite kernel.
: nix run .#lab-pythonThe gtfs.nix file contains content addressed2 definitions for other GTFS feeds which can be loaded. These can be loaded into the environment using the Local start method and building the relevant GTFS database.
For example, the command
: nix build -o mbta-20201002.db .#mbta-gtfs-20201002
# OR
: nix build -o mbta-20201002.db github:firestack/gtfs_onboarding.nix#mbta-gtfs-20201002will download the archived GTFS feed and build a SQLite3
database, and then link it to a file in your working
directory named mbta-20201002.db.
Then, in the notebook, you'll need to change the name of the database passed to the open command.
Alternatively, you can build the database and overwrite the feed.db link:
: nix build -o feed.db .#mbta-gtfs-20201002JupyterLab seems to have difficulty running on Firefox, with symptoms of being extremely slow and unresponsive. Using Safari or Chrome have been a stable alternative for running the notebooks2.