Skip to content
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

Compressors provided via the extensions argument to asdf.AsdfFile.__init__ are ignored #1685

Open
braingram opened this issue Nov 15, 2023 · 0 comments

Comments

@braingram
Copy link
Contributor

Providing a Compressor via an Extension listed in the extensions argument to asdf.AsdfFile.__Init__ does not work as expected.

import asdf
import numpy as np


class MyCompressor:
    label = b"hgtg"

    def compress(self, data, **kwargs):
        yield b"42"

    def decompress(self, blocks, out, **kwargs):
        return 0


class MyExtension:
    compressors = [MyCompressor()]
    extension_uri = "asdf://example.com/foo-1.0.0"


arr = np.array([1, 2, 3])
tree = {'arr': arr}

# works via context
with asdf.config_context() as cfg:
    cfg.add_extension(MyExtension())
    af = asdf.AsdfFile()
    af["arr"] = arr
    af.set_array_compression(arr, "hgtg")
    af.write_to("test.asdf")

af = asdf.AsdfFile(extensions=[MyExtension()])
af["arr"] = arr
af.set_array_compression(arr, "hgtg")
af.write_to("test.asdf")   # this fails with ValueError: Invalid compression type: hgtg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant