Make ASDF extension robust to missing asdf-astropy#2268
Make ASDF extension robust to missing asdf-astropy#2268larrybradley wants to merge 1 commit intoastropy:mainfrom
Conversation
|
Pinging @braingram as a potential reviewer too. |
|
This seems like a complicated distinction to make. Is there much benefit in supporting an environment that supports serializing some objects when asdf is installed and not asdf-astropy (which essentially only depends on asdf and astropy)? For example is it possible to construct a If the goal is to provide a custom message if asdf is used but asdf-astropy is not installed perhaps it would be easier to register a extension that supports all photutils tags and photutils types (that have asdf support) and displays the message on read/write? |
|
@braingram Many thanks for the review! The goal was provide a custom/friendly error message. My solution also doesn't scale -- and @nden is adding more converters (to cover all aperture and psf models). |
This is a followup to #2211. Initial ASDF converters were added in #2211, but with
asdf-astropyas an optional dependency. Previously, attempting to serialize aCircularApertureorAiryDiskPSFto ASDF withoutasdf-astropyinstalled raised anAsdfSerializationErrorwith a long traceback.This PR fixes that by always registering both converters.
CircularApertureConverterworks fully with onlyasdf.AiryDiskPSFConverterfalls back to a plainasdf.extension.Converterbase class whenasdf-astropyis absent, and its to_yaml_tree/from_yaml_tree methods raise a clearImportErrorpointing the user topip install asdf-astropyinstead of a deep traceback.