{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kundajelab.github.io/altar/extend/schemas/altar-long-scores-1.schema.json",
  "$defs": {
    "LongScoresColumnEntry": {
      "additionalProperties": false,
      "description": "One column of a score table's files: its name and its Arrow type, such as ``double`` or ``string``.",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "type"
      ],
      "type": "object"
    },
    "LongScoresFieldEntry": {
      "additionalProperties": false,
      "description": "One score column a model declares: its name, its type, and what it means.",
      "properties": {
        "name": {
          "type": "string"
        },
        "dtype": {
          "enum": [
            "float",
            "int",
            "bool",
            "str"
          ],
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "meaning": {
          "description": "The result field's meaning, as the binding's manifest declares it.",
          "type": "string"
        },
        "nullable": {
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "dtype",
        "label",
        "meaning",
        "nullable"
      ],
      "type": "object"
    },
    "LongScoresFileEntry": {
      "additionalProperties": false,
      "description": "One file of the export: its path under the destination, what it holds, its size, rows and checksums.",
      "properties": {
        "path": {
          "type": "string"
        },
        "table": {
          "description": "The score table's name, or models.",
          "type": "string"
        },
        "chromosome": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The chromosome of a score file's partition; null for models."
        },
        "size": {
          "minimum": 0,
          "type": "integer"
        },
        "row_count": {
          "minimum": 0,
          "type": "integer"
        },
        "sha256": {
          "anyOf": [
            {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The sha256: digest of the bytes, where the writer computed it; null for a warehouse's file."
        },
        "crc32c": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The store's own base64 CRC32C, where it keeps one, as GCS does."
        }
      },
      "required": [
        "path",
        "table",
        "chromosome",
        "size",
        "row_count",
        "sha256",
        "crc32c"
      ],
      "type": "object"
    },
    "LongScoresModelEntry": {
      "additionalProperties": false,
      "description": "One model of the export, with its full identity and the lineages its rows were selected from.",
      "properties": {
        "model_id": {
          "type": "string"
        },
        "model_name": {
          "type": "string"
        },
        "plugin_id": {
          "type": "string"
        },
        "plugin_version": {
          "type": "string"
        },
        "result_schema_version": {
          "type": "string"
        },
        "result_schema_hash": {
          "type": "string"
        },
        "genome": {
          "type": "string"
        },
        "table": {
          "description": "The directory of the score table its rows are in, scores/<name>.",
          "type": "string"
        },
        "score_lineage_ids": {
          "description": "The lineages a read of this model accepts, in preference order; each row names its own.",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "type": "array"
        },
        "run_identity": {
          "additionalProperties": true,
          "description": "The model's run identity, as PluginRunIdentity.to_dict.",
          "type": "object"
        },
        "fields": {
          "items": {
            "$ref": "#/$defs/LongScoresFieldEntry"
          },
          "type": "array"
        }
      },
      "required": [
        "model_id",
        "model_name",
        "plugin_id",
        "plugin_version",
        "result_schema_version",
        "result_schema_hash",
        "genome",
        "table",
        "score_lineage_ids",
        "run_identity",
        "fields"
      ],
      "type": "object"
    },
    "LongScoresScope": {
      "additionalProperties": false,
      "description": "Which variants the export covers: every stored one, a listed set, or a relation in the store.",
      "properties": {
        "variants": {
          "enum": [
            "all",
            "listed",
            "relation"
          ],
          "type": "string"
        },
        "variant_count": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "description": "How many distinct variants were listed; null otherwise."
        },
        "chromosomes": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "The chromosomes the export was limited to; null for all."
        }
      },
      "required": [
        "variants",
        "variant_count",
        "chromosomes"
      ],
      "type": "object"
    },
    "LongScoresTableEntry": {
      "additionalProperties": false,
      "description": "One score table: its directory, the plugin and result schema version its models share, and its columns.",
      "properties": {
        "name": {
          "type": "string"
        },
        "path": {
          "description": "The table's directory under the destination, scores/<name>.",
          "type": "string"
        },
        "plugin_id": {
          "type": "string"
        },
        "result_schema_version": {
          "type": "string"
        },
        "model_ids": {
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "type": "array"
        },
        "columns": {
          "items": {
            "$ref": "#/$defs/LongScoresColumnEntry"
          },
          "type": "array"
        }
      },
      "required": [
        "name",
        "path",
        "plugin_id",
        "result_schema_version",
        "model_ids",
        "columns"
      ],
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "The manifest of a long scores export, ``altar-long-scores/1``, at ``<destination>/_manifest.json``.",
  "properties": {
    "format": {
      "const": "altar-long-scores/1",
      "type": "string"
    },
    "genome": {
      "description": "The genome build every model of the export was scored on.",
      "type": "string"
    },
    "store": {
      "description": "The registry name of the score store that wrote it, such as bigquery.",
      "type": "string"
    },
    "scope": {
      "$ref": "#/$defs/LongScoresScope"
    },
    "file_metadata": {
      "description": "Whether each score file also carries altar.long_scores key-value metadata; BigQuery's EXPORT DATA cannot set it, so its files are described by their columns and this manifest only.",
      "type": "boolean"
    },
    "row_count": {
      "description": "The score rows of every table together.",
      "minimum": 0,
      "type": "integer"
    },
    "tables": {
      "items": {
        "$ref": "#/$defs/LongScoresTableEntry"
      },
      "type": "array"
    },
    "models": {
      "items": {
        "$ref": "#/$defs/LongScoresModelEntry"
      },
      "type": "array"
    },
    "files": {
      "items": {
        "$ref": "#/$defs/LongScoresFileEntry"
      },
      "type": "array"
    },
    "_provenance": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "What the caller's provenance callback returned, as the other exports record it."
    }
  },
  "required": [
    "format",
    "genome",
    "store",
    "scope",
    "file_metadata",
    "row_count",
    "tables",
    "models",
    "files"
  ],
  "type": "object"
}
