Seth Stokes
05/15/2024, 2:54 PMimport
and not execution if I forget the **
for parameterize
line 226
?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [1], in <cell line: 7>()
4 import pandas as pd
5 from hamilton import driver, base
----> 7 import cme
--> 226 @parameterize({
227 f"is_{exec_type}": {"raw_fee_type": source("raw_fee_type"), "search_exec_type": value(exec_type)}
228 for exec_type in ["tas", "block", "efp", "efr", "eoo"]
229 })
230 def execution_types(raw_fee_type: pd.Series, search_exec_type: str) -> pd.Series:
231 return raw_fee_type.str.contains(search_exec_type, na=False)
234 def member_status(raw_fee_type: pd.Series) -> pd.Series:
TypeError: __init__() takes 1 positional argument but 2 were given
Note: not urgent as I realized the **
was the issue, more of a curiosity.Thierry Jean
05/15/2024, 3:04 PM@parameterize
, the __init__
is:
def __init__(
self,
**parametrization: Union[
Dict[str, ParametrizedDependency],
Tuple[Dict[str, ParametrizedDependency], str],
],
)
It has 1 positional argument (self
) and only accepts keyword arguments (kwargs) collected by **parametrization
. Therefore, @parameterize
can't accept a dict()
, but can receive an unpacked dict (**dict()
).
When importing the module, the class parameterize
needs to be instantiated and bound to its function (here execution_types()
).
In other words, it's a "standard Python error" and isn't specific to Hamilton or how the dataflow is defined, which would be caught at the Driver
build or execution.