This message was deleted.
# hamilton-help
s
This message was deleted.
👀 1
t
@Stefan Krawczyk asked "what are some Hamilton decorators that I can use to help me reuse logic?" Let me see what I can find... 🤔
To help reuse logic in Hamilton, you can use decorators such as mapping business concepts to function names and ensuring naming uniformity across the code base (source: [Hamilton - Function Naming Best Practices](https://hamilton.dagworks.io/en/latest/concepts/best-practices/function-naming/)). If you'd like to learn more about the benefits of using Hamilton, you can visit the following resources: - [Hamilton - Main](https://hamilton.dagworks.io/en/latest/) - [Hamilton - Function Naming Best Practices](https://hamilton.dagworks.io/en/latest/concepts/best-practices/function-naming/)
@Stefan Krawczyk asked "what are some Hamilton decorators that I can use to help me reuse logic? (testing out a bot against our docs)" Let me see what I can find... 🤔
To reuse logic in Hamilton, you can make use of the following decorators: 1. check_output 2. config.when 3. does 4. extract_columns 5. extract_fields 6. inject 7. load_from For more information, you can refer to the Hamilton decorators documentation [here](https://hamilton.dagworks.io/en/latest/reference/decorators/). If there are specific use cases for custom decorators, it is recommended to reach out on Slack or via a GitHub issue to discuss and ensure alignment with the API.
s
@ThreadScribe can you tell me how I would use check_output ?
t
@Stefan Krawczyk asked " can you tell me how I would use check_output ?" Let me see what I can find... 🤔
To use the
check_output
decorator in Hamilton, you can add simple data quality checks to your code by following the example provided in the documentation. Here's how you would do it:
Copy code
python
import pandas as pd
import numpy as np
from hamilton.function_modifiers import check_output

@check_output(
    data_type=np.int64,
    range=(0,100),
)
def some_int_data_between_0_and_100() -> pd.Series:
    # Your code here
    pass
This decorator enables you to specify the data type and range for the output, allowing you to enforce data quality constraints. For more details, you can refer to the official documentation on the
check_output
decorator in Hamilton [here](https://hamilton.dagworks.io/en/latest/reference/decorators/check_output/).
s
@ThreadScribe what can you tell me about the
@step
decorator?
t
@Stefan Krawczyk asked "what can you tell me about the
@step
decorator?" Let me see what I can find... 🤔
{ "text": "The
@step
decorator is not mentioned in the provided documents, so there is no information available about it." }
s
(trick question — by me 😈 )
😆 1
@ThreadScribe what can you tell me about the
@pipe
decorator?
t
@Stefan Krawczyk asked "what can you tell me about the
@pipeline
decorator?" Let me see what I can find... 🤔
I'm sorry. Our search came up empty. Please modify your question and try again.
@Stefan Krawczyk asked "what can you tell me about the
@pipe
decorator?" Let me see what I can find... 🤔
To understand the
@pipe
decorator, we can refer to the Hamilton documentation. The
@pipe
decorator is used to represent a chained set of transformations. It is specifically designed to solve the "node redefinition" problem and is meant to represent a pipeline of chaining/redefinitions. This can be used to display transformations as nodes in the DAG, store or visualize the result, pull in functions from an external repository, build the DAG more procedurally, and use the same function multiple times with different parameters. It is a part of the function modifiers in Hamilton, which are highly expressive and useful for writing expressive dataflows. For more details, the documentation can be found at [Hamilton @pipe Documentation](https://hamilton.dagworks.io/en/latest/reference/decorators/pipe/).
m
@Stefan Krawczyk would love some feedback on how helpful these are. we can make updates to improve the response quality
👍 1
e
First piece of feedback is to get the links working 🙂 Seems to be using markdown style and not rendering in slack. Also impressive that
@pipeline
didn’t find anything but it did for
@pipe
. Might be nice to prompt for more.
👍 1
🙏 1
m
thanks @Elijah Ben Izzy - the slack markdown formatting is a pain and you're not the first one to ask us for that 😅 we actually should have a formatting update rolling out tomorrow.
i'll keep you posted
👍 1
@ThreadScribe what can you tell me about the
@pipe
decorator?
t
@Mathew Goldsborough asked "what can you tell me about the
@pipe
decorator?" Let me see what I can find... 🤔
The
@pipe
decorator in Hamilton is used to represent a chained set of transformations, providing a solution to the "node redefinition" problem and representing a pipeline of chaining/redefinitions. It is intended to be used for the following reasons: 1. To display transformations as nodes in the DAG, with the possibility of storing or visualizing the result. 2. To pull in functions from an external repository and build the DAG more procedurally. 3. To use the same function multiple times, but with different parameters. The
@pipe
decorator allows for the chaining of nodes, and it works perfectly with various types of data such as dataframes and series. For more detailed information, the documentation for the
@pipe
decorator can be found at pipe - Hamilton and Function modifiers (Advanced).
m
@Elijah Ben Izzy links fixed 🙂
🔥 1