A CLI tool to import siglip2 image index files (.jsonl, .pkl) into a BeaverDB.
Project description
Image Index Importer for BeaverDB
A command-line tool to import image index files (generated by siglip2-image-indexer) into a BeaverDB database for vector search.
This tool uses the full path of each image as its unique ID. Running the importer multiple times with the same or updated index files automatically updates existing entries and adds new ones (an "upsert" operation), preventing duplicates.
Installation
The tool can be installed using two methods. The key dependencies, including beaver-db[full], tqdm, and PyYAML, will be installed automatically.
1. Install from PyPI (Recommended for Users)
If the package is published on PyPI, you can install it directly:
pip install beaver-index-importer
2. Install from Source (For Developers)
To install the package in editable mode for development or using the latest source code:
- Clone the Repository:
- Access the Directory: Navigate into the cloned directory, which is
beaver-index-importer. - Install in Editable Mode:
# Clone your repository
git clone https://github.com/yudivian/beaver-index-importer
cd beaver-index-importer
# Install the package in editable mode
pip install -e .
Usage
You can run the importer using command-line arguments, a YAML configuration file, or a combination of both. Command-line arguments will always take precedence over settings in the configuration file.
1. Using Command-Line Arguments
The most direct way is to provide all parameters via the command line.
beaver-index-importer --index-file /path/to/your/image_index.jsonl --db-file /path/to/your/images.db
2. Using a Configuration File
For easier management, you can define your settings in a YAML file (e.g., config.yml).
Example config.yml:
index_file: /path/to/your/image_index.jsonl
db_file: /path/to/your/images.db
collection: my_image_collection
mode: upsert
Then, run the importer by pointing it to your config file:
beaver-index-importer --config config.yml
Execution Examples
Here are simple examples demonstrating how to run the importer using different modes and configurations.
| Operation Mode | Purpose | Command Example |
|---|---|---|
upsert |
(Default). Updates existing and inserts new. | beaver-index-importer --index-file index.jsonl --db-file images.db --mode upsert |
rebuild |
Deletes the entire collection before importing. | beaver-index-importer --index-file index.jsonl --db-file images.db --mode rebuild |
insert-only |
Only adds documents that do not exist; ignores existing ones. | beaver-index-importer --index-file index.jsonl --db-file images.db --mode insert-only |
update-only |
Only updates existing documents; ignores new ones. | beaver-index-importer --index-file index.jsonl --db-file images.db --mode update-only |
sync |
Performs upsert and then removes documents from the DB that are missing from the index file. |
beaver-index-importer --index-file index.jsonl --db-file images.db --mode sync |
--collection |
Imports to a collection with a specific name. | beaver-index-importer --index-file index.jsonl --db-file images.db --collection my_photos |
Import Modes
The tool supports five different modes of operation, controlled by the --mode argument (or mode in the config file).
| Mode | Description | Behavior |
|---|---|---|
upsert (Default) |
Update or Insert. | Uses the image path as a unique ID. It updates existing documents and inserts new ones. Ideal for incremental synchronization. |
rebuild |
Clear and Re-insert. | Completely deletes all documents from the collection before importing the new data. Use to start from a clean slate. |
insert-only |
Insert New Documents Only. | Only inserts documents that do not have an existing ID in the database. Existing documents are skipped (not updated). |
update-only |
Update Existing Documents Only. | Only updates documents that already exist in the database. New documents from the index file are skipped (not inserted). |
sync |
Mirror/Synchronize. | Performs an upsert of all index file documents, and then removes any documents from the database that are missing from the current index file. This ensures the database exactly mirrors the index source. |
All Options
| Argument | Short | Description | Default |
|---|---|---|---|
--config |
-c |
Path to a YAML configuration file. | None |
--index-file |
Path to the .jsonl or .pkl index file to import. |
Required | |
--db-file |
Path to the BeaverDB database file to create or update. | Required | |
--collection |
The name of the collection to use inside the database. | images |
|
--mode |
The import strategy: upsert, rebuild, insert-only, update-only, or sync. |
upsert |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file beaver_index_importer-0.1.2.tar.gz.
File metadata
- Download URL: beaver_index_importer-0.1.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0d66365e15fde469a47f6a897faa4d65f742c1c92ddebe01449e11f33fcdd65
|
|
| MD5 |
2e6e44b0999cd385132878772de5c96d
|
|
| BLAKE2b-256 |
279a0b6c588100484c16a468987dc0e4de37e4c159a091b936980d9b9102e5c9
|
File details
Details for the file beaver_index_importer-0.1.2-py3-none-any.whl.
File metadata
- Download URL: beaver_index_importer-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50d8f48d14e6d7b00fd2f94e17384af3496bda3ac38fd87b20024e58209447f3
|
|
| MD5 |
4c6550c87f506f24bc045dd94c849b42
|
|
| BLAKE2b-256 |
da94c76aa83d64fa4505bd0aa3d281c48d2d8d69dfd752d0253faf6e5dd63a0a
|