This directory contains Jupyter notebooks designed to teach users how to work with KnowRob. You can run these tutorials locally on your machine, using Docker, or remotely on Binder. This README provides instructions on each method and explains how to add your own tutorials to the repository.
You can run the Jupyter tutorials locally by following these steps:
- Add KnowRob to your Python environment by setting the
PYTHONPATHto thebuilddirectory where KnowRob is located.
- Navigate to the
tutorialsdirectory: - Start the Jupyter notebook server:
jupyter notebook
- Open one of the tutorial notebooks (e.g.,
intro.ipynb) from your browser, and begin running the cells.
Alternatively, you can run the Jupyter notebooks locally using Docker, which provides a controlled environment with all dependencies set up for you.
- Ensure you have Docker installed on your machine.
- Navigate to the root of your KnowRob repository in your terminal.
- Run the following commands to build and start the Docker containers:
chmod -R g+w ./ && export GID=$(id -g) && \ docker compose -f ./binder/docker-compose.yml up --build
- Open your web browser and navigate to the provided URL to start working with the Jupyter notebooks.
You can run the Jupyter notebooks remotely using Binder without having to install anything locally. Binder provides an online environment where you can directly interact with the notebooks.
- Open your web browser and navigate to the following Binder link: Run on Binder
- This will launch a remote instance of Jupyter Lab, where you can open and run the tutorial notebooks.
If you wish to add your own tutorials to the KnowRob project, follow these steps:
- Place your new Jupyter notebook in the
tutorialsdirectory. - Name your notebook appropriately to reflect its contents and topic.
- Open and run the notebook locally.
- After running all the cells, save the notebook with the outputs by clicking File > Save and Checkpoint. Ensure that the outputs are stored so that they can be used in the testing pipeline.
To make sure your tutorial is testable in the CI pipeline, use the provided script to store the notebook's outputs in its metadata. This is required to set up the notebook for unit testing with nbval.
- Run the script to store the outputs for testing:
This script will move the outputs of the cells into the
python3 notebook_test_util.py store --notebook ./jupyter/tutorials/<your-notebook>.ipynb
metadatafield of the notebook.
You can now commit and push your changes to the repository, including the notebook with the stored outputs.