Skip to content

fix: mypy "str" not callable for PromptModelInvocationLayer#6529

Merged
julian-risch merged 5 commits into
v1.xfrom
fix-mypy-promptmodel
Dec 12, 2023
Merged

fix: mypy "str" not callable for PromptModelInvocationLayer#6529
julian-risch merged 5 commits into
v1.xfrom
fix-mypy-promptmodel

Conversation

@julian-risch
Copy link
Copy Markdown
Member

@julian-risch julian-risch commented Dec 12, 2023

Related Issues

I am seeing a pylint error on Haystack v1.x after the recent prompt model PR. It's haystack/nodes/prompt/prompt_model.py:101: error: "str" not callable [operator] now that invocation_layer_class can be a string: https://github.com/deepset-ai/haystack/pull/6497/files#diff-8a69dcdf57e9a29aff18add4eaa63876f41273bfb905a5b2b9be988a78fe6f76R77

Proposed Changes:

  • Use two variables to avoid re-assignment and fix `"str" not callable``
  • Add raise to fix pointless-exception-statementerror
  • Add mocked tokenizer to unit test to fix error caused by our urlopen_mock check

How did you test it?

Ran mypy locally

Notes for the reviewer

Other option could be # type: ignore

The test added in the previous PR is not a unit test but marked as one and is failing for that reason: https://github.com/deepset-ai/haystack/pull/6497/files#diff-d1a8309a2d6fb001c0a8b7a97dcdb27b0e99626e3d35dd9ef8e33cedc04fe54eR43
It tries to load a tokenizer from the model hub.

Checklist

@julian-risch julian-risch requested a review from a team as a code owner December 12, 2023 10:31
@julian-risch julian-risch requested review from masci and removed request for a team December 12, 2023 10:31
@julian-risch julian-risch added the ignore-for-release-notes PRs with this flag won't be included in the release notes. label Dec 12, 2023
@julian-risch julian-risch requested review from ZanSara and removed request for masci December 12, 2023 10:42
Copy link
Copy Markdown
Contributor

@ZanSara ZanSara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@julian-risch julian-risch merged commit 850cf34 into v1.x Dec 12, 2023
@julian-risch julian-risch deleted the fix-mypy-promptmodel branch December 12, 2023 11:41
anakin87 pushed a commit that referenced this pull request Dec 15, 2023
* cast to PromptModelInvocationLayer

* fix pylint pointless-exception-statement

* use two variables to avoid re-assignment

* black

* use mocked tokenizer in unit test
anakin87 pushed a commit that referenced this pull request Dec 21, 2023
…eciprocal rank fusion (#5704)

* Change type of PromptModel invocation_layer_class init param (#6497)

* fix: mypy `"str" not callable` for `PromptModelInvocationLayer` (#6529)

* cast to PromptModelInvocationLayer

* fix pylint pointless-exception-statement

* use two variables to avoid re-assignment

* black

* use mocked tokenizer in unit test

* Add normalization and weighting for `JoinDocuments` reciprocal rank fusion

* Add weights and score normalization for reciprocal rank fusion in JoinDocuments node.

* Fix black-jupyter

* Fix JoinDocuments test for rrf + score normalization

---------

Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
Co-authored-by: Julian Risch <julian.risch@deepset.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release-notes PRs with this flag won't be included in the release notes. topic:LLM topic:promptnode topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants