Loading Development Data
During development, it is common to clear and re-populate the graph database. Since this flow is not trivial (it requires obtaining authorization tokens), Kartograph provides a script that can be used to quickly load a JSONL data file into the graph.
Prerequisites
Section titled “Prerequisites”- Ensure that you have followed the contributing installation guide. This process requires that you have an instance of Kartograph running.
- JSONL data. The example in the extraction guide can be used for quick testing.
Loading Data
Section titled “Loading Data”-
Prepare Your Environment Set your working directory to the root of the
kartographrepository, and take note of the absolute filepath to your JSONL data.For this guide, we will assume the data is at
/tmp/my-data.jsonl. -
(Optional) Wipe Database
If desired, the entire persistent state of Kartograph, including graph, application, and authorization data, can be wiped by:
Terminal window docker compose down -v # -v removes volumes, which persist data -
Invoke the Load Script
Run
scripts/load_jsonl.py, passing the absolute path of your JSONL data as an argument.Terminal window uv run scripts/load_jsonl.py /tmp/my-data.jsonl -
Authenticate
If this is the first time the script has been run on your computer, you will be interactively prompted to authenticate.
The development configuration of Kartograph defines two test accounts:
Username Password alicepasswordbobpasswordPick one of them to authenticate with.
The token retrieved from Keycloak during this process will be cached at
~/.kartograph/token.json -
Verify Data
After authenticating, the data should automatically be loaded into the graph with output similar to:
Terminal window $ uv run scripts/load_jsonl.py /tmp/my-data.jsonlKartograph JSONL LoaderAPI: http://localhost:8000Keycloak: http://localhost:8080/realms/kartographAuthentication RequiredUsername: alicePassword: ********⠋ Authenticating with Keycloak...✓ Token cached to /home/user/.kartograph/token.jsonPosting my-data.jsonl (78,624 bytes) to http://localhost:8000/graph/mutations⠼ Uploading...Success! Status: 200{"success":true,"operations_applied":258,"errors":[]}As a quick verification step, you can visit the development graph viewer: http://localhost:8000/util/graph-viewer.