Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints to all component __init__ constructor parameters #3144

Closed
1 task done
vblagoje opened this issue Sep 3, 2022 · 0 comments · Fixed by #3152
Closed
1 task done

Add type hints to all component __init__ constructor parameters #3144

vblagoje opened this issue Sep 3, 2022 · 0 comments · Fixed by #3152
Assignees
Labels
type:refactor Not necessarily visible to the users

Comments

@vblagoje
Copy link
Member

vblagoje commented Sep 3, 2022

Describe the bug

We don't specify type hints for many parameters in component constructors. Here is the QuestionGenerator's __init__ constructor to illustrate this issue:

def __init__(
        self,
        model_name_or_path="valhalla/t5-base-e2e-qg",
        model_version=None,
        num_beams=4,
        max_length=256,
        no_repeat_ngram_size=3,
        length_penalty=1.5,
        early_stopping=True,
        split_length=50,
        split_overlap=10,
        use_gpu=True,
        prompt="generate questions:",
        num_queries_per_doc=1,
        sep_token: str = "<sep>",
        batch_size: int = 16,
        progress_bar: bool = True,
        use_auth_token: Optional[Union[str, bool]] = None,
        devices: Optional[List[Union[str, torch.device]]] = None,
    ):

We specify types for the last five parameters but not other parameters. This inconsistency hasn't caused any major issue yet, but it might, and, after all, it is an inconsistency we should correct. The direct consequence I have discovered is that the generated JSON schema doesn't specify the type property for these parameters. In conclusion, for some properties, the Haystack schema has the type field/property, and for others, it doesn't!

Although there are no obvious failures due to this inconsistency, there are no guarantees there might be some in the future. dC tooling will appreciate having types for each component property.

Error message
No error messages were found; there might be silent failures now and in the future.

Expected behavior
We should add type hints for all components' init parameters.

Additional context
None

To Reproduce
Open any Haystack component and view the init method :-)

FAQ Check

System:

  • OS:
  • GPU/CPU:
  • Haystack version (commit or version number):
  • DocumentStore:
  • Reader:
  • Retriever:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:refactor Not necessarily visible to the users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant