Skip to content

feat: use importlib when deserializing callables#8648

Merged
anakin87 merged 1 commit intodeepset-ai:mainfrom
LastRemote:feat/use-importlib-when-deserializing-callable
Jan 3, 2025
Merged

feat: use importlib when deserializing callables#8648
anakin87 merged 1 commit intodeepset-ai:mainfrom
LastRemote:feat/use-importlib-when-deserializing-callable

Conversation

@LastRemote
Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Supports local package imports via importlib.import_module

How did you test it?

Existing unit tests passed. I also added a new negative test for this.

Notes for the reviewer

This is a rather small change but it is causing issues for me right now. Really hope this can be included in 2.9.0!

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@LastRemote LastRemote requested review from a team as code owners December 17, 2024 07:31
@LastRemote LastRemote requested review from anakin87 and dfokina and removed request for a team December 17, 2024 07:31
@github-actions github-actions bot added topic:tests type:documentation Improvements on the docs labels Dec 17, 2024
streaming_callback = getattr(module, function_name, None)
if not streaming_callback:
try:
module = import_module(module_name, None)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@LastRemote Thanks for opening this PR! We merged a change related to this part of the code base yesterday. Could you please update it so that we also use a thread safe import here too? 91619a7#diff-3a452f86d110b4f40389e0e4551b372188b5fe158aafe0afd5226d0007820457R139
We'll get back to you with a full review next week!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@LastRemote Thanks for opening this PR! We merged a change related to this part of the code base yesterday. Could you please update it so that we also use a thread safe import here too? 91619a7#diff-3a452f86d110b4f40389e0e4551b372188b5fe158aafe0afd5226d0007820457R139 We'll get back to you with a full review next week!

Hey, sorry for missing this. Sure, will do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@julian-risch Updated!

@LastRemote LastRemote force-pushed the feat/use-importlib-when-deserializing-callable branch from dcecb97 to 03c2b9b Compare January 2, 2025 11:02
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Jan 2, 2025

Pull Request Test Coverage Report for Build 12593551802

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 91.01%

Totals Coverage Status
Change from base Build 12581091751: 0.02%
Covered Lines: 8544
Relevant Lines: 9388

💛 - Coveralls

Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

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

I took a look and it seems good (I left a minor comment).

@julian-risch feel free to do a final review.

@LastRemote LastRemote force-pushed the feat/use-importlib-when-deserializing-callable branch from 03c2b9b to c339c12 Compare January 3, 2025 06:06
@anakin87
Copy link
Copy Markdown
Member

anakin87 commented Jan 3, 2025

I'm merging, since I need to do further work on the same function, to allow the deserialization of class methods (new feature).

@anakin87 anakin87 merged commit 8e3f647 into deepset-ai:main Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deserialize_callable is not working for local files

4 participants