-
-
Notifications
You must be signed in to change notification settings - Fork 18
Initial import of the package #2
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some commentary on the subset of files that have been, er, converted to converters. Glad to see it working!
asdf_astropy/tags/transform/basic.py
Outdated
|
||
|
||
class TransformType(asdf.AsdfConverter): | ||
tags = {"http://asdf-format.org/schemas/transform/transforms-1.0.0"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just leave out tags
and types
here, since we don't want to actually write a generic transform to a file.
asdf_astropy/tags/transform/basic.py
Outdated
class TransformType(asdf.AsdfConverter): | ||
tags = {"http://asdf-format.org/schemas/transform/transforms-1.0.0"} | ||
types = {Model} | ||
version = '2.0.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version
and requires
attributes are no longer recognized by the framework
node = self.to_tree_transform(model) | ||
return self._to_tree_base_transform_members(model, node) | ||
|
||
def assert_equal(self, a, b): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assert_equal
methods are something that I haven't given much thought yet. It would be nice to put the responsibility of defining equality onto astropy itself, where upkeep will be easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
asdf_astropy/tags/transform/basic.py
Outdated
|
||
|
||
class IdentityType(TransformType): | ||
tags = {"http://asdf-format.org/schemas/transform/identity-2.0.0"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll still need to support the old tags, so this list should also include:
"tag:stsci.edu:asdf/transform/identity-1.0.0",
"tag:stsci.edu:asdf/transform/identity-1.1.0",
"tag:stsci.edu:asdf/transform/identity-1.2.0",
For transforms whose schemas see a lot of changes in this migration, we may want to maintain legacy support in a separate class, just so things don't get confusing.
asdf_astropy/tags/transform/basic.py
Outdated
|
||
class ConstantType(TransformType): | ||
tags = {"http://asdf-format.org/schemas/transform/constant-2.0.0"} | ||
supported_versions = ['1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '2.0.0'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported_versions
is also now ignored, that is determined by the list of tags.
types = {models.Const1D, models.Const2D} | ||
|
||
def from_yaml_tree(self, node): | ||
if self.version < AsdfVersion('1.4.0'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The self.version
property still exists, though at the moment it returns a string, I should probably change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'm not a fan of AsdfVersion
and hope to deprecate it)
asdf_astropy/tags/transform/basic.py
Outdated
|
||
|
||
class UnitsMappingType(asdf.AsdfConverter): | ||
tags = {"http://asdf-format.org/schemas/transform/units_mapping-2.0.0"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transform schema was deemed to be too astropy-specific for the general use transforms, so it's actually still living in astropy with URI http://astropy.org/schemas/astropy/transform/units_mapping-1.0.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a third party implementation of the standard implement only part of the schemas? If so, perhaps we should keep all schemas in one place and let people decide what they want to implement. I think it's something we should discuss further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good idea to me, there are so many transforms that the prospect of implementing them all is intimidating.
I wonder if we should separate them into namespaces to guide people on implementing a minimal set? transform/core
and others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worries me as well. I don't think people should be forced to implement them all (e.g., all the projection transform)
assert a.y_window == b.y_window | ||
|
||
|
||
class PolynomialType1_0(PolynomialTypeBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! I forgot about these. I did this because I didn't understand how supported_versions worked in the old framework. We can merge these back into one class again and just list multiple tags
.
asdf_astropy/extension.py
Outdated
converter_classes = list(_asdf_format_types) | ||
|
||
|
||
asdf.configure(converter_providers=[TransformConverterProvider()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to call configure
from within a library, since that will override other providers that the user might have installed. The entry point should take care of this for us (but maybe it's broken right now, I can't remember if I tested that specifically).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick test shows it doesn't work without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay thanks, I'll investigate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found the issue, left a comment here:
https://github.com/astropy/asdf-astropy/pull/2/files#r441786043
setup.cfg
Outdated
asdf-transform-schemas | ||
|
||
[options.entry_points] | ||
asdf_extensions = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the entry point is different for the new-style plugin. This should be:
asdf.converter_providers =
asdf-astropy = asdf_astropy.extension:TransformConverterProvider
asdf_astropy/tags/transform/basic.py
Outdated
__all__ = ['TransformType', 'IdentityType', 'ConstantType'] | ||
|
||
|
||
class TransformType(asdf.AsdfConverter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead change the class names to use Converter instead of Type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One detail I noticed in passing, but otherwise this looks ready to go
"tag:stsci.edu:asdf/transform/fix_inputs-1.2.0", | ||
} | ||
types = {CompoundModel} | ||
handle_dynamic_subclasses = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute controls a feature that we're planning to remove (and not implement in AsdfConverter
), so we can drop it.
This is the initial import of the package working with the new converters. The new extension (provider) is set up, as well as the converters in basic.py and polynomial.py. Works for me locally - example with Chebyshev1D: