ckanext-nhm


Nameckanext-nhm JSON
Version 6.9.6 PyPI version JSON
download
home_pageNone
SummaryA CKAN extension for the Natural History Museum's Data Portal.
upload_time2024-08-20 14:23:03
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-->
<img src="https://data.nhm.ac.uk/images/nhm_logo.svg" align="left" width="150px" height="100px" hspace="40"/>

# ckanext-nhm

[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-nhm/main.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-nhm/actions/workflows/main.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 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/ee/08/d7422ae065f3d229560193596142aad730589548d79d634aed2c1a0d98ac/ckanext_nhm-6.9.6.tar.gz",
    "platform": null,
    "description": "<!--header-start-->\n<img src=\"https://data.nhm.ac.uk/images/nhm_logo.svg\" align=\"left\" width=\"150px\" height=\"100px\" hspace=\"40\"/>\n\n# ckanext-nhm\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-nhm/main.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-nhm/actions/workflows/main.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 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": "6.9.6",
    "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": "",
            "digests": {
                "blake2b_256": "f949b652d9a03d8bc12b8ad748d7b1b978b842b3574a51c679e0bbc11d5c78af",
                "md5": "ccb67da3c84efd9c2296c00bbb81375e",
                "sha256": "7e4e6285e50190c0ae1c23ee54e9f4a5f2baf8c0c5287489d915cf687b3bae51"
            },
            "downloads": -1,
            "filename": "ckanext_nhm-6.9.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ccb67da3c84efd9c2296c00bbb81375e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 55781162,
            "upload_time": "2024-08-20T14:22:58",
            "upload_time_iso_8601": "2024-08-20T14:22:58.151414Z",
            "url": "https://files.pythonhosted.org/packages/f9/49/b652d9a03d8bc12b8ad748d7b1b978b842b3574a51c679e0bbc11d5c78af/ckanext_nhm-6.9.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee08d7422ae065f3d229560193596142aad730589548d79d634aed2c1a0d98ac",
                "md5": "ab138407a052eef04a46a797af2adb2b",
                "sha256": "4854346f97ad54faae68a7f35649157a099999a1133aade3da8331e2c3e68d1b"
            },
            "downloads": -1,
            "filename": "ckanext_nhm-6.9.6.tar.gz",
            "has_sig": false,
            "md5_digest": "ab138407a052eef04a46a797af2adb2b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 55055816,
            "upload_time": "2024-08-20T14:23:03",
            "upload_time_iso_8601": "2024-08-20T14:23:03.183252Z",
            "url": "https://files.pythonhosted.org/packages/ee/08/d7422ae065f3d229560193596142aad730589548d79d634aed2c1a0d98ac/ckanext_nhm-6.9.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-20 14:23:03",
    "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: 0.84100s