Skip to main content

ckanext-aiextract

CI PyPI License: AGPL v3

A CKAN extension that automates feeding information from documents into AI applications.

Whenever a document resource (by default: PDF) is created or updated, the extension enqueues a background job that sends the file to a configurable text-extraction service and uploads the extracted content back to the dataset. A new tab in the dataset view shows the extraction status and lets users trigger or delete extractions manually.

Requirements

CKAN version Compatible?
2.9 and earlier no
2.10 yes
2.11 yes
  • Python 3.10 or newer
  • CKAN background jobs worker (ckan jobs worker) running
  • A text-extraction HTTP endpoint that accepts multipart file uploads and returns a file response

Installation

  1. Activate your CKAN virtual environment, for example:

    . /usr/lib/ckan/default/bin/activate
    
  2. Install the extension from PyPI:

    pip install ckanext-aiextract
    
  3. Add aiextract to the ckan.plugins setting in your CKAN config file (by default /etc/ckan/default/ckan.ini).

  4. Restart CKAN and the background jobs worker.

Development installation

git clone git@github.com:MBueschelberger/ckanext-aiextract.git
cd ckanext-aiextract
pip install -e ".[dev]"
pre-commit install

Unit tests need CKAN 2.11 installed (pip install "ckan[requirements]==2.11.*"), but no CKAN config, database, Solr or Redis:

pytest

Config settings

Option Default Description
ckanext.aiextract.extract_url "" URL of the text-extraction API endpoint
ckanext.aiextract.ckan_token "" API token used by background jobs. Without it, only public datasets can be processed
ckanext.aiextract.db_url value of sqlalchemy.url Database for the extension's job table
ckanext.aiextract.formats pdf Space-separated list of resource formats to process
ckanext.aiextract.job_timeout 1800 Seconds after which a pending task is considered stale
ckanext.aiextract.ssl_verify true Verify TLS certificates for outgoing requests. Set to false only for development setups with self-signed certificates
ckanext.aiextract.callback_base_url value of ckan.site_url Base URL background jobs use to reach CKAN: status callbacks (aiextract_hook) and downloads of files hosted by this CKAN. In Docker setups set it to the internal address (e.g. http://ckan:5000) so jobs bypass the public reverse proxy / WAF

Status callbacks of a job use a 30 s timeout and are not retried on HTTP errors (e.g. 504); a failed callback is logged and the job continues.

In the official CKAN Docker images, every option can also be set as an environment variable using the CKANINI__ prefix, e.g.:

CKANINI__CKANEXT__AIEXTRACT__EXTRACT_URL=https://extract.example.org/api/extract
CKANINI__CKANEXT__AIEXTRACT__CKAN_TOKEN=<BACKGROUND_JOBS_API_TOKEN>
CKANINI__CKANEXT__AIEXTRACT__JOB_TIMEOUT=1800
CKANINI__CKANEXT__AIEXTRACT__SSL_VERIFY=false   # development only
CKANINI__CKANEXT__AIEXTRACT__CALLBACK_BASE_URL=http://ckan:5000

Operations

Versions before 1.1.0 could make a CKAN worker block itself on a task_status row lock when a PDF was uploaded or updated while an old extraction task existed. Independent of the fix, the following safeguards are recommended:

Measure Effect
uWSGI harakiri of a few minutes (e.g. UWSGI_HARAKIRI=120) instead of hours A hanging request is killed after 2 min
More uWSGI capacity, e.g. -p 4 --threads 4 A single hanging request no longer blocks the whole instance
PostgreSQL: ALTER DATABASE <ckan-db> SET idle_in_transaction_session_timeout = '5min'; Open transactions holding locks are terminated automatically
Docker autoheal (e.g. willfarrell/autoheal) or a healthcheck with restart Docker does not restart unhealthy containers on its own

One-time cleanup of stuck and legacy dataset-level tasks (before or after updating to 1.1.0):

-- inspect
SELECT id, entity_id, entity_type, state, last_updated
FROM task_status
WHERE task_type = 'aiextract'
  AND (entity_type = 'package' OR state IN ('running', 'pending', 'submitting'));

-- delete
DELETE FROM task_status
WHERE task_type = 'aiextract'
  AND (entity_type = 'package'
       OR (state IN ('running', 'pending', 'submitting')
           AND last_updated < now() - interval '1 hour'));

Releasing

Versions follow MAJOR.MINOR.PATCH and are managed with bumpver:

bumpver update --patch   # or --minor / --major

This updates pyproject.toml, commits, tags and pushes. The pushed tag triggers the CI workflow, which builds the package and publishes it to PyPI via Trusted Publishing.

Authors

  • Thomas Hanke (@ThHanke) — main author

Maintainers

License

This project is licensed under the GNU Affero General Public License v3.0 or later — see LICENSE.

Metadata

Release files for ckanext-aiextract 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckanext-aiextract 1.1.0
File Size Uploaded Provenance Actions
ckanext_aiextract-1.1.0.tar.gz 50.3 kB With provenance Details for ckanext_aiextract-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ckanext-aiextract 1.1.0
File Interpreter ABI Platform Actions
ckanext_aiextract-1.1.0-py3-none-any.whl Python 3 none any Details for ckanext_aiextract-1.1.0-py3-none-any.whl

Total release size: 97.6 kB

Release files / ckanext_aiextract-1.1.0.tar.gz

Download URL ckanext_aiextract-1.1.0.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
54a5f7e69cb11ef01ee26666e4c71aba9d906a0c6ecae2b552e1e21e45274ba2
BLAKE2b-256 checksum
How to use checksums
cb98f3de7fc0759972f235bbe93707438e4743625f36a487a567075763debb09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / ckanext_aiextract-1.1.0-py3-none-any.whl

Download URL ckanext_aiextract-1.1.0-py3-none-any.whl
Size 47.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a78c917df8ed5660428b3ee45610617998523366c350adb0556679ffcaec35f
BLAKE2b-256 checksum
How to use checksums
39bdcdeee80cb6b24728e7595a237e454cc875278ff3a1b6a17e1d871bea0949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for ckanext-aiextract 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ckanext_aiextract-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page