Skip to main content

A fast and simple dataset series implementation for CKAN

Project description

Tests

ckanext-dataset-series

A fast and simple implementation of Dataset Series.

Dataset Series are loosely defined as collections of datasets that share some common characteristics. These can be related to the nature of the data, scope, publishing process, etc. For instance:

  • Budget data release monthly or yearly
  • Data split by country / region
  • Data big in size split into smaller chunks
  • Geospatial data distributed in grids

Dataset Series can be ordered or unordered.

How does it work?

This extension uses a custom dataset type (dataset_series) to define the parent series entities. These are just datasets and can have any of the standard dataset fields defined.

If the series is ordered, the only mandatory fields they need are the following (shown in the ckanext-scheming schema file definition):

scheming_version: 2
dataset_type: dataset_series

dataset_fields:

# [...]

# Series fields

- field_name: series_order_field
  preset: dataset_series_order

- field_name: series_order_type
  preset: dataset_series_order_type

At the dataset level, the series membership is defined with the in_series field. Datasets can belong to multiple series:

scheming_version: 2
dataset_type: dataset

dataset_fields:

# [...]

# Series fields

- field_name: in_series
  preset: dataset_series_in_series

Once these are in place, datasets can be assigned to a series by setting the in_series field via the API or the UI form.

[!NOTE] Only users that can update the Dataset Series dataset can add dataset members to it

API

If a dataset belongs to a series, a new series_navigation key is added to the response of the package_show action, showing details of the series it belongs to:

{
   "name": "test-dataset-in-series",
   "type": "dataset",
   "series_navigation": [
      {
          "id": "20f41df2-0b50-4b6b-9a75-44eb39411dca",
          "name": "test-dataset-series",
          "title": "Test Dataset series",
      }
  ]
}

If that series is ordered, it will include links to the previous and next dataset on the series (or None if they don't exist):

{
   "name": "test-series-member-2",
   "type": "dataset",
   "series_navigation": [
      {
          "id": "20f41df2-0b50-4b6b-9a75-44eb39411dca",
          "name": "test-dataset-series",
          "title": "Test Dataset series",
          "next": {
              "id": "ce8fb09a-f285-4ba8-952e-46dbde08c509",
              "name": "test-series-member-3",
              "title": "Test series member 3"
              "type": "dataset"
          },
          "previous": {
              "id": "826bd499-40e5-4d92-bfa1-f777775f0d76",
              "name": "test-series-member-1",
              "title": "Test series member 1",
              "type": "dataset"
          }
      }
  ]
}

Querying the series dataset will also return a series_navigation link if ordered, in this case linking to the first and last members:

{
   "name": "test-dataset-series",
   "type": "dataset_series",
   "series_navigation": {
      "count": 4,
 	  "first": {
 		  "id": "826bd499-40e5-4d92-bfa1-f777775f0d76",
 		  "name": "test-series-member-1",
 		  "title": "Test series member 1",
          "type": "dataset"
 	  },
 	  "last": {
 		  "id": "ce8fb09a-f285-4ba8-952e-46dbde08c509",
 		  "name": "test-series-member-3",
 		  "title": "Test series member 3",
          "type": "dataset"
 	  }
   }
}

UI

The extension includes a series_navigation.html snippet that adds a series navigation to the dataset page, with links to the previous and next datasets in the series. The snippet is left deliberately unstyled so sites can tweak it to fit their own design.

For example, you can adjust your package/read.html template to include the snippet in the following way:

{% ckan_extends %}

{% block package_description %}
    {% snippet "package/snippets/series_navigation.html", package=pkg %}

    {{ super() }}
{% endblock %}

[!NOTE] The snippet only works with the first series a dataset belongs to. You can adjust it to show the navigation for other series if needed

[!NOTE] TODO

  • Series page showing a navigation of the member datasets

Requirements

If your extension works across different versions you can add the following table:

Compatibility with core CKAN versions:

CKAN version Compatible?
2.9 not tested
2.10 yes
2.11 yes

Installation

To install ckanext-dataset-series:

  1. Activate your CKAN virtual environment, for example:

    . /usr/lib/ckan/default/bin/activate
    
  2. Clone the source and install it on the virtualenv

    git clone https://github.com/ckan/ckanext-dataset-series.git
    cd ckanext-dataset-series
    pip install -e .
    pip install -r requirements.txt
    
  3. Add dataset_series to the ckan.plugins setting in your CKAN config file (by default the config file is located at /etc/ckan/default/ckan.ini).

  4. Restart CKAN.

Developer installation

To install ckanext-dataset-series for development, activate your CKAN virtualenv and do:

git clone https://github.com//ckanext-dataset-series.git
cd ckanext-dataset-series
pip install -e .
pip install -r dev-requirements.txt

Tests

To run the tests, do:

pytest --ckan-ini=test.ini

License

AGPL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ckanext_dataset_series-0.1.1.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ckanext_dataset_series-0.1.1-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file ckanext_dataset_series-0.1.1.tar.gz.

File metadata

  • Download URL: ckanext_dataset_series-0.1.1.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ckanext_dataset_series-0.1.1.tar.gz
Algorithm Hash digest
SHA256 20321404ece70bb464b46b8780cc204a174097d17cf91ddd2c62567b40fa35a1
MD5 1b7de66a506d38c4b868bd6577fba8da
BLAKE2b-256 5c493c43cac1e929ad8b72be4214141174a2d3c409b20fea6cdc10dc48286582

See more details on using hashes here.

Provenance

The following attestation bundles were made for ckanext_dataset_series-0.1.1.tar.gz:

Publisher: publish-pypi.yml on ckan/ckanext-dataset-series

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ckanext_dataset_series-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ckanext_dataset_series-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e08b2dbc2f46605892a7b6e1be68d6fa1fbd6356fb0e7aaa3aad216835ac4fb
MD5 91f3defa8225950780c22355d634a042
BLAKE2b-256 9e118170be87406abdc231684bc0fe4751c32adbf7f698c6f9286c5dabf75834

See more details on using hashes here.

Provenance

The following attestation bundles were made for ckanext_dataset_series-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on ckan/ckanext-dataset-series

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page