Write a writer plugin

This guide explains how to create a writer plugin for DEFAIR. A writer plugin lets DEFAIR save datasets in a new file format or to a new kind of storage.

The skeleton in Minimal Writer Plugin Skeleton is a minimal working example of the interface, not a production writer: it stores the dataset as NetCDF through to_netcdf() as a stand-in for your format. It runs against DEFAIR 0.4.3, is found by load_writer() and passes workflow validation. Model a real writer on a complete built-in such as NetCDF4Writer, which shows named options, encoding, CF history tracking and the lat/lon materialisation step described in Writer output contracts. Its source comes with DEFAIR: python -c "import defair_data.writers.netcdf4.netcdf4_writer as m; print(m.__file__)" prints where its source is installed.

Before implementing the plugin, complete the shared setup in Plugin Development.

Prerequisites

No. 1 A test dataset, output destination and format library

Prepare a small dataset, a writable temporary destination and the library that encodes your output format.

No. 2 xdggs for the optional decoding example

If you run the xdggs decoding example, use Python 3.11 or newer and install xdggs==0.6.0 with pip install xdggs==0.6.0. DEFAIR does not install it.

Choose a writer-plugin task

What to do next

Start with Writer output contracts to decide what your format must preserve. Then follow Create and register a writer plugin to implement the writer and make it available to DEFAIR.