Skip to content

Update package name #7

@PetrochukM

Description

@PetrochukM

Add this quote to the documentation:

Defaults are arguably the most important design decisions you'll ever make as a software developer.

https://blog.codinghorror.com/the-power-of-defaults/

Rename this package to Defaults, it makes more sense than HParams.

Example API:

import defaults

@defaults.register
def function(parameter: int = defaults.Default()):
    pass

class Object():
    @defaults.register
    def __init__(self, parameter: str = defaults.Default()):
        pass

defaults.set_defaults({
    function: defaults.Defaults(parameter=0),
    Object.__init__: defaults.Defaults(parameter=''),
})

This module is also redundant, the primary interface is via a dotted string path. The dotted string path is then parsed, imported, and hashed. Instead of resolving a string path, we could just accept a function object. The function object is guaranteed to exist, and we can check if it has a configurable wrapper.

We should still use _get_function_signature so that the configuration is exportable and importable into another process. We can remove _lazy_resolution because the import responsibility is on the owner.

With regard to external libraries, like _BatchNorm and BatchNorm1d, the issue will continue to persist. At the end of the day, there are two references to the same function. If one of the references is decorated and the other is not, that will cause all kinds of issues. For example, it'll cause issues with the trace. It'll also cause issues with __qualname__. The proper solution is to create a subclass with BatchNorm1d that has a separate __init__ with a separate set of kwargs.

The idea of decorating external libraries is interesting. At the end of the day, the goal of this library is to help configure a bunch of code. Instead of having an external configuration object that is passed through the entire code base, we just directly inject the parameters that we'd like to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions