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

Enable native support for bytes for omegaconf 2.2.0 #262

Merged
merged 2 commits into from Apr 15, 2022
Merged

Enable native support for bytes for omegaconf 2.2.0 #262

merged 2 commits into from Apr 15, 2022

Conversation

rsokl
Copy link
Contributor

@rsokl rsokl commented Apr 15, 2022

Closes #181

bytes has had specialized support from hydra-zen. OmegaConf 2.2.0 adds native support for bytes (omry/omegaconf#845).

Now if OmegaConf 2.2.0 or higher is installed, hydra-zen will defer to OmegaConf's native support for bytes.

OmegaConf < 2.2.0 installed:

import inspect
from hydra_zen import builds, to_yaml

def f(x: bytes): ...

Conf = builds(f, x=b'123')
inspect.signature(Conf)  # <Signature (x: Any = Builds_bytes(_target_='builtins.bytes', _args_=((49, 50, 51),))) -> None>

print(to_yaml(Conf))
_target_: __main__.f
x:
  _target_: builtins.bytes
  _args_:
  - - 49
    - 50
    - 51

OmegaConf >= 2.2.0 installed:

import inspect
from hydra_zen import builds, to_yaml

def f(x: bytes): ...

Conf = builds(f, x=b'123')
inspect.signature(Conf)  # <Signature (x: bytes = b'123') -> None>

print(to_yaml(Conf))
_target_: __main__.f
x: !!binary |
  MTIz

@rsokl rsokl added enhancement New feature or request hydra/omegaconf Tied to behavior of hydra/omegaconf labels Apr 15, 2022
@rsokl rsokl added this to the hydra-zen 0.7.0 milestone Apr 15, 2022
@rsokl rsokl merged commit 20dadd7 into main Apr 15, 2022
@rsokl rsokl deleted the omegabytes branch April 15, 2022 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hydra/omegaconf Tied to behavior of hydra/omegaconf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

omegaconf is adding native support for bytes
1 participant