Skip to content

Commit 22c612e

Browse files
author
MartinBuessemeyer
committed
Merge branch 'master' into verbose_default
2 parents 5700581 + 8e5ff90 commit 22c612e

File tree

5 files changed

+19
-29
lines changed

5 files changed

+19
-29
lines changed

wkcuber/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ def create_parser():
8383
args.layer_name,
8484
args.dtype,
8585
args.batch_size,
86-
args.jobs,
8786
args,
8887
)
8988

9089
if not args.no_compress:
91-
compress_mag_inplace(args.target_path, args.layer_name, Mag(1), args.jobs, args)
90+
compress_mag_inplace(args.target_path, args.layer_name, Mag(1), args)
9291

9392
downsample_mags(
9493
args.target_path,
@@ -97,7 +96,6 @@ def create_parser():
9796
Mag(args.max_mag),
9897
"default",
9998
DEFAULT_EDGE_LEN,
100-
args.jobs,
10199
not args.no_compress,
102100
)
103101

wkcuber/compress.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def compress_file_job(source_path, target_path):
7272
raise exc
7373

7474

75-
def compress_mag(source_path, layer_name, target_path, mag: Mag, jobs, args=None):
75+
def compress_mag(source_path, layer_name, target_path, mag: Mag, args=None):
7676
if path.exists(path.join(target_path, layer_name, str(mag))):
7777
logging.error("Target path '{}' already exists".format(target_path))
7878
exit(1)
@@ -98,9 +98,9 @@ def compress_mag(source_path, layer_name, target_path, mag: Mag, jobs, args=None
9898
logging.info("Mag {0} successfully compressed".format(str(mag)))
9999

100100

101-
def compress_mag_inplace(target_path, layer_name, mag: Mag, jobs, args=None):
101+
def compress_mag_inplace(target_path, layer_name, mag: Mag, args=None):
102102
compress_target_path = "{}.compress-{}".format(target_path, uuid4())
103-
compress_mag(target_path, layer_name, compress_target_path, mag, jobs, args)
103+
compress_mag(target_path, layer_name, compress_target_path, mag, args)
104104

105105
shutil.rmtree(path.join(target_path, layer_name, str(mag)))
106106
shutil.move(
@@ -111,7 +111,7 @@ def compress_mag_inplace(target_path, layer_name, mag: Mag, jobs, args=None):
111111

112112

113113
def compress_mags(
114-
source_path, layer_name, target_path=None, mags: List[Mag] = None, jobs=1, args=None
114+
source_path, layer_name, target_path=None, mags: List[Mag] = None, args=None
115115
):
116116
with_tmp_dir = target_path is None
117117
target_path = source_path + ".tmp" if with_tmp_dir else target_path
@@ -121,7 +121,7 @@ def compress_mags(
121121
mags.sort()
122122

123123
for mag in mags:
124-
compress_mag(source_path, layer_name, target_path, mag, jobs, args)
124+
compress_mag(source_path, layer_name, target_path, mag, args)
125125

126126
if with_tmp_dir:
127127
makedirs(path.join(source_path + ".bak", layer_name), exist_ok=True)
@@ -146,11 +146,4 @@ def compress_mags(
146146
args = create_parser().parse_args()
147147
if args.verbose:
148148
logging.basicConfig(level=logging.DEBUG)
149-
compress_mags(
150-
args.source_path,
151-
args.layer_name,
152-
args.target_path,
153-
args.mag,
154-
int(args.jobs),
155-
args,
156-
)
149+
compress_mags(args.source_path, args.layer_name, args.target_path, args.mag, args)

wkcuber/cubing.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def cubing_job(
144144
raise exc
145145

146146

147-
def cubing(
148-
source_path, target_path, layer_name, dtype, batch_size, jobs, args=None
149-
) -> dict:
147+
def cubing(source_path, target_path, layer_name, dtype, batch_size, args=None) -> dict:
150148

151149
target_wkw_info = WkwDatasetInfo(target_path, layer_name, dtype, 1)
152150
source_files = find_source_filenames(source_path)
@@ -198,6 +196,5 @@ def cubing(
198196
args.layer_name,
199197
args.dtype,
200198
args.batch_size,
201-
args.jobs,
202199
args=args,
203200
)

wkcuber/downsampling.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def downsample(
114114
target_mag: Mag,
115115
interpolation_mode,
116116
cube_edge_len,
117-
jobs,
118117
compress,
119118
args=None,
120119
):
@@ -401,7 +400,6 @@ def downsample_mag(
401400
target_mag: Mag,
402401
interpolation_mode="default",
403402
cube_edge_len=DEFAULT_EDGE_LEN,
404-
jobs=1,
405403
compress=False,
406404
args=None,
407405
):
@@ -426,7 +424,6 @@ def downsample_mag(
426424
target_mag,
427425
interpolation_mode,
428426
cube_edge_len,
429-
jobs,
430427
compress,
431428
args,
432429
)
@@ -439,7 +436,6 @@ def downsample_mags(
439436
max_mag: Mag,
440437
interpolation_mode,
441438
cube_edge_len,
442-
jobs,
443439
compress,
444440
args=None,
445441
):
@@ -453,7 +449,6 @@ def downsample_mags(
453449
target_mag,
454450
interpolation_mode,
455451
cube_edge_len,
456-
jobs,
457452
compress,
458453
args,
459454
)
@@ -478,7 +473,6 @@ def downsample_mags(
478473
anisotropic_target_mag,
479474
args.interpolation_mode,
480475
args.buffer_cube_size,
481-
args.jobs,
482476
args.compress,
483477
args,
484478
)
@@ -490,7 +484,6 @@ def downsample_mags(
490484
max_mag,
491485
args.interpolation_mode,
492486
args.buffer_cube_size,
493-
args.jobs,
494487
args.compress,
495488
args,
496489
)

wkcuber/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,17 @@ def get_executor_for_args(args):
116116
executor = None
117117

118118
if args.distribution_strategy == "multiprocessing":
119-
executor = cluster_tools.get_executor("multiprocessing", args.jobs)
120-
logging.info("Using pool of {} workers.".format(args.jobs))
119+
# Also accept "processes" instead of job to be compatible with segmentation-tools.
120+
# In the long run, the args should be unified and provided by the clustertools.
121+
if "jobs" in args:
122+
jobs = args.jobs
123+
elif "processes" in args:
124+
jobs = args.processes
125+
else:
126+
jobs = cpu_count()
127+
128+
executor = cluster_tools.get_executor("multiprocessing", jobs)
129+
logging.info("Using pool of {} workers.".format(jobs))
121130
elif args.distribution_strategy == "slurm":
122131
if args.job_resources is None:
123132
raise argparse.ArgumentTypeError(

0 commit comments

Comments
 (0)