ckanext-nhm


Nameckanext-nhm JSON
Version 7.1.1 PyPI version JSON
download
home_pageNone
SummaryA CKAN extension for the Natural History Museum's Data Portal.
upload_time2025-08-11 12:52:15
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseGPL-3.0-or-later
keywords ckan data nhm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <!--header-start-->
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://data.nhm.ac.uk/images/nhm_logo.svg">
  <source media="(prefers-color-scheme: light)" srcset="https://data.nhm.ac.uk/images/nhm_logo_black.svg">
  <img alt="The Natural History Museum logo." src="https://data.nhm.ac.uk/images/nhm_logo_black.svg" align="left" width="150px" height="100px" hspace="40">
</picture>

# ckanext-nhm

[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-nhm/tests.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-nhm/actions/workflows/tests.yml)
[![Coveralls](https://img.shields.io/coveralls/github/NaturalHistoryMuseum/ckanext-nhm/main?style=flat-square)](https://coveralls.io/github/NaturalHistoryMuseum/ckanext-nhm)
[![CKAN](https://img.shields.io/badge/ckan-2.9.7-orange.svg?style=flat-square)](https://github.com/ckan/ckan)
[![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/)
[![Docs](https://img.shields.io/readthedocs/ckanext-nhm?style=flat-square)](https://ckanext-nhm.readthedocs.io)
[![Specimen records](https://img.shields.io/badge/dynamic/json.svg?color=brightgreen&label=specimens&query=%24.result.total&suffix=%20records&url=https%3A%2F%2Fdata.nhm.ac.uk%2Fapi%2F3%2Faction%2Fdatastore_search%3Fresource_id%3D05ff2255-c38a-40c9-b657-4ccb55ab2feb&style=flat-square)](https://data.nhm.ac.uk/dataset/collection-specimens/resource/05ff2255-c38a-40c9-b657-4ccb55ab2feb)

_A CKAN extension for the Natural History Museum's [Data Portal](https://data.nhm.ac.uk)._

<!--header-end-->

# Overview

<!--overview-start-->
This extension provides theming and specific functionality for the Natural History Museum's [Data Portal](https://data.nhm.ac.uk).

The codebase shows how to implement various plugins created by the Museum's developers; notably our new [ElasticSearch datastore](https://github.com/NaturalHistoryMuseum/ckanext-versioned-datastore) with versioned records.

<!--overview-end-->

# Installation

<!--installation-start-->
Path variables used below:
- `$INSTALL_FOLDER` (i.e. where CKAN is installed), e.g. `/usr/lib/ckan/default`
- `$CONFIG_FILE`, e.g. `/etc/ckan/default/development.ini`

## Pre-install setup

This package depends on `ckanext-dcat==1.3.0`, but since that isn't available on PyPI it's not listed in the package dependencies.

Install it with:
```shell
pip install git+https://github.com/ckan/ckanext-dcat@v1.3.0#egg=ckanext-dcat
```

## Installing from PyPI

```shell
pip install ckanext-nhm
```

## Installing from source

1. Clone the repository into the `src` folder:
   ```shell
   cd $INSTALL_FOLDER/src
   git clone https://github.com/NaturalHistoryMuseum/ckanext-nhm.git
   ```

2. Activate the virtual env:
   ```shell
   . $INSTALL_FOLDER/bin/activate
   ```

3. Install via pip:
   ```shell
   pip install $INSTALL_FOLDER/src/ckanext-nhm
   ```

### Installing in editable mode

Installing from a `pyproject.toml` in editable mode (i.e. `pip install -e`) requires `setuptools>=64`; however, CKAN 2.9 requires `setuptools==44.1.0`. See [our CKAN fork](https://github.com/NaturalHistoryMuseum/ckan) for a version of v2.9 that uses an updated setuptools if this functionality is something you need.

## Post-install setup

1. Add 'nhm' to the list of plugins in your `$CONFIG_FILE`:
   ```ini
   ckan.plugins = ... nhm
   ```

2. Install `lessc` globally:
   ```shell
   npm install -g "less@~4.1"
   ```

<!--installation-end-->

# Configuration

<!--configuration-start-->


<!--configuration-end-->

# Usage

<!--usage-start-->
## Actions

### `record_show`
Retrieve an individual record.

```python
from ckan.plugins import toolkit

data_dict = {
                'resource_id': RESOURCE_ID,
                'record_id': RECORD_ID,
                'version': OPTIONAL_RECORD_VERSION
            }

toolkit.get_action('record_show')(
    context,
    data_dict
)
```

### `object_rdf`
Get record RDF from its occurrence ID.

```python
from ckan.plugins import toolkit

data_dict = {
                'uuid': OCCURRENCE_ID,
                'version': OPTIONAL_RECORD_VERSION
            }

toolkit.get_action('object_rdf')(
    context,
    data_dict
)
```

## Commands

### `create-dataset-vocabulary`
Ensures the default dataset vocabulary and categories exists.

```bash
ckan -c $CONFIG_FILE nhm create-dataset-vocabulary
```

### `add-dataset-category`
Adds the given category to the dataset category vocabulary.

```bash
ckan -c $CONFIG_FILE nhm delete-dataset-category $NAME
```

### `delete-dataset-category`
Deletes the given dataset category from the vocabulary.

```bash
ckan -c $CONFIG_FILE nhm create-dataset-vocabulary $NAME
```

### `replace-resource-file`
Replaces the file associated with `$RESOURCE_ID` with `$PATH`, e.g. to replace a small dummy file
with a large one that was too big to upload initially.

```bash
ckan -c $CONFIG_FILE nhm replace-resource-file $RESOURCE_ID $PATH
```

<!--usage-end-->

# Testing

<!--testing-start-->
There is a Docker compose configuration available in this repository to make it easier to run tests. The ckan image uses the Dockerfile in the `docker/` folder.

To run the tests against ckan 2.9.x on Python3:

1. Build the required images:
   ```shell
   docker compose build
   ```

2. Then run the tests.
   The root of the repository is mounted into the ckan container as a volume by the Docker compose
   configuration, so you should only need to rebuild the ckan image if you change the extension's
   dependencies.
   ```shell
   docker compose run --rm ckan
   ```

<!--testing-end-->

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ckanext-nhm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "CKAN, data, nhm",
    "author": null,
    "author_email": "Natural History Museum <data@nhm.ac.uk>",
    "download_url": "https://files.pythonhosted.org/packages/41/13/bb6e8fcfdfb6bfc22d04119cbeaf738b96e2afa4022f2559064e562013b0/ckanext_nhm-7.1.1.tar.gz",
    "platform": null,
    "description": "<!--header-start-->\n<picture>\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://data.nhm.ac.uk/images/nhm_logo.svg\">\n  <source media=\"(prefers-color-scheme: light)\" srcset=\"https://data.nhm.ac.uk/images/nhm_logo_black.svg\">\n  <img alt=\"The Natural History Museum logo.\" src=\"https://data.nhm.ac.uk/images/nhm_logo_black.svg\" align=\"left\" width=\"150px\" height=\"100px\" hspace=\"40\">\n</picture>\n\n# ckanext-nhm\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-nhm/tests.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-nhm/actions/workflows/tests.yml)\n[![Coveralls](https://img.shields.io/coveralls/github/NaturalHistoryMuseum/ckanext-nhm/main?style=flat-square)](https://coveralls.io/github/NaturalHistoryMuseum/ckanext-nhm)\n[![CKAN](https://img.shields.io/badge/ckan-2.9.7-orange.svg?style=flat-square)](https://github.com/ckan/ckan)\n[![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/)\n[![Docs](https://img.shields.io/readthedocs/ckanext-nhm?style=flat-square)](https://ckanext-nhm.readthedocs.io)\n[![Specimen records](https://img.shields.io/badge/dynamic/json.svg?color=brightgreen&label=specimens&query=%24.result.total&suffix=%20records&url=https%3A%2F%2Fdata.nhm.ac.uk%2Fapi%2F3%2Faction%2Fdatastore_search%3Fresource_id%3D05ff2255-c38a-40c9-b657-4ccb55ab2feb&style=flat-square)](https://data.nhm.ac.uk/dataset/collection-specimens/resource/05ff2255-c38a-40c9-b657-4ccb55ab2feb)\n\n_A CKAN extension for the Natural History Museum's [Data Portal](https://data.nhm.ac.uk)._\n\n<!--header-end-->\n\n# Overview\n\n<!--overview-start-->\nThis extension provides theming and specific functionality for the Natural History Museum's [Data Portal](https://data.nhm.ac.uk).\n\nThe codebase shows how to implement various plugins created by the Museum's developers; notably our new [ElasticSearch datastore](https://github.com/NaturalHistoryMuseum/ckanext-versioned-datastore) with versioned records.\n\n<!--overview-end-->\n\n# Installation\n\n<!--installation-start-->\nPath variables used below:\n- `$INSTALL_FOLDER` (i.e. where CKAN is installed), e.g. `/usr/lib/ckan/default`\n- `$CONFIG_FILE`, e.g. `/etc/ckan/default/development.ini`\n\n## Pre-install setup\n\nThis package depends on `ckanext-dcat==1.3.0`, but since that isn't available on PyPI it's not listed in the package dependencies.\n\nInstall it with:\n```shell\npip install git+https://github.com/ckan/ckanext-dcat@v1.3.0#egg=ckanext-dcat\n```\n\n## Installing from PyPI\n\n```shell\npip install ckanext-nhm\n```\n\n## Installing from source\n\n1. Clone the repository into the `src` folder:\n   ```shell\n   cd $INSTALL_FOLDER/src\n   git clone https://github.com/NaturalHistoryMuseum/ckanext-nhm.git\n   ```\n\n2. Activate the virtual env:\n   ```shell\n   . $INSTALL_FOLDER/bin/activate\n   ```\n\n3. Install via pip:\n   ```shell\n   pip install $INSTALL_FOLDER/src/ckanext-nhm\n   ```\n\n### Installing in editable mode\n\nInstalling from a `pyproject.toml` in editable mode (i.e. `pip install -e`) requires `setuptools>=64`; however, CKAN 2.9 requires `setuptools==44.1.0`. See [our CKAN fork](https://github.com/NaturalHistoryMuseum/ckan) for a version of v2.9 that uses an updated setuptools if this functionality is something you need.\n\n## Post-install setup\n\n1. Add 'nhm' to the list of plugins in your `$CONFIG_FILE`:\n   ```ini\n   ckan.plugins = ... nhm\n   ```\n\n2. Install `lessc` globally:\n   ```shell\n   npm install -g \"less@~4.1\"\n   ```\n\n<!--installation-end-->\n\n# Configuration\n\n<!--configuration-start-->\n\n\n<!--configuration-end-->\n\n# Usage\n\n<!--usage-start-->\n## Actions\n\n### `record_show`\nRetrieve an individual record.\n\n```python\nfrom ckan.plugins import toolkit\n\ndata_dict = {\n                'resource_id': RESOURCE_ID,\n                'record_id': RECORD_ID,\n                'version': OPTIONAL_RECORD_VERSION\n            }\n\ntoolkit.get_action('record_show')(\n    context,\n    data_dict\n)\n```\n\n### `object_rdf`\nGet record RDF from its occurrence ID.\n\n```python\nfrom ckan.plugins import toolkit\n\ndata_dict = {\n                'uuid': OCCURRENCE_ID,\n                'version': OPTIONAL_RECORD_VERSION\n            }\n\ntoolkit.get_action('object_rdf')(\n    context,\n    data_dict\n)\n```\n\n## Commands\n\n### `create-dataset-vocabulary`\nEnsures the default dataset vocabulary and categories exists.\n\n```bash\nckan -c $CONFIG_FILE nhm create-dataset-vocabulary\n```\n\n### `add-dataset-category`\nAdds the given category to the dataset category vocabulary.\n\n```bash\nckan -c $CONFIG_FILE nhm delete-dataset-category $NAME\n```\n\n### `delete-dataset-category`\nDeletes the given dataset category from the vocabulary.\n\n```bash\nckan -c $CONFIG_FILE nhm create-dataset-vocabulary $NAME\n```\n\n### `replace-resource-file`\nReplaces the file associated with `$RESOURCE_ID` with `$PATH`, e.g. to replace a small dummy file\nwith a large one that was too big to upload initially.\n\n```bash\nckan -c $CONFIG_FILE nhm replace-resource-file $RESOURCE_ID $PATH\n```\n\n<!--usage-end-->\n\n# Testing\n\n<!--testing-start-->\nThere is a Docker compose configuration available in this repository to make it easier to run tests. The ckan image uses the Dockerfile in the `docker/` folder.\n\nTo run the tests against ckan 2.9.x on Python3:\n\n1. Build the required images:\n   ```shell\n   docker compose build\n   ```\n\n2. Then run the tests.\n   The root of the repository is mounted into the ckan container as a volume by the Docker compose\n   configuration, so you should only need to rebuild the ckan image if you change the extension's\n   dependencies.\n   ```shell\n   docker compose run --rm ckan\n   ```\n\n<!--testing-end-->\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A CKAN extension for the Natural History Museum's Data Portal.",
    "version": "7.1.1",
    "project_urls": {
        "changelog": "https://github.com/NaturalHistoryMuseum/ckanext-nhm/blob/main/CHANGELOG.md",
        "repository": "https://github.com/NaturalHistoryMuseum/ckanext-nhm"
    },
    "split_keywords": [
        "ckan",
        " data",
        " nhm"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "378c982ac16092414383d7530e97ff892ced5fd1419cf1446f6089395a0497c8",
                "md5": "9acd471a1ef7b870f93bbc2eaaa430c7",
                "sha256": "87b590fbbb6c80381238cd31a6a66619575c7df6a721d8f59a541af0b84951fe"
            },
            "downloads": -1,
            "filename": "ckanext_nhm-7.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9acd471a1ef7b870f93bbc2eaaa430c7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 55871430,
            "upload_time": "2025-08-11T12:52:12",
            "upload_time_iso_8601": "2025-08-11T12:52:12.151871Z",
            "url": "https://files.pythonhosted.org/packages/37/8c/982ac16092414383d7530e97ff892ced5fd1419cf1446f6089395a0497c8/ckanext_nhm-7.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4113bb6e8fcfdfb6bfc22d04119cbeaf738b96e2afa4022f2559064e562013b0",
                "md5": "9bc67570a556d970b1aac77f657dd689",
                "sha256": "be375da0902476a4f9b821558079bfc9d090ebb18cba8b5e4108d838c38f11e9"
            },
            "downloads": -1,
            "filename": "ckanext_nhm-7.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9bc67570a556d970b1aac77f657dd689",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 55145148,
            "upload_time": "2025-08-11T12:52:15",
            "upload_time_iso_8601": "2025-08-11T12:52:15.598632Z",
            "url": "https://files.pythonhosted.org/packages/41/13/bb6e8fcfdfb6bfc22d04119cbeaf738b96e2afa4022f2559064e562013b0/ckanext_nhm-7.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-11 12:52:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NaturalHistoryMuseum",
    "github_project": "ckanext-nhm",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "ckanext-nhm"
}
        
Elapsed time: 4.07469s