Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,12 @@ else if (toolLsid != null &&
// Cookie expires after 1 day
final int expires = 24 * 60 * 60;

SkylineToolsStoreManager.get().recordToolDownload(tool);
// Download counter is an incidental write on a GET action — use ignoreSqlUpdates()
// to avoid the dev-mode mutating SQL assertion (like auditing writes)
try (var ignored = SpringActionController.ignoreSqlUpdates())
{
SkylineToolsStoreManager.get().recordToolDownload(tool);
}

DateFormat df = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'", Locale.US);
Calendar calendar = Calendar.getInstance();
Expand Down Expand Up @@ -1180,7 +1185,7 @@ public ModelAndView getView(DownloadFileForm form, BindException errors) throws
}
else
{
PageFlowUtil.streamFile(getViewContext().getResponse(), downloadFile, true);
PageFlowUtil.streamFile(getViewContext().getResponse(), downloadFile.toPath(), true);
return null;
}
}
Expand Down
24 changes: 11 additions & 13 deletions lincs/src/org/labkey/lincs/LincsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.labkey.lincs.psp.LincsPspUtil;
import org.labkey.lincs.psp.PspEndpoint;
import org.labkey.lincs.view.GctUtils;
import org.labkey.vfs.FileLike;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
Expand Down Expand Up @@ -144,35 +145,32 @@ public void addNavTrail(NavTree root)
}
}

private void copyFiles(Path gctDir, String outputFileBaseName, Path gct, File reportDir) throws IOException
private void copyFiles(Path gctDir, String outputFileBaseName, Path gct, FileLike reportDir) throws IOException
{
// reportDir is a local directory under tomcat's temp directory
File[] reportDirFiles = reportDir.listFiles(new FilenameFilter()
List<FileLike> reportDirFiles = reportDir.getChildren((f) ->
{
@Override
public boolean accept(File dir, String name)
{
return name.toLowerCase().endsWith(".txt")
String name = f.getName();
return name.toLowerCase().endsWith(".txt")
|| name.toLowerCase().endsWith(".gct")
|| name.equals("script.Rout");
}
});

// The report should create two files: lincs.gct and lincs.processed.gct
// Copy both to the GCT folder
for(File file: reportDirFiles)
for(FileLike file: reportDirFiles)
{
if(file.getName().equalsIgnoreCase("lincs.gct"))
{
Files.copy(file.toPath(), gct, StandardCopyOption.REPLACE_EXISTING);
Files.copy(file.toNioPathForRead(), gct, StandardCopyOption.REPLACE_EXISTING);
}
else if(file.getName().equalsIgnoreCase("console.txt"))
{
Files.copy(file.toPath(), gctDir.resolve(outputFileBaseName + ".console.txt" ), StandardCopyOption.REPLACE_EXISTING);
Files.copy(file.toNioPathForRead(), gctDir.resolve(outputFileBaseName + ".console.txt" ), StandardCopyOption.REPLACE_EXISTING);
}
else if(file.getName().equals("script.Rout"))
{
Files.copy(file.toPath(), gctDir.resolve(outputFileBaseName + ".script.Rout" ), StandardCopyOption.REPLACE_EXISTING);
Files.copy(file.toNioPathForRead(), gctDir.resolve(outputFileBaseName + ".script.Rout" ), StandardCopyOption.REPLACE_EXISTING);
}
}
}
Expand Down Expand Up @@ -306,11 +304,11 @@ public ApiResponse execute(GCTReportForm form, BindException errors) throws Exce
}
catch(Exception e)
{
copyFiles(gctDir, outputFileBaseName, downloadFile, rreport.getReportDir(getContainer().getId()));
copyFiles(gctDir, outputFileBaseName, downloadFile, rreport.getReportDirFileLike(getContainer().getId()));
throw new ApiUsageException("There was an error running the GCT R script.", e);
}

copyFiles(gctDir, outputFileBaseName, downloadFile, rreport.getReportDir(getContainer().getId()));
copyFiles(gctDir, outputFileBaseName, downloadFile, rreport.getReportDirFileLike(getContainer().getId()));

if(!Files.exists(downloadFile))
{
Expand Down
5 changes: 2 additions & 3 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,8 +42,8 @@ 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,
!root.isCloudRoot() ? root.getRootPath().getAbsolutePath() : FileUtil.getTempDirectory().getPath());
LocalDirectory localDirectory = LocalDirectory.create(root, baseLogFileName,
!root.isCloudRoot() ? root.getRootFileLike() : FileUtil.getTempDirectoryFileLike());
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
2 changes: 1 addition & 1 deletion nextflow/src/org/labkey/nextflow/NextFlowModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean hasScripts()
@Override
public @Nullable Double getSchemaVersion()
{
return 25.000;
return 26.000;
}

@Override
Expand Down
35 changes: 18 additions & 17 deletions nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
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;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
Expand All @@ -35,29 +36,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 +70,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 +89,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 +105,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 +116,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(getInputFiles().size(), "file") + " using config: " + config.getName();
}

@Override
Expand All @@ -131,19 +132,19 @@ public TaskId getTaskPipelineId()
}

@Override
public AbstractFileAnalysisJob createSingleFileJob(File file)
public AbstractFileAnalysisJob createSingleFileJob(FileLike file)
{
throw new UnsupportedOperationException();
}

@Override
public File findInputFile(String name)
public FileLike findInputFile(String name)
{
throw new UnsupportedOperationException();
}

@Override
public File findOutputFile(String name)
public FileLike findOutputFile(String name)
{
return null;
}
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
16 changes: 8 additions & 8 deletions nextflow/src/org/labkey/nextflow/pipeline/NextFlowRunTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
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;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -75,7 +75,7 @@ public NextFlowRunTask(Factory factory, PipelineJob job)
// Need to pass to the main process directly in the future to allow concurrent execution for different users
ProcessBuilder secretsPB = new ProcessBuilder("nextflow", "secrets", "set", "PANORAMA_API_KEY", apiKey);
log.info("Setting secrets");
File dir = getJob().getLogFile().getParentFile();
FileLike dir = getJob().getLogFileLike().getParent();
getJob().runSubProcess(secretsPB, dir);

ProcessBuilder executionPB = new ProcessBuilder(getArgs());
Expand All @@ -84,9 +84,9 @@ public NextFlowRunTask(Factory factory, PipelineJob job)
NextFlowPipelineJob.LOG.info("Finished executing NextFlow: {}", getJob().getJsonJobInfo(true));

RecordedAction action = new RecordedAction(ACTION_NAME);
for (Path inputFile : getJob().getInputFilePaths())
for (FileLike inputFile : getJob().getInputFiles())
{
action.addInput(inputFile.toFile(), SPECTRA_INPUT_ROLE);
action.addInput(inputFile, SPECTRA_INPUT_ROLE);
}
addOutputs(action, getJob().getLogFilePath().getParent().resolve("reports"), log);
addOutputs(action, getJob().getLogFilePath().getParent().resolve("results"), log);
Expand Down Expand Up @@ -143,9 +143,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 +174,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 +194,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
Loading
Loading