Skip to content

Commit

Permalink
Implement the new Job Manager in ROI Extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvrajjain2003 committed Dec 1, 2023
1 parent 61a51eb commit 2f6b1a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion clpipe/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def add_job(self, job):
def compilejobstrings(self):
header = self.createsubmissionhead()
for job in self.jobs:
temp = header.format(jobid=job.jobID, cmdwrap=job.jobString)
temp = header.format(jobid=job.job_name, cmdwrap=job.job_string)
self.submission_list.append(temp)

def compile_job_strings(self):
Expand Down
24 changes: 13 additions & 11 deletions clpipe/roi_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import glob
import shutil
from .config.options import ProjectOptions
from .job_manager import BatchManager, Job
from .job_manager import JobManagerFactory
from pkg_resources import resource_stream, resource_filename
from .errors import MaskFileNotFoundError
from .utils import get_logger, resolve_fmriprep_dir
Expand Down Expand Up @@ -90,12 +90,15 @@ def fmri_roi_extraction(
"-custom_type={custom_type} -single"
)

batch_manager = BatchManager(config.batch_config_path, config.roi_extraction.log_directory)
batch_manager.update_mem_usage(config.roi_extraction.memory_usage)
batch_manager.update_time(config.roi_extraction.time_usage)
batch_manager.update_nthreads(config.roi_extraction.n_threads)
batch_manager.update_email(config.email_address)
batch_manager.createsubmissionhead()
batch_manager = JobManagerFactory.get(
batch_config=config.batch_config_path,
output_directory=config.roi_extraction.log_directory,
mem_use=config.roi_extraction.time_usage,
time=config.roi_extraction.time_usage,
threads=config.roi_extraction.n_threads,
email=config.email_address
)

for subject in sublist:
logger.debug(f"Setting up ROI extraction for subject {subject}")
for cur_atlas in atlas_list:
Expand Down Expand Up @@ -172,8 +175,9 @@ def fmri_roi_extraction(
logger.debug("Overlap ok flag set")

sub_string_temp = sub_string_temp + " " + subject
batch_manager.addjob(
Job("ROI_extract_" + subject + "_" + atlas_name, sub_string_temp)
batch_manager.add_job(
"ROI_extract_" + subject + "_" + atlas_name,
sub_string_temp
)
if single:
_fmri_roi_extract_subject(
Expand All @@ -192,10 +196,8 @@ def fmri_roi_extraction(
)
if not single:
if submit:
batch_manager.compilejobstrings()
batch_manager.submit_jobs()
else:
batch_manager.compilejobstrings()
click.echo(batch_manager.print_jobs())


Expand Down
4 changes: 2 additions & 2 deletions tests/test_batch_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def test_adding_jobs():
batch_manager.add_job(job1)

assert len(batch_manager.jobs) == 1
assert batch_manager.jobs[0].job_id == 1
assert batch_manager.jobs[0].job_name == 1
assert batch_manager.jobs[0].job_string == "echo hi"

job2 = Job(2, "additional_job")
batch_manager.add_job(job2)

assert len(batch_manager.jobs) == 2
assert batch_manager.jobs[1].job_id == 2
assert batch_manager.jobs[1].job_name == 2
assert batch_manager.jobs[1].job_string == "additional_job"


Expand Down

0 comments on commit 2f6b1a3

Please sign in to comment.