-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi, I am trying to use fairworkflows
to describe a simple ML workflow, but I am facing a few issues
For example whenever I try to use a type annotation to annotate the input or return value of a function I get an error
- Type annotation in function parameters:
@is_fairstep(label='Create and fit classifier', is_script_task=True)
def fit_classifier(hyper_params: Dict[str, float], data, y):
clf = RandomForestClassifier(
n_jobs=hyper_params['n_jobs'],
random_state=hyper_params['random_state'],
)
clf.fit(data, y)
return clf
Will raise something like:
Traceback (most recent call last):
File "my-model/src/my_model/train.py", line 51, in <module>
def fit_classifier(hyper_params: Dict[str, float], data, y):
File "site-packages/fairworkflows/fairstep.py", line 452, in _modify_function
inputs = _extract_inputs_from_function(func, kwargs)
File "site-packages/fairworkflows/fairstep.py", line 504, in _extract_inputs_from_function
computational_type = argspec.annotations[arg].__name__
File "/opt/conda/lib/python3.9/typing.py", line 711, in __getattr__
raise AttributeError(attr)
AttributeError: __name__
- Type annotation for function return:
@is_fairstep(label='Evaluate the trained model', is_script_task=True)
def evaluate() -> Dict[str, float]:
return {
'precision': 0.85,
'recall': 0.80,
'accuracy': 0.85,
'roc_auc': 0.90,
'f1': 0.75,
'average_precision': 0.85,
}
will raise:
Traceback (most recent call last):
File "my-model/src/my_model/train.py", line 61, in <module>
def evaluate(model) -> Dict[str, float]:
File "site-packages/fairworkflows/fairstep.py", line 453, in _modify_function
outputs = _extract_outputs_from_function(func, kwargs)
File "site-packages/fairworkflows/fairstep.py", line 551, in _extract_outputs_from_function
computational_type = return_annotation.__name__ if return_annotation is not None else None
File "/opt/conda/lib/python3.9/typing.py", line 711, in __getattr__
raise AttributeError(attr)
AttributeError: __name__
Metadata
Metadata
Assignees
Labels
No labels