ckanext-nhm


Nameckanext-nhm JSON
Version 6.6.1 PyPI version JSON
download
home_pageNone
SummaryA CKAN extension for the Natural History Museum's Data Portal.
upload_time2024-03-25 11:12:10
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/f0/d1/d5a9b9bfbd630b7930d32c29fd702d00787d1bd5c55e510ae24299a7d279/ckanext-nhm-6.6.1.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.6.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": "",
            "digests": {
                "blake2b_256": "0e40b36a5f476f937ea2f5243a4fd26d84996e4f3e88376aa88c0ee520435205",
                "md5": "19bda3e6923600a6d9c14861ef87d5eb",
                "sha256": "bf9ab065a0b59df8ff61f8bc21e111bfc1b52400dbb3ead6de6a5a501d49194f"
            },
            "downloads": -1,
            "filename": "ckanext_nhm-6.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "19bda3e6923600a6d9c14861ef87d5eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 56300313,
            "upload_time": "2024-03-25T11:12:05",
            "upload_time_iso_8601": "2024-03-25T11:12:05.474242Z",
            "url": "https://files.pythonhosted.org/packages/0e/40/b36a5f476f937ea2f5243a4fd26d84996e4f3e88376aa88c0ee520435205/ckanext_nhm-6.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0d1d5a9b9bfbd630b7930d32c29fd702d00787d1bd5c55e510ae24299a7d279",
                "md5": "673b9ac8258d4ceac951aef7886f45b3",
                "sha256": "d65cd9cc8fc1e2a626ad3fa058e687026b3f96253585a641483388af9892bb2b"
            },
            "downloads": -1,
            "filename": "ckanext-nhm-6.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "673b9ac8258d4ceac951aef7886f45b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 55572781,
            "upload_time": "2024-03-25T11:12:10",
            "upload_time_iso_8601": "2024-03-25T11:12:10.556907Z",
            "url": "https://files.pythonhosted.org/packages/f0/d1/d5a9b9bfbd630b7930d32c29fd702d00787d1bd5c55e510ae24299a7d279/ckanext-nhm-6.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 11:12:10",
    "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.23907s