Skip to content
Snippets Groups Projects
Commit 0b516afe authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

feature: offer copy config.yaml from working directory

parent c52b6c17
No related branches found
No related tags found
No related merge requests found
......@@ -394,6 +394,10 @@ public class Job {
synchronization.close();
}
public Path getInputDirectory() {
return inputDirectory;
}
private void storeInputOutputDirectory() {
if (inputDirectory == null) {
useDemoData = true;
......
......@@ -41,7 +41,6 @@ import cz.it4i.fiji.haas.HaaSOutputHolder;
import cz.it4i.fiji.haas.HaaSOutputHolderImpl;
import cz.it4i.fiji.haas.Job;
import cz.it4i.fiji.haas.JobManager;
import cz.it4i.fiji.haas.UploadingFileFromResource;
import cz.it4i.fiji.haas_java_client.JobState;
import cz.it4i.fiji.haas_java_client.ProgressNotifier;
import cz.it4i.fiji.haas_java_client.Settings;
......@@ -259,6 +258,14 @@ public class BenchmarkJobManager implements Closeable {
public String toString() {
return "" + getId();
}
public void storeDataInWorkdirectory(UploadingFile file) throws IOException {
job.storeDataInWorkdirectory(file);
}
public Path getInputDirectory() {
return job.getInputDirectory();
}
private ProgressNotifier convertTo(Progress progress) {
return progress == null ? null : new P_ProgressNotifierAdapter(progress);
......@@ -453,6 +460,7 @@ public class BenchmarkJobManager implements Closeable {
Stream<BenchmarkError> taskSpecificErrors = tasks.stream().flatMap(s -> s.getErrors().stream());
return Stream.concat(nonTaskSpecificErrors.stream(), taskSpecificErrors).collect(Collectors.toList());
}
}
public BenchmarkJobManager(BenchmarkSPIMParameters params) throws IOException {
......@@ -462,9 +470,6 @@ public class BenchmarkJobManager implements Closeable {
public BenchmarkJob createJob(Function<Path, Path> inputDirectoryProvider,
Function<Path, Path> outputDirectoryProvider) throws IOException {
Job job = jobManager.createJob(inputDirectoryProvider, outputDirectoryProvider);
if (job.isUseDemoData()) {
job.storeDataInWorkdirectory(getConfigYamlFile());
}
return convertJob(job);
}
......@@ -578,10 +583,7 @@ public class BenchmarkJobManager implements Closeable {
jobManager.close();
}
private UploadingFile getConfigYamlFile() {
return new UploadingFileFromResource("", Constants.CONFIG_YAML);
}
private BenchmarkJob convertJob(Job job) {
return new BenchmarkJob(job);
}
......
......@@ -3,6 +3,7 @@ package cz.it4i.fiji.haas_spim_benchmark.ui;
import java.awt.Desktop;
import java.awt.Window;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.EnumSet;
import java.util.HashSet;
......@@ -20,9 +21,11 @@ import java.util.function.Function;
import javax.swing.WindowConstants;
import org.apache.commons.lang3.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cz.it4i.fiji.haas.UploadingFileFromResource;
import cz.it4i.fiji.haas.ui.CloseableControl;
import cz.it4i.fiji.haas.ui.DummyProgress;
import cz.it4i.fiji.haas.ui.InitiableControl;
......@@ -31,6 +34,7 @@ import cz.it4i.fiji.haas.ui.ModalDialogs;
import cz.it4i.fiji.haas.ui.ProgressDialog;
import cz.it4i.fiji.haas.ui.TableViewContextMenu;
import cz.it4i.fiji.haas_java_client.JobState;
import cz.it4i.fiji.haas_java_client.UploadingFile;
import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager;
import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob;
import cz.it4i.fiji.haas_spim_benchmark.core.Constants;
......@@ -160,15 +164,33 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont
private void askForCreateJob() {
NewJobWindow newJobWindow = new NewJobWindow(null);
ModalDialogs.doModal(newJobWindow, WindowConstants.DISPOSE_ON_CLOSE);
newJobWindow.setCreatePressedNotifier(() -> executeWSCallAsync("Creating job", false,p -> doCreateJob(wd -> newJobWindow.getInputDirectory(wd), wd -> newJobWindow.getOutputDirectory(wd))));
newJobWindow.setCreatePressedNotifier(() -> executeWSCallAsync("Creating job", false,
new P_JobAction() {
@Override
public void doAction(Progress p) throws IOException {
BenchmarkJob job = doCreateJob(wd -> newJobWindow.getInputDirectory(wd), wd -> newJobWindow.getOutputDirectory(wd));
if (job.isUseDemoData()) {
job.storeDataInWorkdirectory(getConfigYamlFile());
} else if (Files.exists(job.getInputDirectory().resolve(Constants.CONFIG_YAML))) {
throw new NotImplementedException("");
}
}
}
));
}
private void doCreateJob(Function<Path,Path> inputProvider, Function<Path,Path> outputProvider) throws IOException {
private UploadingFile getConfigYamlFile() {
return new UploadingFileFromResource("", Constants.CONFIG_YAML);
}
private BenchmarkJob doCreateJob(Function<Path,Path> inputProvider, Function<Path,Path> outputProvider) throws IOException {
BenchmarkJob bj = manager.createJob(inputProvider, outputProvider);
ObservableBenchmarkJob obj = registry.addIfAbsent(bj);
addJobToItems(obj);
jobs.refresh();
return bj;
}
private synchronized void addJobToItems(ObservableBenchmarkJob obj) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment