Kuha Client is used to submit records to Kuha Document Store. Kuha Client is written in Python and uses HTTP to communicate with Document Store.
- Support for DDI 3.1, DDI 2.5 and DDI 1.2.2 metadata standards.
- Import records to Document Store.
- Update records already stored in Document Store.
- Delete records in Document Store.
- Batch process DDI files by recursing into directories:
- Option to remove records from Document Store not found in the current batch.
- Option to keep track of previously processed files and bypass processing if modification times have not changed.
Dependencies & requirements¶
Versions spesified here are the ones that the software has been developed with. Newer versions may be compatible.
- Python 3.5.
- Recommended: python3-venv 3.5.1
Kuha Common is a library used with Kuha2 software. It can be obtained from https://bitbucket.org/tietoarkisto/kuha_common
- kuha_common (License: EUPL)
Kuha Client is available under the EUPL. See LICENSE.txt for the full license.
Most common configuration options are described here. Use
--help to print all
Required positional argument. Absolute path to file or directory. Repeat to process multiple paths.
Show help and exit.
Only for upsert and import run. Limits the import to a spesific document type. Valid values are
Noneto import all document types. Defaults to
Required. Full URL to Document Store, for example
http://localhost:6001/v0. May also be controlled by setting environment variable:
Only for upsert and import run. Store processed files to file log. Compare modification times on subsequent run. Bypass if modification times have not changed.
Only for upsert run. Remove records from Document Store not present in current batch.
Running the program¶
If installed to a Python virtual environment, the environment must be activated before running the program.
Import records to Document Store by scanning a directory tree for .xml files to submit and create a file-log to keep track of processed files:
python -m kuha_client.kuha_import --file-log-path=file_log /path/to/directory
Upsert records (insert and update) to Document Store by scanning a directory tree for .xml files and comparing found files to the ones store in file-log. If a file’s modification time is newer than the one stored in file-log, the file gets processed. When using the –remove-absent flag, any ID found from document store, but not from the current batch, gets removed:
python -m kuha_client.kuha_upsert --file-log-path=file_log --remove-absent /path/to/directory
Delete record from collection:
python -m kuha_client.kuha_delete studies 5af94ff06fb71d7646160bd4
Delete all records from collection:
python -m kuha_client.kuha_delete studies ALL
Delete all records from all collections:
python -m kuha_client.kuha_delete ALL ALL