-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to disable inline representation of tagged field content when writing to ASDF file #1499
Comments
Here's an example what happens if the tagged field has a child field node: !<asdf://example.com/tags/node-1.0.0>
child: !<asdf://example.com/tags/node-1.0.0> {child: null} This looks a bit silly |
This should be controlled by the It should work as the Roman asdf files make extensive use of this. For example if one generates and saves a roman: !<asdf://stsci.edu/datamodels/roman/tags/wfi_image-1.0.0>
meta:
aperture: !<asdf://stsci.edu/datamodels/roman/tags/aperture-1.0.0>
name: WFI_06_FULL
position_angle: 30.149604523080143
cal_step: !<asdf://stsci.edu/datamodels/roman/tags/cal_step-1.0.0>
assign_wcs: INCOMPLETE
flat_field: SKIPPED
dark: COMPLETE
dq_init: COMPLETE
jump: COMPLETE
linearity: SKIPPED
photom: COMPLETE
ramp_fit: COMPLETE
saturation: INCOMPLETE
calibration_software_version: !<asdf://stsci.edu/datamodels/roman/tags/calibration_software_version-1.0.0> Version
94bb92d0a922867c94ed1fddcb4216a5
coordinates: !<asdf://stsci.edu/datamodels/roman/tags/coordinates-1.0.0>
reference_frame: ICRS
crds_context_used: roman_8226.pmap
crds_software_version: 63.1.67
ephemeris: !<asdf://stsci.edu/datamodels/roman/tags/ephemeris-1.0.0>
earth_angle: 1.301915411283766
moon_angle: 1.1516403400836825
sun_angle: 2.736255246678112
type: PREDICTED
time: 59865.65463414276
ephemeris_reference_frame: Frame 3706a1f3
spatial_x: -1.3623950365305825e+308
spatial_y: -1.60804538172114e+306
spatial_z: 1.5921914973582028e+307
velocity_x: 1.3125923623238684e+308
velocity_y: -1.6632717836035864e+308
velocity_z: 2.352229275461757e+307 I believe yaml would have normally chosen to represent the part under |
How would I control this without defining a schema for the tag? One may want to overwrite all tag's preference after all this is just for the serialization and does not affect deseralization. |
This is currently not supported outside of setting the style within the tag definition. However, looking at the early history, adjusting the default for serialization was planned but never finished, see: Lines 90 to 95 in d33ca09
Please feel free to explore how to do this further if you wish and open PR adding the feature if you figure out how to do it. Now I do have some broad thoughts on how to accomplish this. Note that the For the two wrapper objects that are used to wrap tagged objects in the ASDF tree. This is then read by the
for the two wrapper types above. Thus if you examine the raw ASDF tree, once its been converted into data by the converters, you should be able to set the How and when to access will require more in-depth investigation and experimentation. |
Very informative, thank you! I will take a stab it this. First, ASDF is using whatever default the pyyaml dumper is using. This is fine as-is, but if ASDF has a preference, the change seems simple and this would not ignore the tag definition schema preference. - flow_style = _flow_style_map.get(mapping.flow_style, None)
+ flow_style = _flow_style_map.get(mapping.flow_style, _flow_style_map['block']) For adding user overrides of flow style, I'm seeing this would have to come from the configs elsewhere as the function signature for the representers will not support this (unless I'm mistaken and the object type for data/mapper/sequence do contain user configs). Lastly, what are the interfaces the users can use to set stylistics preferences. Is it just |
This Since ASDF uses In so far as, enabling user overrides placing the interface in the asdf-config is a fine idea, this can even enable the |
Note that "inlining" arrays (storing them in the yaml directly, instead of in a binary block) operates on the same principle as the The global setting for this is controlled by the Lines 325 to 347 in 8dce02c
I believe something like |
Here is where Lines 1188 to 1190 in 8dce02c
|
Okay I won't push further, but I will say it's not much of a heuristic -- it looks to be just a consistency rule:
Thank you, the existing config for array serialization styling helps a lot. |
I do not see this in the docs, but currently when writing to ASDF file, all ASDF tags are written inline if it is not nested (i.e., all children are leaf nodes).
Current Behavior:
Desired Behavior:
Can we add an option to disable this and I much prefer this to be the default.
The text was updated successfully, but these errors were encountered: