From 00309398e084b43c876337c159e299c77fe1e73b Mon Sep 17 00:00:00 2001 From: noordhee Date: Mon, 20 Jan 2025 16:41:37 +0100 Subject: [PATCH 1/5] test frelon peaksearch --- ImageD11/frelon_peaksearch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ImageD11/frelon_peaksearch.py b/ImageD11/frelon_peaksearch.py index a62c78de..72dbd9d7 100755 --- a/ImageD11/frelon_peaksearch.py +++ b/ImageD11/frelon_peaksearch.py @@ -360,7 +360,7 @@ def guess_bg(ds, scan_number=0, start=0, step=9, n=None): PKCOL = [getattr(ImageD11.cImageD11, p) for p in PKSAVE] -def process(ds, worker_args, ncpu=None): +def process(ds, worker_args, ncpu=None, **kwargs): """ Runs over the first scan in a dataset in parallel @@ -383,7 +383,7 @@ def process(ds, worker_args, ncpu=None): args = [(hname, frames_dset, i, omega[i], worker_args) for i in range(n_frames)] - all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads) + all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads, **kwargs) # make a dict to hold our results in cf_2d_dict = {} From 0267c1478e843a743f4737f540e3fd99fb139c08 Mon Sep 17 00:00:00 2001 From: noordhee Date: Mon, 20 Jan 2025 17:19:25 +0100 Subject: [PATCH 2/5] updated frelon_peaksearch --- ImageD11/frelon_peaksearch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ImageD11/frelon_peaksearch.py b/ImageD11/frelon_peaksearch.py index 72dbd9d7..15f0dcb4 100755 --- a/ImageD11/frelon_peaksearch.py +++ b/ImageD11/frelon_peaksearch.py @@ -360,7 +360,7 @@ def guess_bg(ds, scan_number=0, start=0, step=9, n=None): PKCOL = [getattr(ImageD11.cImageD11, p) for p in PKSAVE] -def process(ds, worker_args, ncpu=None, **kwargs): +def process(ds, worker_args, ncpu=None, tqdm_class=None, **kwargs): """ Runs over the first scan in a dataset in parallel @@ -383,7 +383,7 @@ def process(ds, worker_args, ncpu=None, **kwargs): args = [(hname, frames_dset, i, omega[i], worker_args) for i in range(n_frames)] - all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads, **kwargs) + all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads, tqdm_class=tqdm_class, **kwargs) # make a dict to hold our results in cf_2d_dict = {} From 9ad833e4947eb6570ff5302c639ba19475e5da26 Mon Sep 17 00:00:00 2001 From: noordhee Date: Tue, 21 Jan 2025 14:56:15 +0100 Subject: [PATCH 3/5] test in frelong_peaksearch --- ImageD11/frelon_peaksearch.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ImageD11/frelon_peaksearch.py b/ImageD11/frelon_peaksearch.py index 15f0dcb4..cfa64cc5 100755 --- a/ImageD11/frelon_peaksearch.py +++ b/ImageD11/frelon_peaksearch.py @@ -360,7 +360,7 @@ def guess_bg(ds, scan_number=0, start=0, step=9, n=None): PKCOL = [getattr(ImageD11.cImageD11, p) for p in PKSAVE] -def process(ds, worker_args, ncpu=None, tqdm_class=None, **kwargs): +def process(ds, worker_args, ncpu=None, tqdm_class=None, task_instance=None, **kwargs): """ Runs over the first scan in a dataset in parallel @@ -382,8 +382,17 @@ def process(ds, worker_args, ncpu=None, tqdm_class=None, **kwargs): n_frames = omega.shape[0] args = [(hname, frames_dset, i, omega[i], worker_args) for i in range(n_frames)] + - all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads, tqdm_class=tqdm_class, **kwargs) + if tqdm_class and task_instance: + all_peaks = process_map( + pps, args, chunksize=1, max_workers=nthreads, + tqdm_class=lambda *args, **kwargs: tqdm_class(task_instance, *args, **kwargs), + **kwargs + ) + else: + all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads) + # make a dict to hold our results in cf_2d_dict = {} From 523c4cd1cb4247b483f2a4677b7e5469dd52de71 Mon Sep 17 00:00:00 2001 From: noordhee Date: Tue, 21 Jan 2025 15:15:01 +0100 Subject: [PATCH 4/5] test frelong_peaksearch task progress update --- ImageD11/frelon_peaksearch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ImageD11/frelon_peaksearch.py b/ImageD11/frelon_peaksearch.py index cfa64cc5..21036c59 100755 --- a/ImageD11/frelon_peaksearch.py +++ b/ImageD11/frelon_peaksearch.py @@ -387,8 +387,8 @@ def process(ds, worker_args, ncpu=None, tqdm_class=None, task_instance=None, **k if tqdm_class and task_instance: all_peaks = process_map( pps, args, chunksize=1, max_workers=nthreads, - tqdm_class=lambda *args, **kwargs: tqdm_class(task_instance, *args, **kwargs), - **kwargs + tqdm_class=tqdm_class, + task_instance=task_instance, ) else: all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads) From 25970435109b33bcd16434690c6074752f52c14e Mon Sep 17 00:00:00 2001 From: noordhee Date: Wed, 22 Jan 2025 09:12:51 +0100 Subject: [PATCH 5/5] simplified process function in frelon_peaksearch.py file --- ImageD11/frelon_peaksearch.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ImageD11/frelon_peaksearch.py b/ImageD11/frelon_peaksearch.py index 21036c59..e2f28016 100755 --- a/ImageD11/frelon_peaksearch.py +++ b/ImageD11/frelon_peaksearch.py @@ -360,7 +360,7 @@ def guess_bg(ds, scan_number=0, start=0, step=9, n=None): PKCOL = [getattr(ImageD11.cImageD11, p) for p in PKSAVE] -def process(ds, worker_args, ncpu=None, tqdm_class=None, task_instance=None, **kwargs): +def process(ds, worker_args, ncpu=None, **process_map_kwargs): """ Runs over the first scan in a dataset in parallel @@ -384,15 +384,7 @@ def process(ds, worker_args, ncpu=None, tqdm_class=None, task_instance=None, **k args = [(hname, frames_dset, i, omega[i], worker_args) for i in range(n_frames)] - if tqdm_class and task_instance: - all_peaks = process_map( - pps, args, chunksize=1, max_workers=nthreads, - tqdm_class=tqdm_class, - task_instance=task_instance, - ) - else: - all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads) - + all_peaks = process_map(pps, args, chunksize=1, max_workers=nthreads, **process_map_kwargs) # make a dict to hold our results in cf_2d_dict = {}