Skip to content

Commit

Permalink
update resources
Browse files Browse the repository at this point in the history
- cores_per_rule -> total_cores
- added total_mem_mb
- better calculation of resources for tif_to_zarr (mem-based calc of
threads)
- snakefmt
  • Loading branch information
akhanf committed Oct 7, 2024
1 parent e88ba56 commit f1f4ba6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
4 changes: 3 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ remote_creds: '~/.config/gcloud/application_default_credentials.json' #this is n

write_ome_zarr_direct: True #use this to skip writing the final zarr output to work first and copying afterwards -- useful when work is not a fast local disk

cores_per_rule: 32
#total resources available, used to set rule resources
total_cores: 32
total_mem_mb: 128000

#import wildcards: tilex, tiley, channel, zslice (and prefix - unused)
import_blaze:
Expand Down
2 changes: 1 addition & 1 deletion workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rule all:
input:
get_all_targets(),
get_bids_toplevel_targets(),
# get_qc_targets(), #need to skip this if using prestitched
# get_qc_targets(), #need to skip this if using prestitched
localrule: True


Expand Down
16 changes: 8 additions & 8 deletions workflow/rules/bigstitcher.smk
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ rule zarr_to_bdv:
desc="{desc}",
suffix="log.txt",
),
threads: config["cores_per_rule"]
threads: config["total_cores"]
group:
"preproc"
container:
Expand Down Expand Up @@ -152,8 +152,8 @@ rule bigstitcher_stitching:
config["containers"]["spimprep"]
resources:
runtime=30,
mem_mb=40000,
threads: config["cores_per_rule"]
mem_mb=int(config["total_mem_mb"] * 0.9),
threads: config["total_cores"]
group:
"preproc"
shell:
Expand Down Expand Up @@ -216,8 +216,8 @@ rule bigstitcher_solver:
config["containers"]["spimprep"]
resources:
runtime=30,
mem_mb=40000,
threads: config["cores_per_rule"]
mem_mb=int(config["total_mem_mb"] * 0.9),
threads: config["total_cores"]
group:
"preproc"
shell:
Expand All @@ -226,7 +226,7 @@ rule bigstitcher_solver:
" -s STITCHING --lambda 0.1 "
" {params.method} && "
"{params.rm_old_xml}"
#lambda 0.1 is default (can expose this if needed)


rule bigstitcher_fusion:
input:
Expand Down Expand Up @@ -310,8 +310,8 @@ rule bigstitcher_fusion:
config["containers"]["spimprep"]
resources:
runtime=30,
mem_mb=30000,
threads: config["cores_per_rule"]
mem_mb=int(config["total_mem_mb"] * 0.9),
threads: config["total_cores"]
group:
"preproc"
shell:
Expand Down
2 changes: 0 additions & 2 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def get_all_subj_html(wildcards):
htmls = []

for i in range(len(datasets)):

html = "{root}/qc/sub-{subject}_sample-{sample}_acq-{acq}/subject.html".format(
root=root,
subject=datasets.loc[i, "subject"],
Expand Down Expand Up @@ -257,7 +256,6 @@ def get_stains(wildcards):
return df.iloc[0][stain_columns].dropna().tolist()



def get_output_ome_zarr_uri():
if is_remote(config["root"]):
return _bids(
Expand Down
8 changes: 6 additions & 2 deletions workflow/rules/flatfield_corr.smk
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ rule apply_basic_flatfield_corr:
allow_missing=True,
),
params:
out_chunks=[128, 128, 128],
out_chunks=[
config["bigstitcher"]["fuse_dataset"]["block_size_z"],
config["bigstitcher"]["fuse_dataset"]["block_size_y"],
config["bigstitcher"]["fuse_dataset"]["block_size_x"],
],
output:
zarr=temp(
directory(
Expand Down Expand Up @@ -115,7 +119,7 @@ rule apply_basic_flatfield_corr:
resources:
runtime=60,
mem_mb=32000,
threads: config["cores_per_rule"]
threads: config["total_cores"]
group:
"preproc"
script:
Expand Down
8 changes: 6 additions & 2 deletions workflow/rules/import.smk
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ rule tif_to_zarr:
),
group:
"preproc"
threads: config["cores_per_rule"]
resources:
mem_mb=config["total_mem_mb"],
threads: int(config["total_mem_mb"] / 8000) #this is memory-limited -- seems to need ~8000mb for each thread, so threads=total_mem_mb / 8000
container:
config["containers"]["spimprep"]
script:
Expand Down Expand Up @@ -280,7 +282,9 @@ rule tif_to_zarr_gcs:
),
group:
"preproc"
threads: 16
resources:
mem_mb=config["total_mem_mb"],
threads: int(config["total_mem_mb"] / 8000) #this is memory-limited -- seems to need ~8000mb for each thread, so threads=total_mem_mb / 8000
container:
config["containers"]["spimprep"]
script:
Expand Down
12 changes: 8 additions & 4 deletions workflow/rules/ome_zarr.smk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


rule zarr_to_ome_zarr:
input:
**get_storage_creds(),
Expand Down Expand Up @@ -27,7 +29,9 @@ rule zarr_to_ome_zarr:
storage_provider_settings=workflow.storage_provider_settings,
output:
**get_output_ome_zarr("blaze"),
threads: config["cores_per_rule"]
resources:
mem_mb=config["total_mem_mb"],
threads: config["total_cores"]
log:
bids(
root="logs",
Expand Down Expand Up @@ -77,10 +81,10 @@ rule tif_stacks_to_ome_zarr:
config["containers"]["spimprep"]
group:
"preproc"
threads: config["cores_per_rule"]
threads: config["total_cores"]
resources:
runtime=360,
mem_mb=32000,
mem_mb=config["total_mem_mb"],
script:
"../scripts/tif_stacks_to_ome_zarr.py"

Expand Down Expand Up @@ -165,7 +169,7 @@ rule ome_zarr_to_nii:
),
group:
"preproc"
threads: config["cores_per_rule"]
threads: config["total_cores"]
container:
config["containers"]["spimprep"]
script:
Expand Down

0 comments on commit f1f4ba6

Please sign in to comment.