Seth Stokes
03/26/2024, 4:02 PM@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
@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.
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
Seth Stokes
03/26/2024, 4:05 PMhamilton pipe
is intended to perform on the input parameter values and not the return value?Stefan Krawczyk
03/26/2024, 4:06 PM@pipe
is run before the function. So no, they aren’t equivalent.Stefan Krawczyk
03/26/2024, 4:06 PM@post_pipe
which would mirror the behavior you’re expectingStefan Krawczyk
03/26/2024, 4:08 PM@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
Seth Stokes
03/26/2024, 4:17 PM