Morning, should this be equivalent? ```@extract_co...
# hamilton-help
s
Morning, should this be equivalent?
Copy code
@extract_columns(
    *COLS_TO_EXPOSE
)
@pipe(
    step(_filter_to_src_trades),
    step(_filter_to_unrealized)
)
@config.when(env="test")
def raw_data_src__test(
    cob_date: datetime, 
    cache_dir: str = r"C:\codebase\data"
    ) -> pd.DataFrame:
    return query(cob_date)
to
Copy code
@extract_columns(
    *COLS_TO_EXPOSE
)
@config.when(env="test")
def raw_data_src__test(
    cob_date: datetime, 
    cache_dir: str = r"C:\codebase\data"
    ) -> pd.DataFrame:
    raw = query(cob_date)
    return raw.pipe(_filter_to_src_trades).pipe(_filter_to_unrealized)
Asking because of the following error.
Copy code
ValueError: Error: raw_data_src is expecting raw_data_src.with_filter_to_unrealized:<class 'datetime.datetime'>, but found raw_data_src.with_filter_to_unrealized:<class 'pandas.core.frame.DataFrame'>. 
Hamilton does not consider these types to be equivalent. If you believe they are equivalent, please reach out to the developers. Note that, if you have types that are equivalent for your purposes, you can create a graph adapter that checks the types against each other in a more lenient manner
By the looks of it,
hamilton pipe
is intended to perform on the input parameter values and not the return value?
s
@Seth Stokes the
@pipe
is run before the function. So no, they aren’t equivalent.
We have an issue open to create
@post_pipe
which would mirror the behavior you’re expecting
So you’ll want to change things to be like this:
Copy code
@config.when(env="test")
def raw_data_src__test(
    cob_date: datetime, 
    cache_dir: str = r"C:\codebase\data"
    ) -> pd.DataFrame:
    return query(cob_date)

@extract_columns(
    *COLS_TO_EXPOSE
)
@pipe(
    step(_filter_to_src_trades),
    step(_filter_to_unrealized)
)
def processed_data(raw_data_src: pd.DataFrame) -> pd.DataFrame:
    return raw_data_src # transforms in pipe have been applied
s
beautiful, ty sir - assuming it’s this one https://github.com/DAGWorks-Inc/hamilton/issues/701