Skip to content

Commit 8e2998a

Browse files
committed
Update image_labeling and first example of Fractal integration (ref #64)
1 parent 621b12a commit 8e2998a

File tree

8 files changed

+83
-28
lines changed

8 files changed

+83
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ monitoring.db
1313

1414
output*
1515
tmp_data
16+
LOG_*
17+
slurm-*.out
18+
Local_backup

examples/example_uzh_1_well_2x2_sites.sh

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ echo
3737

3838
echo 'Add yokogawa_to_zarr task'
3939
$CMD task add yokogawa_to_zarr zarr zarr well
40-
$CMD task list
4140
echo
4241

4342
#echo 'Add replicate_zarr_structure'
4443
#$CMD task add replicate_zarr_structure zarr zarr plate
45-
$CMD task list
46-
echo
44+
#echo
4745

48-
#echo 'Add illumination_correction'
49-
#$CMD task add illumination_correction zarr zarr well
50-
#$CMD task list
46+
echo 'Add illumination_correction'
47+
$CMD task add illumination_correction zarr zarr well
5148
echo
5249

5350
echo 'Add replicate_zarr_structure_mip'
5451
$CMD task add replicate_zarr_structure_mip zarr zarr plate
55-
$CMD task list
52+
echo
53+
54+
echo 'Add image_labeling'
55+
$CMD task add image_labeling zarr zarr well
5656
echo
5757

5858
echo 'Add maximum_intensity_projection'
@@ -64,26 +64,29 @@ echo
6464

6565
echo 'Create workflow'
6666
$CMD workflow new mwe-test wftest create_zarr_structure
67-
$CMD workflow list mwe-test
6867
echo
6968

7069
echo 'Add yokogawa_to_zarr task'
7170
$CMD workflow add-task mwe-test wftest yokogawa_to_zarr
72-
$CMD workflow list mwe-test
7371
echo
7472

75-
#echo 'Add illumination_correction'
76-
#$CMD workflow add-task mwe-test wftest illumination_correction
77-
#$CMD workflow list mwe-test
78-
#echo
73+
echo 'Add illumination_correction'
74+
$CMD workflow add-task mwe-test wftest illumination_correction
75+
echo
76+
77+
echo 'Add image_labeling'
78+
$CMD workflow add-task mwe-test wftest image_labeling
79+
echo
7980

8081
echo 'Add replicate_zarr_structure_mip'
8182
$CMD workflow add-task mwe-test wftest replicate_zarr_structure_mip
82-
$CMD workflow list mwe-test
8383
echo
8484

8585
echo 'Add maximum_intensity_projection'
8686
$CMD workflow add-task mwe-test wftest maximum_intensity_projection
87+
echo
88+
89+
echo 'Final list:'
8790
$CMD workflow list mwe-test
8891
echo
8992

examples/wf_params_uzh_1_well_2x2_sites.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"dims": [2, 2],
44
"coarsening_xy": 2,
55
"coarsening_z": 1,
6-
"num_levels": 4,
6+
"num_levels": 5,
77
"channel_file": "wf_params_uzh_cardiac_channels.json",
88
"path_dict_corr": "wf_params_uzh_cardiac_illumination.json"
99
}

