-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the ASDF history in meta (#513)
* Add a meta dict to TiledDataset * Expose ASDF history in `[Tiled]Dataset.meta` Also makes sure it doesn't get saved back out. * Refactor schema and converter for TiledDataset now there is meta * Fix figure test * Add quality to shadow dataset * Add changelogs * Fix level_1_dataset_schema
- Loading branch information
Showing
13 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
History of the ADSF file, such as versions of packages and extensions used when writing it are now exposed ``TiledDataset.meta["history"]`` and ``Dataset.meta["history"]``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
``TiledDataset`` now has a ``.meta`` dictionary like that of ``Dataset``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import copy | ||
|
||
from asdf.extension import Converter | ||
|
||
|
||
class TiledDatasetConverter(Converter): | ||
tags = [ | ||
"tag:dkist.nso.edu:dkist/tiled_dataset-0.1.0", | ||
"asdf://dkist.nso.edu/tags/tiled_dataset-1.0.0", | ||
"asdf://dkist.nso.edu/tags/tiled_dataset-1.1.0", | ||
] | ||
types = ["dkist.dataset.tiled_dataset.TiledDataset"] | ||
|
||
def from_yaml_tree(cls, node, tag, ctx): | ||
from dkist.dataset.tiled_dataset import TiledDataset | ||
|
||
return TiledDataset(node["datasets"], node["inventory"]) | ||
# Support old files without meta, but with inventory | ||
meta = node.get("meta", {}) | ||
if "inventory" not in meta and (inventory := node.get("inventory", None)): | ||
meta["inventory"] = inventory | ||
|
||
return TiledDataset(node["datasets"], meta=meta) | ||
|
||
def to_yaml_tree(cls, tiled_dataset, tag, ctx): | ||
tree = {} | ||
tree["inventory"] = tiled_dataset._inventory | ||
# Copy the meta so we don't pop from the one in memory | ||
meta = copy.copy(tiled_dataset.meta) | ||
# If the history key has been injected into the meta, do not save it | ||
meta.pop("history", None) | ||
tree["meta"] = meta | ||
tree["datasets"] = tiled_dataset._data.tolist() | ||
return tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
%YAML 1.1 | ||
--- | ||
id: asdf://dkist.nso.edu/manifests/dkist-1.3.0 | ||
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-1.3.0 | ||
title: DKIST extension | ||
description: ASDF schemas and tags for DKIST classes. | ||
|
||
tags: | ||
- schema_uri: "asdf://dkist.nso.edu/schemas/file_manager-1.0.0" | ||
tag_uri: "asdf://dkist.nso.edu/tags/file_manager-1.0.0" | ||
- schema_uri: "asdf://dkist.nso.edu/schemas/dataset-1.1.0" | ||
tag_uri: "asdf://dkist.nso.edu/tags/dataset-1.2.0" | ||
- schema_uri: "asdf://dkist.nso.edu/schemas/tiled_dataset-1.1.0" | ||
tag_uri: "asdf://dkist.nso.edu/tags/tiled_dataset-1.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
%YAML 1.1 | ||
--- | ||
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01" | ||
id: "asdf://dkist.nso.edu/schemas/tiled_dataset-1.1.0" | ||
|
||
title: | | ||
A DKIST Tiled Dataset object. | ||
description: | ||
The container for a set of Dataset objects. | ||
|
||
type: object | ||
properties: | ||
datasets: | ||
description: A nested structure of Dataset objects | ||
type: array | ||
items: | ||
type: array | ||
items: | ||
- tag: "asdf://dkist.nso.edu/tags/dataset-1.*" | ||
|
||
meta: | ||
description: Dataset metadata, describing the whole dataset. | ||
type: object | ||
properties: | ||
quality: | ||
description: A copy of the quality report of these observations. | ||
type: object | ||
|
||
inventory: | ||
description: A copy of the inventory record for this dataset. | ||
type: object | ||
|
||
required: [inventory] | ||
additionalProperties: true | ||
|
||
required: [datasets, meta] | ||
additionalProperties: false | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters