asdf-format / asdf

ASDF (Advanced Scientific Data Format) is a next generation interchange format for scientific data
http://asdf.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
530 stars 58 forks source link

Explore setting up a try/reject system for ASDF converters #1263

Open WilliamJamieson opened 1 year ago

WilliamJamieson commented 1 year ago

In astropy/asdf-astropy#144 I describe solution (2) here: https://github.com/astropy/asdf-astropy/issues/144#issuecomment-1343410493 with more details here: https://github.com/astropy/asdf-astropy/issues/144#issuecomment-1343411260.

I think this solution requires more exploration.

As a recap the idea is to create a system where-in:

  1. A Converter instance can "reject" serializing a given object.
  2. ASDF gracefully handles this and continues searching for another Converter to attempt serialization.

This seems like a nice system to have as it would allow users to handle serializing objects that have been determined by previous Converters to not be serializable.

WilliamJamieson commented 1 year ago

A first tangential thought on this is that maybe we should allow libraries to control the "search" order for searching the Extensions for a viable Converter as there are circumstances where one might want to insert a Converter one wants to try first and then if it "rejects" fall back on a builtin converter.

WilliamJamieson commented 1 year ago

This is somewhat related to #1086 (at least in-so far as documenting the current tag handling behavior).