fractal/dictionary_tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
Institute for Biomedical Research and Pelkmans Lab from the University of
1212
Zurich.
1313
"""
14-
1514
from fractal.tasks.create_zarr_structure import create_zarr_structure
1615
from fractal.tasks.create_zarr_structure_multifov import (
1716
create_zarr_structure_multifov,
1817
)
1918
from fractal.tasks.illumination_correction import illumination_correction
19+
from fractal.tasks.image_labeling import image_labeling
2020
from fractal.tasks.maximum_intensity_projection import (
2121
maximum_intensity_projection,
2222
)
@@ -36,3 +36,4 @@
3636
dict_tasks["maximum_intensity_projection"] = maximum_intensity_projection
3737
dict_tasks["replicate_zarr_structure"] = replicate_zarr_structure
3838
dict_tasks["illumination_correction"] = illumination_correction
39+
dict_tasks["image_labeling"] = image_labeling

fractal/fractal_cmd.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ def workflow_apply(
459459
path_dict_channels = params["channel_file"]
460460
path_dict_corr = params["path_dict_corr"]
461461
delete_input = params.get("delete_input", False)
462+
labeling_channel = params.get("labeling_channel", "A01_C01")
462463

463464
# FIXME validate tasks somewhere?
464465

@@ -478,10 +479,27 @@ def workflow_apply(
478479
exclusive=fractal_config.exclusive,
479480
)
480481
htex = define_HighThroughputExecutor(
481-
provider=provider, max_workers=fractal_config.max_workers
482+
provider=provider,
483+
max_workers=fractal_config.max_workers,
484+
label="cpu",
482485
)
486+
provider_gpu = define_SlurmProvider(
487+
nodes_per_block=fractal_config.nodes_per_block,
488+
cores_per_node=fractal_config.cores_per_node,
489+
mem_per_node_GB=fractal_config.mem_per_node_GB,
490+
partition=fractal_config.partition_gpu,
491+
worker_init=fractal_config.worker_init,
492+
max_blocks=fractal_config.max_blocks,
493+
exclusive=fractal_config.exclusive,
494+
)
495+
htex_gpu = define_HighThroughputExecutor(
496+
provider=provider_gpu,
497+
max_workers=fractal_config.max_workers,
498+
label="gpu",
499+
)
500+
483501
monitoring = define_MonitoringHub(workflow_name=workflow_name)
484-
config = Config(executors=[htex], monitoring=monitoring)
502+
config = Config(executors=[htex, htex_gpu], monitoring=monitoring)
485503
# config = Config(executors=[htex])
486504
parsl.clear()
487505
parsl.load(config)
@@ -490,7 +508,7 @@ def workflow_apply(
490508

491509
debug(dict_tasks)
492510

493-
@parsl.python_app
511+
@parsl.python_app(executors=["cpu"])
494512
def collect_intermediate_results(inputs=[]):
495513
return [x for x in inputs]
496514

@@ -507,7 +525,7 @@ def collect_intermediate_results(inputs=[]):
507525
num_levels=num_levels,
508526
)
509527

510-
@parsl.python_app
528+
@parsl.python_app(executors=["cpu"])
511529
def app_create_zarr_structure(**kwargs_):
512530
os.environ["OPENBLAS_NUM_THREADS"] = OPENBLAS_NUM_THREADS
513531
import fractal.dictionary_tasks # noqa: F401
@@ -542,6 +560,7 @@ def app_create_zarr_structure(**kwargs_):
542560
"yokogawa_to_zarr and take a global dict of paths."
543561
)
544562

563+
executor = "cpu"
545564
if task == "yokogawa_to_zarr":
546565
kwargs = dict(
547566
in_path=resources_in[0], # FIXME
@@ -582,8 +601,15 @@ def app_create_zarr_structure(**kwargs_):
582601
overwrite=True,
583602
# background=background,
584603
)
604+
elif task == "image_labeling":
605+
kwargs = dict(
606+
chl_list=chl_list,
607+
coarsening_xy=coarsening_xy,
608+
labeling_channel=labeling_channel,
609+
)
610+
executor = "gpu"
585611

586-
@python_app
612+
@python_app(executors=[executor])
587613
def app(zarrurl, **kwargs_):
588614
os.environ["OPENBLAS_NUM_THREADS"] = OPENBLAS_NUM_THREADS
589615
import fractal.dictionary_tasks # noqa: F401

fractal/fractal_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
Institute for Biomedical Research and Pelkmans Lab from the University of
1212
Zurich.
1313
"""
14-
1514
# Parameters of parsl.executors.HighThroughputExecutor
16-
max_workers = 1 # This is the maximum number of workers per block
15+
max_workers = 2 # This is the maximum number of workers per block
1716

1817
# Parameters of parsl.providers.SlurmProvider
1918
# Note that worker_init is a command which is included at the beginning of
2019
# each SLURM submission scripts
2120
nodes_per_block = 1 # This implies that a block corresponds to a node
22-
max_blocks = 15 # Maximum number of blocks (=nodes) that parsl can use
21+
max_blocks = 24 # Maximum number of blocks (=nodes) that parsl can use
2322
exclusive = False
2423
cores_per_node = 16
2524
mem_per_node_GB = 60
2625
partition = "main"
26+
partition_gpu = "gpu"
2727
worker_init = "source /opt/easybuild/software/Anaconda3/2019.07/"
2828
worker_init += "etc/profile.d/conda.sh\n"
2929
worker_init += "conda activate fractal"

fractal/parsl_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
Institute for Biomedical Research and Pelkmans Lab from the University of
1212
Zurich.
1313
"""
14-
1514
from parsl.addresses import address_by_hostname
1615
from parsl.channels import LocalChannel
1716
from parsl.executors import HighThroughputExecutor
@@ -57,17 +56,18 @@ def define_SlurmProvider(
5756
parallelism=1,
5857
exclusive=exclusive,
5958
)
59+
6060
return slurm
6161

6262

63-
def define_HighThroughputExecutor(provider=None, max_workers=40):
63+
def define_HighThroughputExecutor(provider=None, max_workers=40, label="htex"):
6464

6565
htex = HighThroughputExecutor(
66-
label="htex",
66+
label=label,
6767
address=address_by_hostname(),
6868
# worker_debug=True,
6969
max_workers=max_workers,
70-
cores_per_worker=8,
70+
cores_per_worker=16,
7171
provider=provider,
7272
cpu_affinity="block",
7373
)

fractal/tasks/image_labeling.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,30 @@ def image_labeling(
256256
parser.add_argument(
257257
"-z", "--zarrurl", help="zarr url, at the FOV level", required=True
258258
)
259+
parser.add_argument(
260+
"-C",
261+
"--chl_list",
262+
nargs="+",
263+
help="list of channel names (e.g. A01_C01)",
264+
)
265+
parser.add_argument(
266+
"-cxy",
267+
"--coarsening_xy",
268+
default=2,
269+
type=int,
270+
help="coarsening factor along X and Y (optional, defaults to 2)",
271+
)
272+
parser.add_argument(
273+
"-lc",
274+
"--labeling_channel",
275+
help="name of channel for labeling (e.g. A01_C01)",
276+
)
259277

260278
args = parser.parse_args()
261279
image_labeling(
262280
args.zarrurl,
281+
coarsening_xy=args.coarsening_xy,
282+
chl_list=args.chl_list,
283+
labeling_channel=args.labeling_channel,
284+
# FIXME: more arguments
263285
)

0 commit comments

Comments
 (0)