Skip to content

Commit ff71504

Browse files
author
Jon Palmer
committed
fix default predict after memory changes
1 parent 8652117 commit ff71504

File tree

2 files changed

+20
-55
lines changed

2 files changed

+20
-55
lines changed

funannotate2/predict.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,15 @@ def predict(args):
304304
logger.info("Parsing alignments and generating hintsfile for augustus")
305305
evidence2hints(ProtAlign, TranAlign, contigs, tmp_dir)
306306

307-
# now run ab intio in parallel
308-
abinit_cmds = []
309-
for c in contigs:
310-
abinit_cmds.append((c, params, logger))
311-
312307
# Check if memory monitoring is enabled
313308
monitor_memory = getattr(args, "monitor_memory", False)
314309
memory_limit = getattr(args, "memory_limit", None)
315310

311+
# now run ab intio in parallel
312+
abinit_cmds = []
313+
for c in contigs:
314+
abinit_cmds.append((c, params, logger, monitor_memory))
315+
316316
if monitor_memory:
317317
logger.info("Memory monitoring enabled for ab initio predictions")
318318
if memory_limit:
@@ -375,8 +375,6 @@ def predict(args):
375375
abinitio_wrapper,
376376
abinit_cmds,
377377
cpus=args.cpus,
378-
monitor_memory=monitor_memory,
379-
memory_limit_gb=memory_limit,
380378
)
381379

382380
# get all predictions

funannotate2/utilities.py

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,18 +1076,8 @@ def update(res):
10761076
def handle_error(error):
10771077
print(f"Error: {error}", flush=True)
10781078

1079-
# Handle memory monitoring by modifying the input arguments instead of using a wrapper
1080-
if monitor_memory:
1081-
# Modify the input arguments to include monitor_memory flag
1082-
modified_inputList = []
1083-
for i in inputList:
1084-
if isinstance(i, (list, tuple)):
1085-
# Convert to list and add monitor_memory as keyword argument
1086-
# We'll handle this in the function call by unpacking properly
1087-
modified_inputList.append(list(i) + [monitor_memory])
1088-
else:
1089-
modified_inputList.append((i, monitor_memory))
1090-
inputList = modified_inputList
1079+
# Note: monitor_memory is now handled by the individual functions themselves
1080+
# No need to modify inputList here since functions receive monitor_memory as a parameter
10911081

10921082
actual_function = function
10931083

@@ -1096,43 +1086,20 @@ def handle_error(error):
10961086
# setup results and split over cpus
10971087
results = []
10981088
for i in inputList:
1099-
if isinstance(i, list):
1100-
if monitor_memory and len(i) >= 4:
1101-
# Handle the case where monitor_memory was added as the 4th argument
1102-
# Call function with monitor_memory as keyword argument
1103-
args = i[:-1] # All arguments except the last one (monitor_memory)
1104-
kwargs = {"monitor_memory": i[-1]}
1105-
p.apply_async(
1106-
actual_function,
1107-
args=args,
1108-
kwds=kwargs,
1109-
callback=update,
1110-
error_callback=handle_error,
1111-
)
1112-
else:
1113-
p.apply_async(
1114-
actual_function,
1115-
args=i,
1116-
callback=update,
1117-
error_callback=handle_error,
1118-
)
1089+
if isinstance(i, (list, tuple)):
1090+
p.apply_async(
1091+
actual_function,
1092+
args=i,
1093+
callback=update,
1094+
error_callback=handle_error,
1095+
)
11191096
else:
1120-
if monitor_memory and isinstance(i, tuple) and len(i) == 2:
1121-
# Handle the case where monitor_memory was added as the 2nd argument
1122-
p.apply_async(
1123-
actual_function,
1124-
args=(i[0],),
1125-
kwds={"monitor_memory": i[1]},
1126-
callback=update,
1127-
error_callback=handle_error,
1128-
)
1129-
else:
1130-
p.apply_async(
1131-
actual_function,
1132-
args=(i,),
1133-
callback=update,
1134-
error_callback=handle_error,
1135-
)
1097+
p.apply_async(
1098+
actual_function,
1099+
args=(i,),
1100+
callback=update,
1101+
error_callback=handle_error,
1102+
)
11361103
p.close()
11371104
p.join()
11381105
return results

0 commit comments

Comments
 (0)