Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lincs/src/org/labkey/lincs/psp/LincsPspPipelineJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.lincs.LincsModule;

public class LincsPspPipelineJob extends PipelineJob implements LincsPspJobSupport
{
Expand Down Expand Up @@ -43,7 +42,7 @@ public LincsPspPipelineJob(ViewBackgroundInfo info, PipeRoot root, ITargetedMSRu

String baseLogFileName = FileUtil.makeFileNameWithTimestamp("LincsPSP_" + (_oldPspJob != null ? "rerun_" : "") + run.getBaseName().replace(" ", "_"));

LocalDirectory localDirectory = LocalDirectory.create(root, LincsModule.NAME, baseLogFileName,
LocalDirectory localDirectory = LocalDirectory.create(root, baseLogFileName,
!root.isCloudRoot() ? root.getRootPath().getAbsolutePath() : FileUtil.getTempDirectory().getPath());
setLocalDirectory(localDirectory);
setLogFile(localDirectory.determineLogFile());
Expand Down
15 changes: 8 additions & 7 deletions nextflow/src/org/labkey/nextflow/NextFlowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.nextflow.pipeline.NextFlowPipelineJob;
import org.labkey.nextflow.pipeline.NextFlowProtocol;
import org.labkey.vfs.FileLike;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
Expand Down Expand Up @@ -261,17 +262,17 @@ public void validateCommand(AnalyzeForm o, Errors errors)
@Override
public ModelAndView getView(AnalyzeForm o, boolean b, BindException errors)
{
List<File> selectedFiles = o.getValidatedFiles(getContainer(), false);
List<FileLike> selectedFiles = o.getValidatedFiles(getContainer(), false);
if (selectedFiles.isEmpty())
{
return new HtmlView(HtmlString.of("Couldn't find input file(s)"));
}
// NextFlow operates on the full directory so show the list to the user, regardless of what they selected
// from the file listing
File inputDir = selectedFiles.get(0).getParentFile();
FileLike inputDir = selectedFiles.get(0).getParent();

File[] inputFiles = inputDir.listFiles(new PipelineProvider.FileTypesEntryFilter(NextFlowProtocol.INPUT_TYPES));
if (inputFiles == null || inputFiles.length == 0)
List<FileLike> inputFiles = inputDir.getChildren().stream().filter(new PipelineProvider.FileTypesEntryFilter(NextFlowProtocol.INPUT_TYPES)).toList();
if (inputFiles.isEmpty())
{
return new HtmlView(HtmlString.of("Couldn't find input file(s)"));
}
Expand All @@ -290,7 +291,7 @@ public ModelAndView getView(AnalyzeForm o, boolean b, BindException errors)
INPUT(at(hidden, true, name, "launch", value, true)),
Arrays.stream(o.getFile()).map(f -> INPUT(at(hidden, true, name, "file", value, f))).toList(),
"Files: ",
UL(Arrays.stream(inputFiles).map(File::getName).map(DOM::LI)),
UL(inputFiles.stream().map(FileLike::getName).map(DOM::LI)),
"Config: ",
new SelectBuilder().name("configFile").addOptions(Arrays.stream(configFiles).filter(f -> f.isFile() && f.getName().toLowerCase().endsWith(".config")).map(File::getName).sorted(String.CASE_INSENSITIVE_ORDER).toList()).build(),
DOM.BR(),
Expand Down Expand Up @@ -318,7 +319,7 @@ public boolean handlePost(AnalyzeForm form, BindException errors) throws Excepti
}
else
{
List<File> inputFiles = form.getValidatedFiles(getContainer());
List<FileLike> inputFiles = form.getValidatedFiles(getContainer());
if (inputFiles.isEmpty())
{
errors.reject(ERROR_MSG, "No input files");
Expand All @@ -327,7 +328,7 @@ public boolean handlePost(AnalyzeForm form, BindException errors) throws Excepti
{
ViewBackgroundInfo info = getViewBackgroundInfo();
PipeRoot root = PipelineService.get().findPipelineRoot(info.getContainer());
NextFlowPipelineJob job = NextFlowPipelineJob.create(info, root, configFile.toPath(), inputFiles.stream().map(File::toPath).toList());
NextFlowPipelineJob job = NextFlowPipelineJob.create(info, root, configFile.toPath(), inputFiles);
PipelineService.get().queueJob(job);
LOG.info("NextFlow job queued: {}", job.getJsonJobInfo(false));
}
Expand Down
30 changes: 16 additions & 14 deletions nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.api.writer.PrintWriters;
import org.labkey.nextflow.NextFlowManager;
import org.labkey.vfs.FileLike;

import java.io.BufferedWriter;
import java.io.File;
Expand All @@ -35,29 +37,29 @@ public class NextFlowPipelineJob extends AbstractFileAnalysisJob
{
protected static final Logger LOG = LogHelper.getLogger(NextFlowPipelineJob.class, "NextFlow jobs");

private Path config;
private FileLike config;

@SuppressWarnings("unused") // For serialization
protected NextFlowPipelineJob()
{}

public static NextFlowPipelineJob create(ViewBackgroundInfo info, @NotNull PipeRoot root, Path templateConfig, List<Path> inputFiles) throws IOException
public static NextFlowPipelineJob create(ViewBackgroundInfo info, @NotNull PipeRoot root, Path templateConfig, List<FileLike> inputFiles) throws IOException
{
Path parentDir = inputFiles.get(0).getParent();
FileLike parentDir = inputFiles.get(0).getParent();

String jobName = FileUtil.makeFileNameWithTimestamp("NextFlow");
Path jobDir = parentDir.resolve(jobName);
Path log = jobDir.resolve(jobName + ".log");
FileLike jobDir = parentDir.resolveChild(jobName);
FileLike log = jobDir.resolveChild(jobName + ".log");
FileUtil.createDirectory(jobDir);

Path config = createConfig(templateConfig, parentDir, jobDir, info.getContainer());
FileLike config = createConfig(templateConfig, parentDir, jobDir, info.getContainer());

return new NextFlowPipelineJob(info, root, config, inputFiles, log);
}

public NextFlowPipelineJob(ViewBackgroundInfo info, @NotNull PipeRoot root, Path config, List<Path> inputFiles, Path log) throws IOException
public NextFlowPipelineJob(ViewBackgroundInfo info, @NotNull PipeRoot root, FileLike config, List<FileLike> inputFiles, FileLike log) throws IOException
{
super(new NextFlowProtocol(), NextFlowPipelineProvider.NAME, info, root, config.getFileName().toString(), config, inputFiles, false, false);
super(new NextFlowProtocol(), NextFlowPipelineProvider.NAME, info, root, config.getName(), config, inputFiles, false);
this.config = config;
setLogFile(log);
}
Expand All @@ -69,7 +71,7 @@ public JSONObject getJsonJobInfo(boolean includeInvocationCount)
result.put("container", getContainer().getPath());
result.put("filePath", getLogFilePath().getParent().toString());
result.put("runName", getNextFlowRunName(includeInvocationCount));
result.put("configFile", getConfig().getFileName().toString());
result.put("configFile", getConfig().getName());
return result;
}

Expand All @@ -88,7 +90,7 @@ public ParamParser getInputParameters()
}

/** Take the template config file and substitute in the values for this job */
private static Path createConfig(Path configTemplate, Path parentDir, Path jobDir, Container container) throws IOException
private static FileLike createConfig(Path configTemplate, FileLike parentDir, FileLike jobDir, Container container) throws IOException
{
String template;
try (InputStream in = Files.newInputStream(configTemplate))
Expand All @@ -104,8 +106,8 @@ private static Path createConfig(Path configTemplate, Path parentDir, Path jobDi
uploadUrl = StringUtils.stripEnd(uploadUrl, "/");
substitutedContent = substitutedContent.replace("${panorama.upload_url}", "panorama.upload_url = '" + uploadUrl + "'");

Path substitutedFile = jobDir.resolve(configTemplate.getFileName());
try (BufferedWriter writer = Files.newBufferedWriter(substitutedFile))
FileLike substitutedFile = jobDir.resolveChild(configTemplate.getFileName().toString());
try (BufferedWriter writer = new BufferedWriter(PrintWriters.getPrintWriter(substitutedFile.openOutputStream())))
{
writer.write(substitutedContent);
}
Expand All @@ -115,7 +117,7 @@ private static Path createConfig(Path configTemplate, Path parentDir, Path jobDi
@Override
public String getDescription()
{
return "NextFlow analysis of " + StringUtilsLabKey.pluralize(getInputFilePaths().size(), "file") + " using config: " + config.getFileName();
return "NextFlow analysis of " + StringUtilsLabKey.pluralize(getInputFilePaths().size(), "file") + " using config: " + config.getName();
}

@Override
Expand All @@ -131,7 +133,7 @@ public TaskId getTaskPipelineId()
}

@Override
public AbstractFileAnalysisJob createSingleFileJob(File file)
public AbstractFileAnalysisJob createSingleFileJob(FileLike file)
{
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory;
import org.labkey.api.util.FileType;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.vfs.FileLike;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -47,7 +47,7 @@ public NextFlowProtocol createProtocolInstance(String name, String description,
}

@Override
public Path getDefaultParametersFile(PipeRoot root)
public FileLike getDefaultParametersFile(PipeRoot root)
{
return null;
}
Expand All @@ -61,7 +61,7 @@ public String getName()
}

@Override
public NextFlowPipelineJob createPipelineJob(ViewBackgroundInfo info, PipeRoot root, List<Path> filesInput, Path fileParameters, @Nullable Map<String, String> variableMap)
public NextFlowPipelineJob createPipelineJob(ViewBackgroundInfo info, PipeRoot root, List<FileLike> filesInput, FileLike fileParameters, @Nullable Map<String, String> variableMap)
{
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.labkey.api.util.FileType;
import org.labkey.nextflow.NextFlowConfiguration;
import org.labkey.nextflow.NextFlowManager;
import org.labkey.vfs.FileLike;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -143,9 +144,9 @@ else if (Files.isDirectory(path))
}
}

private boolean hasAwsSection(Path configFile) throws PipelineJobException
private boolean hasAwsSection(FileLike configFile) throws PipelineJobException
{
try (InputStream in = Files.newInputStream(configFile);
try (InputStream in = configFile.openInputStream();
InputStreamReader isReader = new InputStreamReader(in, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(isReader))
{
Expand Down Expand Up @@ -174,7 +175,7 @@ private boolean hasAwsSection(Path configFile) throws PipelineJobException
private @NotNull List<String> getArgs() throws PipelineJobException
{
NextFlowConfiguration config = NextFlowManager.get().getConfiguration();
Path configFile = getJob().getConfig();
FileLike configFile = getJob().getConfig();

boolean aws = hasAwsSection(configFile);

Expand All @@ -194,7 +195,7 @@ private boolean hasAwsSection(Path configFile) throws PipelineJobException
args.add(s3Path);
}
args.add("-c");
args.add(configFile.toAbsolutePath().toString());
args.add(configFile.toNioPathForRead().toAbsolutePath().toString());
args.add("-name");
args.add(getJob().getNextFlowRunName(true));
return args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
import org.labkey.panoramapublic.view.expannotations.TargetedMSExperimentWebPart;
import org.labkey.panoramapublic.view.expannotations.TargetedMSExperimentsWebPart;
import org.labkey.panoramapublic.view.publish.CatalogEntryWebPart;
import org.labkey.vfs.FileLike;
import org.labkey.vfs.FileSystemLike;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
Expand Down Expand Up @@ -1748,15 +1750,15 @@ private boolean validateAction(CopyExperimentForm form, BindException errors)
return true;
}

private Path getExportFilesDir(Container c)
private FileLike getExportFilesDir(Container c)
{
FileContentService fcs = FileContentService.get();
if(fcs != null)
{
Path fileRoot = fcs.getFileRootPath(c, FileContentService.ContentType.files);
if (fileRoot != null)
{
return fileRoot.resolve(PipelineService.EXPORT_DIR);
return FileSystemLike.wrapFile(fileRoot.resolve(PipelineService.EXPORT_DIR));
}
}
return null;
Expand Down Expand Up @@ -4710,7 +4712,7 @@ private static File getLocalFile(Container container, String fileName) throws Px
PipeRoot root = PipelineService.get().getPipelineRootSetting(container);
if (root != null)
{
LocalDirectory localDirectory = LocalDirectory.create(root, PanoramaPublicModule.NAME);
LocalDirectory localDirectory = LocalDirectory.create(root);
return new File(localDirectory.getLocalDirectoryFile(), fileName);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import org.labkey.panoramapublic.query.JournalManager;
import org.labkey.panoramapublic.query.SubmissionManager;
import org.labkey.panoramapublic.security.PanoramaPublicSubmitterRole;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -254,9 +255,9 @@ private void verifySymlinks(Container source, Container target, boolean matching
}
}

private void cleanupExportDirectory(User user, File directory)
private void cleanupExportDirectory(User user, FileLike directory)
{
List<? extends ExpData> datas = ExperimentService.get().getExpDatasUnderPath(directory.toPath(), null, true);
List<? extends ExpData> datas = ExperimentService.get().getExpDatasUnderPath(directory.toNioPathForRead(), null, true);
for (ExpData data : datas)
{
data.delete(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

import org.labkey.panoramapublic.model.ExperimentAnnotations;
import org.labkey.panoramapublic.model.Journal;

import java.io.File;
import java.nio.file.Path;
import org.labkey.vfs.FileLike;

/**
* User: vsharma
Expand All @@ -32,7 +30,7 @@ public interface CopyExperimentJobSupport

Journal getJournal();

File getExportDir();
FileLike getExportDir();

String getReviewerEmailPrefix();

Expand All @@ -48,5 +46,5 @@ public interface CopyExperimentJobSupport

String getPreviousVersionName();

void setExportTargetPath(Path exportTargetPath);
void setExportTargetPath(FileLike exportTargetPath);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.NotFoundException;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.panoramapublic.PanoramaPublicModule;
import org.labkey.panoramapublic.model.ExperimentAnnotations;
import org.labkey.panoramapublic.model.Journal;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

/**
* User: vsharma
Expand All @@ -63,7 +62,7 @@ public class CopyExperimentPipelineJob extends PipelineJob implements CopyExperi

private String _previousVersionName;

private Path _exportTargetPath;
private FileLike _exportTargetPath;

private Container _exportSourceContainer;

Expand Down Expand Up @@ -93,7 +92,7 @@ public CopyExperimentPipelineJob(ViewBackgroundInfo info, PipeRoot root, Experim

// CONSIDER: Add a static factory method to LocalDirectory instead of using the constructor.
// create(@NotNull PipeRoot root, @NotNull String moduleName, @NotNull String baseLogFileName, @NotNull String localDirPath, boolean temporary)
LocalDirectory localDirectory = new LocalDirectory(targetRoot.getContainer(), PanoramaPublicModule.NAME, root, baseLogFileName);
LocalDirectory localDirectory = new LocalDirectory(targetRoot.getContainer(), root, baseLogFileName);

setLocalDirectory(localDirectory);
setLogFile(localDirectory.determineLogFile());
Expand Down Expand Up @@ -160,9 +159,9 @@ public Journal getJournal()
}

@Override
public File getExportDir()
public FileLike getExportDir()
{
return _exportTargetPath.toFile();
return _exportTargetPath;
}

@Override
Expand Down Expand Up @@ -254,7 +253,7 @@ public void setPreviousVersionName(String previousVersionName)
}

@Override
public void setExportTargetPath(Path exportTargetPath)
public void setExportTargetPath(FileLike exportTargetPath)
{
_exportTargetPath = exportTargetPath;
}
Expand Down
Loading