Utility for catching errors in DUNE file metadata
MetaCatch includes a fairly comprehensive metadata specification, defined here: config/specification.yaml
However, the specification is far from complete, and we could use help fleshing it out by:
- Adding definitions for keys that are currently missing them
- Adding human-readable descriptions for keys and options
- Flagging deprecated and retired keys and mapping them to appropriate replacements (if any)
- Reviewing the preliminary categorization of valid, deprecated, and retired options for various keys
- Reviewing add adding to the system for conditional key requirements and value cross-checks
The "metacatch" command will run client-side validation on a list of inputs. Inputs may be provided as either JSON file paths or existing DIDs to fetch from the MetaCat database. Text files containing lists of additional inputs may also be provided and will be expanded automatically.
MetaCatch may run in three different modes:
- By default, MetaCatch will simply report any errors or warnings, and suggest potential fixes if possible.
- The "--fix [<pattern>]" argument will make MetaCatch attempt to automatically fix any problems it detects, outputting the result to JSON files. The provided pattern will be used to generate appropriate output filenames, and can use {path} to get the path of local input files or {namespace} and {name} to refer to the corresponding field in the file dictionaries. This may fail for inputs with critical validation errors.
- The "--merge <file> argument will make MetaCatch attempt to merge the metadata from all the input files, applying any fixes in the process. The output will be written to the specified file, which should be of the form "directory/filename.ext.json" where "filename.ext" is the name of the merged data file. Again, this may fail if any input files have critical validation errors.
The user may also provide "default" and "override" metadata values, as either JSON files or inline JSON. The default values will be used to populate any missing metadata keys, while the override values will be set whether or not the key exists in the input. Overriding a key to null is interpreted as deleting the key.
usage: metacatch [options] <input> [<input> ...]
MetaCatch: Utility for catching errors in DUNE file metadata
positional arguments:
input file(s) to validate, as JSON file, DID, or TXT file listing inputs
options:
-h, --help show this help message and exit
-d <file|json>, --default <file|json>
defaults for missing metadata keys, as JSON file or inline JSON
-o <file|json>, --override <file|json>
overrides for existing metadata keys, as JSON file or inline JSON
-f [pattern], --fix [pattern]
output fixed metadata, default = "{dir}/{name}.fixed"
-m <file>, --merge <file>
merge input metadata and write output to JSON file
--force overwrite existing output files without prompting
-q, --quiet suppress output (info -> warnings -> fixes -> non-critical errors)
--debug print extra debug information
--boring disable colorized output
The MetaCat server-side validation does not use the MetaCatch metadata specification directly, instead it uses a separate set of validation rules stored in the database. This means that any updates to the specification need to be manually uploaded to the server to take effect. MetaCatch therefore includes a "metacatch-sync" command that automatically checks for changes to the spec and optionally updates the definitions in the database.
The sync script originally had several modes, these have now been moved into the spec itself as a series of synchronization flags:
- optional: Includes full specifications for non-required keys. Otherwise, optional keys are omitted or given placeholder definitions with no constraints if the category is restricted.
- retired: Creates black-list definitions for retired keys or categories by either defining an empty list of valid values or creating a restricted category with the keys omitted.
- restricted: Sets categories to restricted by default, otherwise categories will be unrestricted. Explicitly setting individual categories to restricted or open will override this default.
- conditions: Enables conditional required flags (required keys in optional categories). Otherwise, all conditionally-required keys will have required set to false.
The MetaCatch package uses semantic versioning of the form major.minor.patch. Starting with version 1.0.0, these components will have the following meanings:
- major: Breaking changes that involve changes to the spec file format.
- minor: New package features or changes that do not modify the spec.
- patch: Bug fixes and changes that do not change the core functionality.
The spec file itself has a separate versioning scheme, so that changes to the spec can be largely decoupled from updates to the validation script. There won't necessarily be a clear distinction between major spec updates and minor patches, so it uses a combination of semantic and date-based versioning of the form version.YY.MM.DD[p]. These components have the following meanings:
- version is the same as the MetaCatch major version meant to read the spec.
- YY.MM.DD is the date of the update, as 2-digit 0-padded year.month.day.
- [p] is an optional letter to differentiate patches released on the same day, e.g. 1.26.11.30a > 1.26.11.30
Starting with version 1.0.0, MetaCatch will be able to download an updated spec file and use it to validate against, as long as the major versions are compatible. The spec version is appended to the core category description in the MetaCat database, allowing easy comparison between the server-side and client-side versions.
Copyright © 2025 FERMI NATIONAL ACCELERATOR LABORATORY
This repository, and all software contained within, is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Copyright is granted to FERMI NATIONAL ACCELERATOR LABORATORY on behalf of the Deep Underground Neutrino Experiment (DUNE). Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.