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

bug: Successfully imported module XXX but can't find it in the component registry.This is unexpected and most likely a bug. #9002

Closed
vmarchese opened this issue Mar 8, 2025 · 0 comments · Fixed by #9066
Assignees
Labels
P1 High priority, add to the next sprint

Comments

@vmarchese
Copy link

Describe the bug
I have the following situation:

  • a service using pipeline deserialization from yaml and executing the pipelines
  • a custom components package

The custom components package is in the format:

comp/
    __init__.py
    A/
       __init__.py
       B/
            __init__.py
            b.py

in which the comp/A/B/b.py file is (in pseudo code):

from haystack import component

@component
class BComponent:

   def __init__(self, some_param: str):
      self.some_param = some_param

  @component.output_types(some_return=Any)
  def run(some_input: Any):
       # do some stuff...
       return {"some_input": ...}

The comp/A/B/__init__.py file is

from .b import BComponent

__all__ = ["BComponent"]

If the pipeline is written in yaml as:

components:
   b:
     init_parameters:... 
    type: comp.A.B.BComponent

I have the following error:

  File "[omitted]/.venv/lib/python3.12/site-packages/haystack/core/pipeline/base.py", line 167, in from_dict
    raise PipelineError(
haystack.core.errors.PipelineError: Successfully imported module comp.A.B but can't find it in the component registry.This is unexpected and most likely a bug.

If I write the fully qualified name:

components:
   b:
     init_parameters:... 
    type: comp.A.B.b.BComponent

it works perfectly.

Error message

  File "[omitted]/.venv/lib/python3.12/site-packages/haystack/core/pipeline/base.py", line 167, in from_dict
    raise PipelineError(
haystack.core.errors.PipelineError: Successfully imported module comp.A.B but can't find it in the component registry.This is unexpected and most likely a bug.

Expected behavior
The from_dict method of the Base Pipeline to support external exported symbols

To Reproduce

  1. Write a package structure as in the previous example
  2. create a new project
  3. import the package
  4. write the yaml with the exported name
  5. write the following code:
from haystack import Pipeline


ptext = """
components:
   b:
     init_parameters:... 
    type: comp.A.B.BComponent
"""

p = Pipeline.loads(ptext)
  1. execute the code

FAQ Check

System:

  • OS: MacOS M4 Pro (doesn't matter... even in x86 docker images is the same)
  • Haystack version (commit or version number): 2.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 High priority, add to the next sprint
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants