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

Cannot use cachier with tqdm.contrib.concurrent.process_map or thread_map #92

Open
NicolasMICAUX opened this issue Sep 11, 2022 · 4 comments
Labels
bug complex issue help wanted stale Issues and PRs that seem abandoned by their authors.

Comments

@NicolasMICAUX
Copy link

Hi,
When using @cachier with tqdm utility for multiprocessing or multithreading, cachier always get stuck in what seems to be an infinite loop.
I tried playing with the decorator args, but without success.

@NicolasMICAUX NicolasMICAUX changed the title Cannot use cachier with from tqdm.contrib.concurrent import process_map or thread_map Cannot use cachier with tqdm.contrib.concurrent.process_map or thread_map Sep 11, 2022
@shaypal5
Copy link
Collaborator

Could you please share a simplified code example? :)

@shaypal5 shaypal5 added the bug label Sep 11, 2022
@NicolasMICAUX
Copy link
Author

NicolasMICAUX commented Oct 16, 2022

Hi, back with some code example:

With pandarallel (pandas in parallel):

"""Test pandarallel with cachier."""

from cachier import cachier
import pandas as pd
from pandarallel import pandarallel


@cachier(stale_after=86400)
def _worker(x):
    return x + 1


def worker(x):
    return _worker(x)


def main():
    """Main function."""
    df = pd.DataFrame({"x": range(100)})
    pandarallel.initialize(progress_bar=True)
    df["y"] = df["x"].parallel_apply(worker)
    print(df)


if __name__ == "__main__":
    # _worker.clear_cache()
    main()

The first time, it runs fine. But if I relaunch the script just after (hopefully with the cache), I get error:
EDIT : THIS DOESN'T SEEM TO BE AN ERROR CAUSED BY CACHIER.

If I replace df["x"].parallel_apply(worker) by df["x"].parallel_apply(_worker), it does not progress at all (progressbar blocked).

@NicolasMICAUX
Copy link
Author

NicolasMICAUX commented Oct 16, 2022

With tqdm.process_map now:

"""Test tqdm.process_map with cachier."""
from cachier import cachier
from tqdm.contrib.concurrent import process_map


@cachier(stale_after=86400)
def _worker(x):
    return x + 1


def worker(x):
    return _worker(x)


def main():
    """Main function."""
    data = list(range(100))
    result = process_map(worker, data, max_workers=4)
    print(result)


if __name__ == "__main__":
    # _worker.clear_cache()
    main()

First time, it runs fine.
Second time (hopefully use cachier), progressbar is blocked: 0%| | 0/100 [00:00<?, ?it/s]

@shaypal5 shaypal5 added help wanted stale Issues and PRs that seem abandoned by their authors. complex issue labels Jun 30, 2023
@Borda
Copy link
Contributor

Borda commented Nov 1, 2024

@NicolasMICAUX not sure what am I doing now, but it does not run for me...
Copied the code sample and run locally and it does not show anything and finish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug complex issue help wanted stale Issues and PRs that seem abandoned by their authors.
Projects
None yet
Development

No branches or pull requests

3 participants