Pyrallis

Latest version: v0.3.1

Safety actively analyzes 623827 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.3.1

Improved decoding mechanism to support inherited types, one can still use the existing `register` functionality
python
pyrallis.decode.register(SomeClass, lambda x: SomeClass(x))

But can also register parent classes as well
python
pyrallis.decode.register(BaseClass, lambda t, x: t(x), include_subclasses=True)


Also revised the dispatch mechanism from singledispatch to a new dedicated wrapper (singledispatch tries to dispatch by class instead of value which isn't suited for decoding, but worked only thanks to the default behavior)

0.3.0

Added an option to change the configuration format used by pyrallis globally, or for a specific context.

This will affect `pyrallis.parse`, `pyrallis.dump` and `pyrallis.load` to use the desired format

python
import pyrallis
pyrallis.set_config_type('json')
or
with pyrallis.config_type('json'):
pyrallis.dump(cfg)

0.2.2

Changed enum parsing to be based on enum field names instead of values.

As discussed in 8 , this allows one to support enums with non-string values such as
python
class LRMethod1(Enum):
onecycle: torch.optim.lr_scheduler = OneCycleLR
lambdalr: torch.optim.lr_scheduler = LambdaLR

Instead of allowing only enums of the form:
python
class LRMethod2(Enum):
onecycle: str = "onecycle"
constant: str = "constant"


The release also includes:
- Minor improvement in error mechanism
- Bug fixes when using the default collections such as Dict and List

0.2.1

Implemented the suggestion from issue 1 to add an omit_defaults option to the dump function
python
pyrallis.dump(cfg, omit_defaults=True)

Also simplified the wrapper classes in the process and improved the `--help` command to be more concise.

0.2

Two breaking API changes

1. Added the new `pyrallis.parse` call instead of the `pyrallis.ArgumentParser.parse_args()`
python
cfg = pyrallis.parse(config_class=TrainConfig)

2. Modified the configuration argument name from --CONFIG to --config_path
bash
$ python train_model.py --config_path=some_config.yaml --exp_name=my_first_exp

0.1.4.2

Fixed a bug with nested dataclasses, where if the dataclass had a required argument the dataclass wrapper could not initialize the dataclass to define its default value and raised an exception.

python
dataclass
class LogConfig:
exp_dir: str

dataclass
class TrainConfig:
log: LogConfig= field(default_factory=LogConfig)

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.