Skip to content

Commit

Permalink
Adds documentation about not stacking check_output_custom
Browse files Browse the repository at this point in the history
We cannot stack them, instead you can pass multiple ones in.
  • Loading branch information
skrawcz committed Jun 15, 2024
1 parent 5209934 commit 3da2639
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/concepts/function-modifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ The ``@check_output`` function modifiers are applied on the **node output / func

In the future, validatation capabailities may be added to ``@schema``. For now, it's only added metadata.

@check_output
~~~~~~~~~~~~~
@check_output*
~~~~~~~~~~~~~~

The ``@check_output`` implements many data checks for Python objects and DataFrame/Series including data type, min/max/between, count, fraction of null/nan values, and allow null/nan. Failed checks are either logged (``importance="warn"``) or make the dataflow fail (``importance="fail"``).

Expand All @@ -162,6 +162,7 @@ The next snippet checks if the returned Series is of type ``np.int32``, which is

- To see all available validators, go to the file ``hamilton/data_quality/default_validators.py`` and view the variable ``AVAILABLE_DEFAULT_VALIDATORS``.
- The function modifier ``@check_output_custom`` allows you to define your own validator. Validators inherit the ``base.BaseDefaultValidator`` class and are essentially standardized Hamilton node definitions (instead of functions). See ``hamilton/data_quality/default_validators.py`` or reach out on `Slack <https://join.slack.com/t/hamilton-opensource/shared_invite/zt-1bjs72asx-wcUTgH7q7QX1igiQ5bbdcg>`_ for help!
- Note: ``@check_output_custom`` decorators cannot be stacked, but they instead can take multiple validators.

.. note::

Expand Down
4 changes: 4 additions & 0 deletions hamilton/function_modifiers/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def __init__(self, *validators: dq_base.DataValidator, target_: base.TargetType
4. **Collection[str]**: This will check all nodes specified in the list.
In all likelihood, you *don't* want ``...``, but the others are useful.
Note: you cannot stack `@check_output_custom` decorators. If you want to use multiple custom validators, \
you should pass them all in as arguments to a single `@check_output_custom` decorator.
"""
super(check_output_custom, self).__init__(target=target_)
self.validators = list(validators)
Expand Down

0 comments on commit 3da2639

Please sign in to comment.