Skip to content

Commit

Permalink
cli demos: make amount of parallelism in the backend a CLI parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
pgunn committed Nov 16, 2023
1 parent 9b999db commit 77bd5e8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
5 changes: 2 additions & 3 deletions demos/general/demo_OnACID_mesoscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def main():
plt.ylabel('Processing time [ms]')

# Prepare result visualisations (might take time)
c, dview, n_processes = \
cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=None,
single_thread=False)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)
if opts.online['motion_correct']:
shifts = cnm.estimates.shifts[-cnm.estimates.C.shape[-1]:]
if not opts.motion['pw_rigid']:
Expand Down Expand Up @@ -171,6 +169,7 @@ def handle_args():
parser = argparse.ArgumentParser(description="Full OnACID Caiman demo")
parser.add_argument("--no_play", action="store_true", help="Do not display results")
parser.add_argument("--cluster_backend", default="multiprocessing", help="Specify multiprocessing, ipyparallel, or single to pick an engine")
parser.add_argument("--cluster_nproc", type=int, default=None, help="Override automatic selection of number of workers to use")
parser.add_argument("--input", action="append", help="File(s) to work on, provide multiple times for more files")
parser.add_argument("--logfile", help="If specified, log to the named file")
return parser.parse_args()
Expand Down
3 changes: 2 additions & 1 deletion demos/general/demo_caiman_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def main():
opts = params.CNMFParams(params_dict=params_dict)

# start a cluster for parallel processing
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)


# Run CaImAn Batch (CNMF)
Expand Down Expand Up @@ -170,6 +170,7 @@ def handle_args():
parser.add_argument("--no_patches", action="store_true", help="Do not use patches")
parser.add_argument("--no_play", action="store_true", help="Do not display results")
parser.add_argument("--cluster_backend", default="multiprocessing", help="Specify multiprocessing, ipyparallel, or single to pick an engine")
parser.add_argument("--cluster_nproc", type=int, default=None, help="Override automatic selection of number of workers to use")
parser.add_argument("--input", action="append", help="File(s) to work on, provide multiple times for more files")
parser.add_argument("--logfile", help="If specified, log to the named file")
return parser.parse_args()
Expand Down
5 changes: 3 additions & 2 deletions demos/general/demo_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def main():
moviehandle.play(q_max=99.5, fr=60, magnification=2)

# start a cluster for parallel processing
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)

# Motion Correction
# first we create a motion correction object with the specified parameters
Expand Down Expand Up @@ -138,7 +138,7 @@ def main():

# restart cluster to clean up memory
cm.stop_server(dview=dview)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)

# Parameters for source extraction and deconvolution
p = 1 # order of the autoregressive system
Expand Down Expand Up @@ -264,6 +264,7 @@ def handle_args():
parser.add_argument("--keep_logs", action="store_true", help="Keep temporary logfiles")
parser.add_argument("--no_play", action="store_true", help="Do not display results")
parser.add_argument("--cluster_backend", default="multiprocessing", help="Specify multiprocessing, ipyparallel, or single to pick an engine")
parser.add_argument("--cluster_nproc", type=int, default=None, help="Override automatic selection of number of workers to use")
parser.add_argument("--input", action="append", help="File(s) to work on, provide multiple times for more files")
parser.add_argument("--logfile", help="If specified, log to the named file")
return parser.parse_args()
Expand Down
6 changes: 3 additions & 3 deletions demos/general/demo_pipeline_NWB.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def main():
moviehandle.play(q_max=99.5, fr=60, magnification=2)

# start a cluster for parallel processing
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)

# Motion Correction
# first we create a motion correction object with the specified parameters
Expand Down Expand Up @@ -197,8 +197,7 @@ def main():

# restart cluster to clean up memory
cm.stop_server(dview=dview)
c, dview, n_processes = cm.cluster.setup_cluster(
backend=cfg.cluster_backend, n_processes=None, single_thread=False)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)

# parameters for source extraction and deconvolution
p = 1 # order of the autoregressive system
Expand Down Expand Up @@ -331,6 +330,7 @@ def handle_args():
parser.add_argument("--keep_logs", action="store_true", help="Keep temporary logfiles")
parser.add_argument("--no_play", action="store_true", help="Do not display results")
parser.add_argument("--cluster_backend", default="multiprocessing", help="Specify multiprocessing, ipyparallel, or single to pick an engine")
parser.add_argument("--cluster_nproc", type=int, default=None, help="Override automatic selection of number of workers to use")
parser.add_argument("--input", action="append", help="File(s) to work on, provide multiple times for more files")
parser.add_argument("--logfile", help="If specified, log to the named file")
return parser.parse_args()
Expand Down
3 changes: 2 additions & 1 deletion demos/general/demo_pipeline_cnmfE.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def main():

opts = params.CNMFParams(params_dict=params_dict)

c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)
# Motion Correction
# The pw_rigid flag set above, determines where to use rigid or pw-rigid
# motion correction
Expand Down Expand Up @@ -230,6 +230,7 @@ def handle_args():
parser.add_argument("--keep_logs", action="store_true", help="Keep temporary logfiles")
parser.add_argument("--no_play", action="store_true", help="Do not display results")
parser.add_argument("--cluster_backend", default="multiprocessing", help="Specify multiprocessing, ipyparallel, or single to pick an engine")
parser.add_argument("--cluster_nproc", type=int, default=None, help="Override automatic selection of number of workers to use")
parser.add_argument("--input", action="append", help="File(s) to work on, provide multiple times for more files")
parser.add_argument("--logfile", help="If specified, log to the named file")
return parser.parse_args()
Expand Down
5 changes: 3 additions & 2 deletions demos/general/demo_pipeline_voltage_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def main():
moviehandle.play(q_max=99.5, fr=40, magnification=4)

# start a cluster for parallel processing
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)

# %%% MOTION CORRECTION
# first we create a motion correction object with the specified parameters
Expand Down Expand Up @@ -179,7 +179,7 @@ def main():

# restart cluster to clean up memory
cm.stop_server(dview=dview)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend)
c, dview, n_processes = cm.cluster.setup_cluster(backend=cfg.cluster_backend, n_processes=cfg.cluster_nproc)


# parameters for trace denoising and spike extraction
Expand Down Expand Up @@ -273,6 +273,7 @@ def handle_args():
parser.add_argument("--keep_logs", action="store_true", help="Keep temporary logfiles")
parser.add_argument("--no_play", action="store_true", help="Do not display results")
parser.add_argument("--cluster_backend", default="multiprocessing", help="Specify multiprocessing, ipyparallel, or single to pick an engine")
parser.add_argument("--cluster_nproc", type=int, default=None, help="Override automatic selection of number of workers to use")
parser.add_argument("--input", action="append", help="File(s) to work on, provide multiple times for more files")
parser.add_argument("--pathinput", action="append", help="Path input file(s) to work on, provide multiple times for more files")
parser.add_argument("--logfile", help="If specified, log to the named file")
Expand Down

0 comments on commit 77bd5e8

Please sign in to comment.