GithubHelp home page GithubHelp logo

Comments (3)

FloRul avatar FloRul commented on June 8, 2024

I worked around by tweaking the callable_serialization.py :

import inspect
import sys
from typing import Callable, Optional

from haystack import DeserializationError


def serialize_callable(callable_handle: Callable) -> str:
    """
    Serializes a callable to its full path.
    :param callable_handle: The callable to serialize
    :return: The full path of the callable
    """
    if callable_handle is None:
        return "None"

    module = inspect.getmodule(callable_handle)

    # Get the full package path of the function
    if module is not None:
        full_path = f"{module.__name__}.{callable_handle.__name__}"
    else:
        full_path = callable_handle.__name__
    return full_path


def deserialize_callable(callable_handle: str) -> Optional[Callable]:
    """
    Deserializes a callable given its full import path as a string.
    :param callable_handle: The full path of the callable_handle
    :return: The callable
    :raises DeserializationError: If the callable cannot be found
    """
    if callable_handle == "None":
        return None

    parts = callable_handle.split(".")
    module_name = ".".join(parts[:-1])
    function_name = parts[-1]
    module = sys.modules.get(module_name, None)
    if not module:
        raise DeserializationError(f"Could not locate the module of the callable: {module_name}")
    streaming_callback = getattr(module, function_name, None)
    if not streaming_callback:
        raise DeserializationError(f"Could not locate the callable: {function_name}")
    return streaming_callback

from haystack.

FloRul avatar FloRul commented on June 8, 2024

Investigating further I think the problem is rather with the bedrock integration itself and not the serialization utils

from haystack.

FloRul avatar FloRul commented on June 8, 2024

Found the right repo to post the issue, sorry

from haystack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.