Skip to content

Commit

Permalink
Deprecations introduced in v0.3.0 are now errors (#212)
Browse files Browse the repository at this point in the history
* deprecated uses of target-as-kwarg and hydra_partial are now errors

* Deprecated used of hydra_partial in hydrated_dataclass is now error

* Add changelog notes

* remove deprecated hydra_run, hydra_multirun

* remove docs fro hydra_run and hydra_multirun
  • Loading branch information
rsokl authored Jan 26, 2022
1 parent 9bb94de commit 045853c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 329 deletions.
8 changes: 0 additions & 8 deletions docs/source/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ Python function instead of from a commandline interface.

launch

.. currentmodule:: hydra_zen.experimental

.. autosummary::
:toctree: generated/

hydra_run
hydra_multirun


*********************************
Creating and Working with Configs
Expand Down
12 changes: 9 additions & 3 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ Improvements
- :ref:`Type widening <type-support>` will now be applied to configured fields where an interpolated variable -- a string of form ``"${<var-name>}"`` -- is specified. See :issue:`206` for rationale and examples.
- Fixed incomplete annotations for ``builds(..., zen_wrappers=<..>)``. See :pull:`180`

Compatibility-Breaking Changes
------------------------------

The deprecations :ref:`introduced in v0.3.0 <0p3p0-deprecations>` are now errors. Refer to those notes for details and for solutions for fixing stale code.


Notes
-----
There are no compatibility-breaking changes in this release. However, it should be
noted that the aforementioned improvements to :func:`~hydra_zen.builds` can change
the interface to your app.
It should be noted that the aforementioned improvements to :func:`~hydra_zen.builds`
can change the interface to your app.

For instance, if you were configuring ``torch.utils.data.DataLoader``, note the
following difference in behavior:
Expand Down Expand Up @@ -192,6 +197,7 @@ New Features
interpolation will be valid no matter where the configuration is
utilized. See :pull:`112`.

.. _0p3p0-deprecations:

Deprecations
------------
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions docs/source/generated/hydra_zen.experimental.hydra_run.rst

This file was deleted.

152 changes: 0 additions & 152 deletions src/hydra_zen/experimental.py

This file was deleted.

98 changes: 10 additions & 88 deletions src/hydra_zen/structured_configs/_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,56 +154,6 @@ def _retain_type_info(type_: type, value: Any, hydra_recursive: Optional[bool]):
return False


def _target_as_kwarg_deprecation(func: _T2) -> Callable[..., _T2]:
@wraps(func)
def wrapped(*args, **kwargs):
if not args and "target" in kwargs:
# builds(target=<>, ...) is deprecated
warnings.warn(
HydraZenDeprecationWarning(
"Specifying the target of `builds` as a keyword argument is deprecated "
"as of 2021-10-27. Change `builds(target=<target>, ...)` to `builds(<target>, ...)`."
"\n\nThis will be an error in hydra-zen 1.0.0, or by 2021-01-27 — whichever "
"comes first.\n\nNote: This deprecation does not impact yaml configs "
"produced by `builds`."
),
stacklevel=2,
)
target = kwargs.pop("target")
return func(target, *args, **kwargs)
return func(*args, **kwargs)

return wrapped


def _hydra_partial_deprecation(func: _T2) -> Callable[..., _T2]:
@wraps(func)
def wrapped(*args, **kwargs):
if "hydra_partial" in kwargs:
if "zen_partial" in kwargs:
raise TypeError(
"Both `hydra_partial` and `zen_partial` are specified. "
"Specifying `hydra_partial` is deprecated, use `zen_partial` "
"instead."
)

# builds(..., hydra_partial=...) is deprecated
warnings.warn(
HydraZenDeprecationWarning(
"The argument `hydra_partial` is deprecated as of 2021-10-27.\n"
"Change `builds(..., hydra_partial=<..>)` to `builds(..., zen_partial=<..>)`."
"\n\nThis will be an error in hydra-zen 1.0.0, or by 2022-01-27 — whichever "
"comes first.\n\nNote: This deprecation does not impact yaml configs "
"produced by `builds`."
),
stacklevel=2,
)
kwargs["zen_partial"] = kwargs.pop("hydra_partial")
return func(*args, **kwargs)

return wrapped


def mutable_value(x: _T) -> _T:
"""Used to set a mutable object as a default value for a field
in a dataclass.
Expand Down Expand Up @@ -271,7 +221,6 @@ def hydrated_dataclass(
hydra_recursive: Optional[bool] = None,
hydra_convert: Optional[Literal["none", "partial", "all"]] = None,
frozen: bool = False,
**_kw, # reserved to deprecate hydra_partial
) -> Callable[[Type[_T]], Type[_T]]:
"""A decorator that uses `builds` to create a dataclass with the appropriate
Hydra-specific fields for specifying a targeted config [1]_.
Expand Down Expand Up @@ -390,31 +339,6 @@ def hydrated_dataclass(
For more detailed examples, refer to `builds`.
"""

if "hydra_partial" in _kw:
if zen_partial is True:
raise TypeError(
"Both `hydra_partial` and `zen_partial` are specified. "
"Specifying `hydra_partial` is deprecated, use `zen_partial` "
"instead."
)

# builds(..., hydra_partial=...) is deprecated
warnings.warn(
HydraZenDeprecationWarning(
"The argument `hydra_partial` is deprecated as of 2021-10-27.\n"
"Change `builds(..., hydra_partial=<..>)` to `builds(..., zen_partial=<..>)`."
"\n\nThis will be an error in hydra-zen 1.0.0, or by 2022-01-27 — whichever "
"comes first.\n\nNote: This deprecation does not impact yaml configs "
"produced by `builds`."
),
stacklevel=2,
)
zen_partial = _kw.pop("hydra_partial")
if _kw:
raise TypeError(
f"hydrated_dataclass got an unexpected argument: {', '.join(_kw)}"
)

def wrapper(decorated_obj: Any) -> Any:

if not isinstance(decorated_obj, type):
Expand Down Expand Up @@ -757,20 +681,18 @@ def builds(
...


@_hydra_partial_deprecation
@_target_as_kwarg_deprecation
def builds(
*pos_args: Any,
zen_partial: bool = False,
zen_wrappers: ZenWrappers = tuple(),
zen_meta: Optional[Mapping[str, SupportedPrimitive]] = None,
populate_full_signature: bool = False,
hydra_recursive: Optional[bool] = None,
hydra_convert: Optional[Literal["none", "partial", "all"]] = None,
*pos_args,
zen_partial=False,
zen_wrappers=tuple(),
zen_meta=None,
populate_full_signature=False,
hydra_recursive=None,
hydra_convert=None,
frozen: bool = False,
builds_bases: Tuple[Type[_DataClass], ...] = (),
dataclass_name: Optional[str] = None,
**kwargs_for_target: SupportedPrimitive,
builds_bases=(),
dataclass_name=None,
**kwargs_for_target,
) -> Union[Type[Builds[Importable]], Type[PartialBuilds[Importable]]]:
"""builds(hydra_target, /, *pos_args, zen_partial=False, zen_meta=None,
hydra_recursive=None, populate_full_signature=False, hydra_convert=None,
Expand Down
24 changes: 0 additions & 24 deletions tests/test_experimental.py

This file was deleted.

Loading

0 comments on commit 045853c

Please sign in to comment.