{
  "$defs": {
    "DimPolicy": {
      "description": "What may happen to a dim's coordinates at score time.",
      "enum": [
        "fixed",
        "extend",
        "new_levels"
      ],
      "title": "DimPolicy",
      "type": "string"
    },
    "DimSpec": {
      "additionalProperties": false,
      "description": "A dimension and its score-time policy.",
      "properties": {
        "description": {
          "anyOf": [
            {
              "maxLength": 2000,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Description"
        },
        "freq": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Pandas-style frequency, e.g. 'W-SUN'",
          "title": "Freq"
        },
        "kind": {
          "enum": [
            "categorical",
            "time",
            "integer",
            "float",
            "index"
          ],
          "title": "Kind",
          "type": "string"
        },
        "max_extension": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Periods allowed past the fit",
          "title": "Max Extension"
        },
        "new_level_strategy": {
          "default": "error",
          "enum": [
            "error",
            "hyperprior",
            "pooled",
            "zero"
          ],
          "title": "New Level Strategy",
          "type": "string"
        },
        "ordered": {
          "default": false,
          "title": "Ordered",
          "type": "boolean"
        },
        "policy": {
          "$ref": "#/$defs/DimPolicy",
          "default": "fixed"
        }
      },
      "required": [
        "kind"
      ],
      "title": "DimSpec",
      "type": "object"
    },
    "Hdf5Coord": {
      "additionalProperties": false,
      "description": "The coordinate of dim ``dim`` in node ``node`` of a raw HDF5 upload (M4).\n\nExactly one source: ``path`` (a 1-D HDF5 dataset holding the labels), or ``start`` with\nan optional ``step`` (a range: numbers, or a date and a pandas frequency such as\n``\"2024-01-01\"`` + ``\"W-MON\"``), or neither (an integer index ``0..n-1``). ``spec``\noverrides the inferred :class:`~mapi_spec.schema.DimSpec`.",
      "examples": [
        {
          "dim": "row",
          "spec": {
            "kind": "float",
            "ordered": true
          },
          "start": 0.0,
          "step": 0.05
        },
        {
          "dim": "date",
          "path": "/axes/date",
          "spec": {
            "kind": "time",
            "policy": "extend"
          }
        }
      ],
      "properties": {
        "dim": {
          "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-]{0,127}$",
          "title": "Dim",
          "type": "string"
        },
        "node": {
          "default": "/",
          "pattern": "^/(?:[A-Za-z_][A-Za-z0-9_.\\-]{0,63}(?:/[A-Za-z_][A-Za-z0-9_.\\-]{0,63}){0,7})?$",
          "title": "Node",
          "type": "string"
        },
        "path": {
          "anyOf": [
            {
              "pattern": "^/[^\\x00]{1,1024}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Path"
        },
        "spec": {
          "anyOf": [
            {
              "$ref": "#/$defs/DimSpec"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "start": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Start"
        },
        "step": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Step"
        }
      },
      "required": [
        "dim"
      ],
      "title": "Hdf5Coord",
      "type": "object"
    },
    "Hdf5Var": {
      "additionalProperties": false,
      "description": "A data variable read from one HDF5 dataset of a raw HDF5 upload (M4).\n\n``dims`` names the array's axes in order (its length must equal the array's ``ndim``;\nthe sandbox checks it). The variable is stored as ``name`` in tree node ``node``.",
      "examples": [
        {
          "dims": [
            "row",
            "col"
          ],
          "name": "image",
          "node": "/",
          "path": "/observations/image",
          "units": "counts"
        }
      ],
      "properties": {
        "description": {
          "anyOf": [
            {
              "maxLength": 2000,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Description"
        },
        "dims": {
          "items": {
            "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-]{0,127}$",
            "type": "string"
          },
          "maxItems": 32,
          "title": "Dims",
          "type": "array"
        },
        "missing": {
          "default": "forbid",
          "enum": [
            "forbid",
            "allow",
            "mask"
          ],
          "title": "Missing",
          "type": "string"
        },
        "name": {
          "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-]{0,127}$",
          "title": "Name",
          "type": "string"
        },
        "node": {
          "default": "/",
          "pattern": "^/(?:[A-Za-z_][A-Za-z0-9_.\\-]{0,63}(?:/[A-Za-z_][A-Za-z0-9_.\\-]{0,63}){0,7})?$",
          "title": "Node",
          "type": "string"
        },
        "path": {
          "pattern": "^/[^\\x00]{1,1024}$",
          "title": "Path",
          "type": "string"
        },
        "role": {
          "$ref": "#/$defs/Role",
          "default": "covariate"
        },
        "units": {
          "anyOf": [
            {
              "maxLength": 64,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Units"
        }
      },
      "required": [
        "path",
        "name"
      ],
      "title": "Hdf5Var",
      "type": "object"
    },
    "Role": {
      "description": "What a variable means to a model.",
      "enum": [
        "target",
        "covariate",
        "media",
        "spend",
        "control",
        "index",
        "mask",
        "constant",
        "weight",
        "exposure"
      ],
      "title": "Role",
      "type": "string"
    }
  },
  "$id": "https://schemas.mapi.dev/v1/api-Hdf5Mapping.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "How a raw HDF5 upload becomes a (tree) dataset (M4): which arrays become which\nvariables of which node, with which dims and coords. Arrays that are not mapped are\nreported in one warning, never read.",
  "examples": [
    {
      "coords": [
        {
          "dim": "row",
          "spec": {
            "kind": "float",
            "ordered": true
          },
          "start": 0.0,
          "step": 0.05
        }
      ],
      "vars": [
        {
          "dims": [
            "row",
            "col"
          ],
          "name": "image",
          "node": "/",
          "path": "/observations/image",
          "units": "counts"
        },
        {
          "dims": [
            "prow",
            "pcol"
          ],
          "name": "psf",
          "node": "/psf",
          "path": "/psf/kernel"
        }
      ]
    }
  ],
  "properties": {
    "coords": {
      "items": {
        "$ref": "#/$defs/Hdf5Coord"
      },
      "maxItems": 64,
      "title": "Coords",
      "type": "array"
    },
    "vars": {
      "items": {
        "$ref": "#/$defs/Hdf5Var"
      },
      "maxItems": 1024,
      "minItems": 1,
      "title": "Vars",
      "type": "array"
    }
  },
  "required": [
    "vars"
  ],
  "title": "Hdf5Mapping",
  "type": "object",
  "x-mapi-contract-version": "0.2"
}
