Skip to content

Commit

Permalink
fix issue where jobs could not run in headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleisch committed Aug 9, 2024
1 parent 342eeba commit ccabc03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.googlecode.concurentlocks.ReadWriteUpdateLock;
import com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock;
import de.unijena.bioinf.ChemistryBase.jobs.SiriusJobs;
import de.unijena.bioinf.babelms.inputresource.InputResource;
import de.unijena.bioinf.jjobs.*;
import de.unijena.bioinf.ms.frontend.Run;
Expand Down Expand Up @@ -287,7 +288,10 @@ private BackgroundRunJob submitRunAndLockInstances(final BackgroundRunJob runToS
if (instances != null)
instances.forEach(i -> computingInstances.add(i.getId()));
log.info("...All instances locked!");
Jobs.submit(runToSubmit, runToSubmit::getName, psm::getName, runToSubmit::getDescription);
if (SiriusJobs.getGlobalJobManager() instanceof SwingJobManager) //todo hacky. get rid of this swing job dependency by solving job progress via api
Jobs.submit(runToSubmit, runToSubmit::getName, psm::getName, runToSubmit::getDescription);
else
SiriusJobs.getGlobalJobManager().submitJob(runToSubmit);
return runToSubmit;
} catch (Exception e) {
// just in case something goes wrong during submission, then we do not want to have locked instances
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ public void run() {
splash.setVisible(false);
splash.dispose();
}
Jobs.runEDTLater(() -> Thread.currentThread().setPriority(9));
} else {
log.info("No GUI service found. Skipping GUI startup, likely due to headless mode!");
}
Jobs.runEDTLater(() -> Thread.currentThread().setPriority(9));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@

import de.unijena.bioinf.ChemistryBase.jobs.SiriusJobs;
import de.unijena.bioinf.fingerid.fingerprints.cache.IFingerprinterCache;
import de.unijena.bioinf.jjobs.JJob;
import de.unijena.bioinf.jjobs.JobManager;
import de.unijena.bioinf.jjobs.JobSubmitter;
import de.unijena.bioinf.jjobs.ProgressJJob;
import de.unijena.bioinf.jjobs.*;
import de.unijena.bioinf.ms.frontend.core.ApplicationCore;
import de.unijena.bioinf.ms.frontend.subtools.ToolChainJob;
import de.unijena.bioinf.ms.frontend.workflow.InstanceBufferFactory;
Expand Down Expand Up @@ -104,18 +101,23 @@ public JobManager jobManager() {
}

@Bean
public InstanceBufferFactory<?> instanceBufferFactory() {
return (bufferSize, instances, tasks, dependJob, progressSupport) ->
new SimpleInstanceBuffer(bufferSize, instances, tasks, dependJob, progressSupport, new JobSubmitter() {
@Override
public <Job extends JJob<Result>, Result> Job submitJob(Job j) {
if (j instanceof ToolChainJob<?> tj) {
Jobs.submit((ProgressJJob<?>) j, j::identifier, tj::getProjectName, tj::getToolName);
return j;
} else {
return Jobs.MANAGER().submitJob(j);
public InstanceBufferFactory<?> instanceBufferFactory(JobManager jobManager) {
//todo hacky. get rid of this swing job dependency by solving job progress via api
if (jobManager instanceof SwingJobManager) {
return (bufferSize, instances, tasks, dependJob, progressSupport) ->
new SimpleInstanceBuffer(bufferSize, instances, tasks, dependJob, progressSupport, new JobSubmitter() {
@Override
public <Job extends JJob<Result>, Result> Job submitJob(Job j) {
if (j instanceof ToolChainJob<?> tj) {
Jobs.submit((ProgressJJob<?>) j, j::identifier, tj::getProjectName, tj::getToolName);
return j;
} else {
return Jobs.MANAGER().submitJob(j);
}
}
}
});
});
}else {
return new SimpleInstanceBuffer.Factory();
}
}
}

0 comments on commit ccabc03

Please sign in to comment.