Skip to content

Commit

Permalink
Fixes documentation to include new decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahbenizzy committed Mar 16, 2023
1 parent 41b473c commit 433e3b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion docs/reference/api-reference/decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ Actual decorators:
.. autoclass:: hamilton.experimental.decorators.parameterize_frame.parameterize_frame
:special-members: __init__

@inject
------------------------
.. autoclass:: hamilton.function_modifiers.inject
:special-members: __init__

@does
------------------------
.. autoclass:: hamilton.function_modifiers.does
Expand All @@ -83,7 +88,12 @@ Actual decorators:
.. autoclass:: hamilton.function_modifiers.subdag
:special-members: __init__

@delay_resolution
@parameterize_subdag
------------------------
.. autoclass:: hamilton.function_modifiers.parameterized_subdag
:special-members: __init__

@resolve
------------------------
.. autoclass:: hamilton.function_modifiers.resolve
:special-members: __init__
6 changes: 3 additions & 3 deletions hamilton/function_modifiers/expanders.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,7 @@ def validate(self, fn: Callable):


class inject(parameterize):
"""
@inject allows you to replace parameters with values passed in. You can think of
"""@inject allows you to replace parameters with values passed in. You can think of
it as a `@parameterize` call that has only one parameterization, the result of which
is the name of the function. See the following examples:
Expand All @@ -958,6 +957,7 @@ def a_plus_10_plus_b_plus_2(nums: List[int]) -> int:
})
def sum_numbers(nums: List[int]) -> int:
return sum(nums)
Something to note -- we currently do not support the case in which the same parameter is utilized
multiple times as an injection. E.G. two lists, a list and a dict, two sources, etc...
Expand All @@ -968,6 +968,6 @@ def __init__(self, **key_mapping: ParametrizedDependency):
"""Instantiates an @inject decorator with the given key_mapping.
:param key_mapping: A dictionary of string to dependency spec.
This is the same as the input mapping in `@parameterize`.
This is the same as the input mapping in `@parameterize`.
"""
super(inject, self).__init__(**{parameterize.PLACEHOLDER_PARAM_NAME: key_mapping})
2 changes: 1 addition & 1 deletion hamilton/function_modifiers/recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def __init__(
Furthermore, note the following:
1. The parameterizations passed to the constructor are **kwargs, so you are not
1. The parameterizations passed to the constructor are \*\*kwargs, so you are not
allowed to name these `load_from`, `inputs`, or `config`. That's a good thing, as these
are not good names for variables anyway.
Expand Down

0 comments on commit 433e3b5

Please sign in to comment.