A package containing common components for the roocs project
Project description
roocs-utils
A package containing common components for the roocs project
Free software: BSD - see LICENSE file in top-level package directory
Documentation: https://roocs-utils.readthedocs.io.
Features
Intake Catalog
1. Data Catalog
The module roocs_utils.catalog_maker provides tools for writing data catalogs of the known data holdings in a csv format, described by a YAML file.
For each project in roocs_utils/etc/roocs.ini there are options to set the file paths for the inputs and outputs of this catalog maker. A list of datasets to include needs to be provided. The path to this list for each project can be set in roocs_utils/etc/roocs.ini. The datasets in this list must be what you want in the ds_id column of the csv file.
The data catalog is created using a database backend to store the results of the scans, from which the csv and YAML files will be created. For this, a posgresql database is required. Once you have a database, you need to export an environment variable called $ABCUNIT_DB_SETTINGS:
$ export ABCUNIT_DB_SETTINGS="dbname=<name> user=<user> host=<host> password=<pwd>"
The table created will be named after the porject you are creating a catalog for in the format <project_name>_catalog_results e.g. c3s_cmip6_catalog_results
Note when using the catalog maker, the dependencies abcunit-backend and psycopg2 are required. These must be pip installed manually.
$ pip install abcunit-backend
Creating batches
Once the list of datasets is collated a number of batches must be created:
$ python roocs_utils/catalog_maker/cli.py create-batches -p c3s-cmip6
The option -p is required to specify the project.
Creating catalog entries
Once the batches are created, the catalog maker can be run - either locally or on lotus. The settings for how many datasets to be included in a batch and the maximum duration of each job on lotus can also be changed in roocs_utils/etc/roocs.ini.
Each batch can be run idependently, e.g. running batch 1 locally:
$ python roocs_utils/catalog_maker/cli.py run -p c3s-cmip6 -b 1 -r local
or running all batches on lotus:
$ python roocs_utils/catalog_maker/cli.py run -p c3s-cmip6 -r lotus
This creates a table in the database containing an ordered dictionary of the entry for each file in each dataset if successful, or the error traceback if there is an Exception raised.
Viewing entries and errors
To view the records:
$ python roocs_utils/catalog_maker/cli.py list -p c3s-cmip6
With many entries, this may take a while.
To just get a count of how many files have been scanned:
$ python roocs_utils/catalog_maker/cli.py list -p c3s-cmip6 -c
To see any errors:
$ python roocs_utils/catalog_maker/cli.py show-errors -p c3s-cmip6
To see just a count of errors:
$ python roocs_utils/catalog_maker/cli.py show-errors -p c3s-cmip6 -c
Each count will show how many files and how many datasets have been successful/failed.
The list count will also show the total numbers of datasets/files in the database - including errors. The error count will show whether there are any datasets that have files which have succeeded and failed i.e. that are partially scanned.
Writing to CSV
The final command is to write the entries to a csv file.
$ python roocs_utils/catalog_maker/cli.py write -p c3s-cmip6
The csv file will be generated in the csv_dir specified in roocs_utils/etc/roocs.ini and will have the name “{project}_{version_stamp}.csv”. e.g. c3s-cmip6_v20210414.csv
A yaml file will be created the catalog_dir specified in roocs_utils/etc/roocs.ini. It will have the name c3s.yml and will contain the below for each project scanned and which is using the same catalog_dir:
sources:
c3s-cmip6:
args:
urlpath:
cache:
- argkey: urlpath
type: file
description: c3s-cmip6 datasets
driver: intake.source.csv.CSVSource
metadata:
last_updated:
urlpath and last_updated for a project will be updated very time the csv file is written for the project.
Deleting the table of results
In order to delete all entries in the table of results
$ python roocs_utils/catalog_maker/cli.py clean -p c3s-cmip6
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Cookiecutter: https://github.com/audreyr/cookiecutter
cookiecutter-pypackage: https://github.com/audreyr/cookiecutter-pypackage
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file roocs_utils-0.4.2.tar.gz
.
File metadata
- Download URL: roocs_utils-0.4.2.tar.gz
- Upload date:
- Size: 49.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ad44ec2f98145ad6df387d12114a6e4f47cc22ff1f0b1755d82f77b49990d35 |
|
MD5 | 490b0ad7ad97d3cdc27bcb7a1c3a44c0 |
|
BLAKE2b-256 | 54587d85d14e6f98b9ae3bc502f8b376b9f8bfe817b83cc4de6003d21a611f6e |
Provenance
File details
Details for the file roocs_utils-0.4.2-py2.py3-none-any.whl
.
File metadata
- Download URL: roocs_utils-0.4.2-py2.py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7efb822a6b7678e31dd529913a6e67c071167c07486ea4b4786b482ecf65e31c |
|
MD5 | ddd8b7dab65bda50c20695dd991218da |
|
BLAKE2b-256 | 93033dc28fb793e1813b059be4cbd3e83b21bb1bc042686661249a3dea106fa6 |