Templates for OpenRefine batch processing (import, transform, export) using a task runner and a Python client.
Go to file
Felix Lohmeier a6d455580a 💡 add some more source code comments 2021-02-25 12:33:27 +01:00
example-doaj 💡 add some more source code comments 2021-02-25 12:33:27 +01:00
example-duplicates 💡 add some more source code comments 2021-02-25 12:33:27 +01:00
example-powerhouse 💡 add some more source code comments 2021-02-25 12:33:27 +01:00
.gitignore 💡 add some more source code comments 2021-02-25 12:33:27 +01:00
LICENSE Initial commit 2021-02-18 17:03:07 +01:00
README.md 💡 add some more source code comments 2021-02-25 12:33:27 +01:00
Taskfile.yml 🐛 fix quoting in check task 2021-02-24 21:59:56 +01:00

README.md

OpenRefine Task Runner (💎+🤖)

Codacy Badge

Templates for OpenRefine batch processing (import, transform, export) using the task runner go-task and the openrefine-client to control OpenRefine via its HTTP API.

Features

  • run tasks in parallel
  • basic error handling by monitoring the OpenRefine server log
  • dedicated OpenRefine instances for each task (your existing OpenRefine data will not be touched)
  • prevent unnecessary work by fingerprinting generated files and their sources
  • the openrefine-client used here supports many core features of OpenRefine:
    • import CSV, TSV, line-based TXT, fixed-width TXT, JSON or XML (and specify input options)
    • apply undo/redo history from given JSON file(s)
    • export to CSV, TSV, HTML, XLS, XLSX, ODS
    • templating export to additional formats like JSON or XML
    • works with OpenRefine 2.7, 2.8, 3.0, 3.1, 3.2, 3.3, 3.4 and 3.4.1
  • tasks are easy to extend with additional commands (e.g. to download input data or validate results)

Typical workflow

Step 1: Do some experiments with your data (or parts of it) in the graphical user interface of OpenRefine. If you are fine with all transformation rules, extract the json code and save it as file (e.g. dedup.json).

Step 2: Configure a task to automate importing your data set, applying the json file and exporting to the required output format.

Possible automation benefits:

  • When you receive updated data (in the same structure), you just need to drop the file and start the task like this:

    task example-doaj
    
  • The entire data processing (including options during import) becomes reproducible. The task configuration file can also be used for documentation through source code comments.

  • Metadata experts can use OpenRefine's graphical interface and IT staff can incorporate the created transformation rules into regular data processing flows.

Requirements

  • GNU/Linux (tested with Fedora 32)
  • JAVA 8+ (for OpenRefine)

Install

  1. Clone this git repository

    git clone https://github.com/opencultureconsulting/openrefine-task-runner.git
    cd openrefine-task-runner
    
  2. Install Task 3.2.2

    a) RPM-based (Fedora, CentOS, SLES, etc.)

    wget https://github.com/go-task/task/releases/download/v3.2.2/task_linux_amd64.rpm
    sudo dnf install ./task_linux_amd64.rpm && rm task_linux_amd64.rpm
    

    b) DEB-based (Debian, Ubuntu etc.)

    wget https://github.com/go-task/task/releases/download/v3.2.2/task_linux_amd64.deb
    sudo apt install ./task_linux_amd64.deb && rm task_linux_amd64.deb
    
  3. Run install task to download OpenRefine 3.4.1 and openrefine-client 0.3.10

    task install
    

Usage

  • Run all tasks in parallel

    task
    
  • Run a specific task

    task example-duplicates:main
    
  • Run some tasks in parallel

    task --parallel example-duplicates:main example-doaj:main
    
  • Force run a task even when the task is up-to-date

    task example-duplicates:main --force
    
  • Dry-run in verbose mode for debugging

    task example-duplicates:main --dry --verbose --force
    
  • List available tasks

    task --list
    

How to develop your own tasks

(first draft, will be elaborated later)

  1. create a new folder
  2. copy an example Taskfile.yml
  3. provide input data in subdirectory input
  4. provide OpenRefine transformation history files in subdirectory config
  5. add commands to specific Taskfile (check openrefine-client help screen for available options: openrefine/client --help)
  6. add project to general Taskfile
  7. check memory load and increase RAM if needed

Getting help

Please file an issue if you miss some features or if you have tracked a bug. And you are welcome to ask any questions!

To do

  • hide OpenRefine install by renaming directory to .openrefine
  • add kill task to save time by skipping storing an OpenRefine project archive
  • differentiate examples
    • example for loading multiple input files by providing a zip archive
    • example for download "fresh" input data as a dependent task and generating archives/diffs
    • example for applying multiple json files
    • example for templating xml and validation with xmllint
    • example for multiple projects in one directory/taskfile
    • example for using kill task to save time and disk space
  • describe example datasets (and differences) with source code examples
  • elaborate how-to for developing tasks
    • document openrefine-client options and defaults (tables for input and output with file-format-specific defaults) including templating
    • how-to for extracting input options from OpenRefine GUI (via metadata in open project)
    • document known issues, e.g. import xls, xlsx, ods
  • add Binder files and badge
  • add example notebooks (links to nbviewer and Binder)