Skip to content

Releases: eladrich/pyrallis

Improved Decoding Mechanism :microscope:

14 Mar 08:22
Compare
Choose a tag to compare

Improved decoding mechanism to support inherited types, one can still use the existing register functionality

pyrallis.decode.register(SomeClass, lambda x: SomeClass(x))

But can also register parent classes as well

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)

Added pyrallis.set_config_type to support json and toml

03 Mar 17:29
Compare
Choose a tag to compare

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

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

Changed enum parsing mechanism to be name based + bug fixes

10 Feb 22:54
Compare
Choose a tag to compare

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

class LRMethod1(Enum):
    onecycle: torch.optim.lr_scheduler = OneCycleLR
    lambdalr: torch.optim.lr_scheduler = LambdaLR

Instead of allowing only enums of the form:

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

Added omit_defaults in dump and improved --help

24 Jan 21:07
Compare
Choose a tag to compare

Implemented the suggestion from issue #1 to add an omit_defaults option to the dump function

pyrallis.dump(cfg, omit_defaults=True)

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

Modified API with pyrallis.parse and --config_path

11 Jan 19:49
Compare
Choose a tag to compare

Two breaking API changes

  1. Added the new pyrallis.parse call instead of the pyrallis.ArgumentParser.parse_args()
cfg = pyrallis.parse(config_class=TrainConfig)
  1. Modified the configuration argument name from --CONFIG to --config_path
$ python train_model.py --config_path=some_config.yaml --exp_name=my_first_exp

Required Arguments Bug Fix

06 Jan 06:32
Compare
Choose a tag to compare

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.

@dataclass
class LogConfig:
    exp_dir: str

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

Type Hint Fixes

05 Jan 22:37
Compare
Choose a tag to compare

Fixed type hints in pyrallis.decode and pyrallis.ArgumentParser for better code analysis

Improved Error Mechanism

02 Jan 15:43
Compare
Choose a tag to compare

Improved error mechanism to be more informative, showing the field that caused the exception

$  python -m examples.demo --compute.workers=five

pyrallis.utils.ParsingError: Failed when parsing value='five' into field "<class '__main__.ComputeConfig'>.workers" of type <class 'int'>.
        Underlying error: invalid literal for int() with base 10: 'five'

Bug fixes for different python versions

30 Dec 16:58
Compare
Choose a tag to compare

Fixed two bugs found when testing different python versions:

  • Started using collections.abc as expected (python 3.10)
  • Fixed a bug where assumed .name field does not exist (python 3.6)

Updates for PyPi Publication

30 Dec 16:05
Compare
Choose a tag to compare

Updated readme to use raw resources so that PyPi renders them correctly