alteryx / alteryx/evalml

Component API: explore alternatives to kwargs

Abierto
#2,857 0 comentarios 0 reacciones 0 asignados Ver en GitHub
refactor spike
Lenguaje dominante
Python
Estrellas
850
Forks
96
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

While adding a new component, I ran into this test and error, pasted below. My understanding of this test is that it tests whether or not kwargs make it into our component's `parameters` dictionary and then if there's a component object, whether or not it's set as an attribute on the component object.

I just wanted to raise two assumptions and whether or not they're necessary or even good practice:

1) If a user gives us an erroneous keyword argument such as "foo", should we really be keeping that as part of `component.parameters`?
2) We're assuming that **kwargs is passed to the component object. This is not true in the case of the LabelEncoder which does not take any arguments.

```
def test_components_init_kwargs():
for component_class in all_components():
try:
component = component_class()
except EnsembleMissingPipelinesError:
continue
if component._component_obj is None:
continue
if isinstance(component, StackedEnsembleBase):
continue

obj_class = component._component_obj.__class__.__name__
module = component._component_obj.__module__
importlib.import_module(module, obj_class)
patched = module + "." + obj_class + ".__init__"

def all_init(self, *args, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)

with patch(patched, new=all_init) as _:
component = component_class(test_arg="test")
component_with_different_kwargs = component_class(diff_test_arg="test")
> assert component.parameters["test_arg"] == "test"
if not isinstance(component, PolynomialDetrender):
assert component._component_obj.test_arg == "test"
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.