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

Pool decorator doesn't allow 3rd party multiprocessing map functors #535

Closed
dmitrymyl opened this issue Aug 21, 2024 · 0 comments
Closed

Comments

@dmitrymyl
Copy link

Hey! I tried to run cooltools.pileup with a custom map_functor, but it threw an error:
image

It seems the issue is with the cooltools.lib.common.pool_decorator, specifically on this line and the last line in the code snippet below:

    @wraps(func)
    def wrapper(*args, **kwargs):
        # If alternative or third party map functors are provided
        if "map_functor" in kwargs.keys():
            logging.info(f"using an alternative map functor: {kwargs['map_functor']}")
            return func(*args, **kwargs, map_functor=kwargs["map_functor"])

"map_functor" is passed twice to the func: once in **kwargs and next in map_functor=kwargs["map_functor"], and that's why it breaks.

To fix that, I suggest a patch to the last line, so that it would look like:

    @wraps(func)
    def wrapper(*args, **kwargs):
        # If alternative or third party map functors are provided
        if "map_functor" in kwargs.keys():
            logging.info(f"using an alternative map functor: {kwargs['map_functor']}")
            return func(*args, **kwargs)

As a workaround before the patch, I am using cooltools.pileup.__wrapped__, which strips the pool_decorator away.

Hope it will help improve the package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant