Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete MS2 GWT code. Switch to simple job launcher #6163

Merged
merged 13 commits into from
Feb 14, 2025
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
8 changes: 0 additions & 8 deletions api/src/org/labkey/api/pipeline/PipelineJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,6 @@ else if (!TaskStatus.splitWaiting.matches(statusText) && statusText.toLowerCase(
@Override
public boolean isActive() { return false; }
},
waitingForFiles
{
@Override
public boolean isActive() { return false; }

@Override
public String toString() { return "WAITING FOR FILES"; }
},
splitWaiting
{
@Override
Expand Down
19 changes: 5 additions & 14 deletions api/src/org/labkey/api/pipeline/PipelineProtocolFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.xmlbeans.XmlOptions;
import org.fhcrc.cpas.pipeline.protocol.xml.PipelineProtocolPropsDocument;
import org.labkey.api.data.Container;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.NetworkDrive;

Expand Down Expand Up @@ -63,20 +64,10 @@ public static File locateProtocolRootDir(File rootDir, File systemDir)

public T load(PipeRoot root, String name, boolean archived) throws IOException
{
return load(getProtocolFile(root, name, archived));
return load(getProtocolFile(root, name, archived), root.getContainer());
}

public T loadInstance(File file) throws IOException
{
return load(file);
}

protected T load(File file) throws IOException
{
return load(file.toPath());
}

protected T load(Path file) throws IOException
protected T load(Path file, Container container) throws IOException
{
try
{
Expand All @@ -100,7 +91,7 @@ protected T load(Path file) throws IOException
type = type.replace("org.labkey.ms2.protocol.", "org.labkey.ms2.pipeline.");
}

PipelineProtocol protocol = (PipelineProtocol) Class.forName(type).newInstance();
PipelineProtocol protocol = (PipelineProtocol) Class.forName(type).getDeclaredConstructor().newInstance();
PipelineProtocolPropsDocument.PipelineProtocolProps.Property[] props =
ppp.getPropertyArray();
if (ppp.isSetTemplate())
Expand All @@ -118,7 +109,7 @@ protected T load(Path file) throws IOException
}
catch (Exception e)
{
throw (IOException)new IOException("Failed to load protocol document " + file.toAbsolutePath() + ".").initCause(e);
throw new IOException("Failed to load protocol document " + file.toAbsolutePath() + ".", e);
}
}

Expand Down
47 changes: 13 additions & 34 deletions api/src/org/labkey/api/pipeline/PipelineProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.labkey.api.pipeline;

import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.module.Module;
Expand Down Expand Up @@ -94,7 +95,7 @@ public FileTypesEntryFilter(List<FileType> initialFileTypes)
}
else
{
_initialFileTypes = initialFileTypes.toArray(new FileType[initialFileTypes.size()]);
_initialFileTypes = initialFileTypes.toArray(new FileType[0]);
}
}

Expand Down Expand Up @@ -180,30 +181,6 @@ public boolean accept(Path f, boolean checkSiblings)
}
}

/**
* Operations that can be performed on a job belonging to this provider from the job's status details page.
* Cancel and retry are examples.
*/
public static class StatusAction
{
private final String _label;

public StatusAction(String label)
{
_label = label;
}

public String getLabel()
{
return _label;
}

public boolean isVisible(PipelineStatusFile statusFile)
{
return true;
}
}

protected String _name;
private final Module _owningModule;

Expand Down Expand Up @@ -258,7 +235,6 @@ public boolean isStatusViewableFile(Container container, String name, String bas
/**
* Override to do any extra work necessary before deleting a status entry.
*
* @param user
* @param sf the entry to delete
*/
public void preDeleteStatusFile(User user, PipelineStatusFile sf)
Expand All @@ -279,7 +255,7 @@ public boolean supportsCloud()
* @return Web part shown on the setup page.
*/
@Nullable
public HttpView getSetupWebPart(Container container)
public HttpView<?> getSetupWebPart(Container container)
{
// No setup.
return null;
Expand Down Expand Up @@ -317,12 +293,17 @@ public HandlerException(String message)
}
}

protected String createActionId(Class action, String description)
protected String createActionId(@NotNull Class<?> action, @Nullable String description)
{
return createActionId(action.getName(), description);
}

protected String createActionId(@NotNull String action, @Nullable String description)
{
if (description != null)
return action.getName() + ':' + description;
return action + ':' + description;
else
return action.getName();
return action;
}

@Deprecated //Prefer List<Path> version
Expand All @@ -343,15 +324,13 @@ protected void addAction(String actionId, Class<? extends Controller> action, St
return;
ActionURL actionURL = directory.cloneHref();
actionURL.setAction(action);
// Uncomment to debug GWT app - can't just edit the URL and reload because it's a POST
// actionURL.addParameter("gwt.codesvr", "127.0.0.1:9997");
directory.addAction(new PipelineAction(actionId, description, actionURL, files, allowMultiSelect, allowEmptySelect));
}

protected void addAction(String actionId, URLHelper actionURL, String description, PipelineDirectory entry, List<Path> files,
boolean allowMultiSelect, boolean allowEmptySelect, boolean includeAll)
{
if (!includeAll && (files == null || files.size() == 0))
if (!includeAll && (files == null || files.isEmpty()))
return;

entry.addAction(new PipelineAction(actionId, description, actionURL, files, allowMultiSelect, allowEmptySelect));
Expand All @@ -360,7 +339,7 @@ protected void addAction(String actionId, URLHelper actionURL, String descriptio
protected void addAction(String actionId, Class<? extends Controller> action, String description, PipelineDirectory directory, List<Path> files,
boolean allowMultiSelect, boolean allowEmptySelect, boolean includeAll)
{
if (!includeAll && (files == null || files.size() == 0))
if (!includeAll && (files == null || files.isEmpty()))
return;
ActionURL actionURL = directory.cloneHref();
actionURL.setAction(action);
Expand Down
21 changes: 5 additions & 16 deletions api/src/org/labkey/api/pipeline/PipelineService.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,11 @@ enum PipelineButtonOption { Minimal, Assay, Standard }
boolean savePipelineSetup(ViewContext context, SetupForm form, BindException errors) throws Exception;

// TODO: This should be on PipelineProtocolFactory
String getLastProtocolSetting(PipelineProtocolFactory factory, Container container, User user);
String getLastProtocolSetting(PipelineProtocolFactory<?> factory, Container container, User user);

// TODO: This should be on PipelineProtocolFactory
void rememberLastProtocolSetting(PipelineProtocolFactory factory, Container container,
void rememberLastProtocolSetting(PipelineProtocolFactory<?> factory, Container container,
User user, String protocolName);

String getLastSequenceDbSetting(PipelineProtocolFactory factory, Container container, User user);

void rememberLastSequenceDbSetting(PipelineProtocolFactory factory, Container container, User user,
String sequenceDbPath, String sequenceDb);

List<String> getLastSequenceDbPathsSetting(PipelineProtocolFactory factory, Container container, User user);

void rememberLastSequenceDbPathsSetting(PipelineProtocolFactory factory, Container container,
User user, List<String> sequenceDbPaths);

boolean hasSiteDefaultRoot(Container container);

TableInfo getJobsTable(User user, Container container);
Expand Down Expand Up @@ -236,9 +225,9 @@ class PathAnalysisProperties
{
private final PipeRoot _pipeRoot;
private final Path _dirData;
private final AbstractFileAnalysisProtocolFactory _factory;
private final AbstractFileAnalysisProtocolFactory<?> _factory;

public PathAnalysisProperties(PipeRoot pipeRoot, Path dirData, AbstractFileAnalysisProtocolFactory factory)
public PathAnalysisProperties(PipeRoot pipeRoot, Path dirData, AbstractFileAnalysisProtocolFactory<?> factory)
{
_pipeRoot = pipeRoot;
_dirData = dirData;
Expand All @@ -256,7 +245,7 @@ public Path getDirData()
return _dirData;
}

public AbstractFileAnalysisProtocolFactory getFactory()
public AbstractFileAnalysisProtocolFactory<?> getFactory()
{
return _factory;
}
Expand Down
2 changes: 0 additions & 2 deletions api/src/org/labkey/api/pipeline/PipelineStatusFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ interface StatusReader
List<? extends PipelineStatusFile> getQueuedStatusFiles() throws SQLException;

List<? extends PipelineStatusFile> getQueuedStatusFiles(Container c) throws SQLException;

List<? extends PipelineStatusFile> getJobsWaitingForFiles(Container c);
}

interface StatusWriter
Expand Down
2 changes: 2 additions & 0 deletions api/src/org/labkey/api/pipeline/TaskPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ public interface TaskPipeline<SettingsType extends TaskPipelineSettings>

/**@return When true, the module providing this task must be enabled in the current container */
boolean isActiveModuleRequired();

String getPipelineProviderName();
}
18 changes: 15 additions & 3 deletions api/src/org/labkey/api/pipeline/TaskPipelineSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class TaskPipelineSettings
{
private TaskId _id;
private final TaskId _id;
private Object[] _taskProgressionSpec = new Object[0];

/**
Expand All @@ -53,6 +53,8 @@ public class TaskPipelineSettings

private boolean _activeModuleRequired = true;

private String _pipelineProviderName;

public TaskPipelineSettings(TaskId id)
{
_id = id;
Expand All @@ -63,7 +65,7 @@ public TaskPipelineSettings(TaskId id)
*
* @param namespaceClass namespace class for TaskId
*/
public TaskPipelineSettings(Class namespaceClass)
public TaskPipelineSettings(Class<?> namespaceClass)
{
this(namespaceClass, null);
}
Expand All @@ -74,7 +76,7 @@ public TaskPipelineSettings(Class namespaceClass)
* @param namespaceClass namespace class for TaskId
* @param name name for TaskId
*/
public TaskPipelineSettings(Class namespaceClass, String name)
public TaskPipelineSettings(Class<?> namespaceClass, String name)
{
this(new TaskId(namespaceClass, name));
}
Expand Down Expand Up @@ -198,6 +200,16 @@ public void setActiveModuleRequired(boolean activeModuleRequired)
_activeModuleRequired = activeModuleRequired;
}

public String getPipelineProviderName()
{
return _pipelineProviderName;
}

public void setPipelineProviderName(String pipelineProviderName)
{
_pipelineProviderName = pipelineProviderName;
}

protected void parseWorkflowProcessKey()
{
// This is an optional setting that will either be of the form "processKey" or "moduleName:processKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.commons.io.input.ReaderInputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.action.ApiUsageException;
import org.labkey.api.data.Container;
Expand Down Expand Up @@ -50,15 +51,14 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* <code>AbstractFileAnalysisProtocol</code>
*/
public abstract class AbstractFileAnalysisProtocol<JOB extends AbstractFileAnalysisJob>
extends PipelineProtocol
{
private static Logger _log = LogManager.getLogger(AbstractFileAnalysisProtocol.class);
private static final Logger _log = LogManager.getLogger(AbstractFileAnalysisProtocol.class);

public static final String LEGACY_JOINED_BASENAME = "all";

Expand Down Expand Up @@ -189,23 +189,17 @@ public void saveInstance(Path file, Container c) throws IOException
save(file, null, addParams);
}

@Deprecated //Prefer the Path based version
protected void save(File file, Map<String, String> addParams, Map<String, String> instanceParams) throws IOException
{
save(file.toPath(), addParams, instanceParams);
}

protected void save(Path file, Map<String, String> addParams, Map<String, String> instanceParams) throws IOException
{
if (xml == null || xml.length() == 0)
if (xml == null || xml.isEmpty())
{
xml = "<?xml version=\"1.0\"?>\n" +
"<bioml>\n" +
"</bioml>";
xml = """
<?xml version="1.0"?>
<bioml>
</bioml>""";
}

ParamParser parser = getFactory().createParamParser();
parser.parse(new ReaderInputStream(new StringReader(xml), Charset.defaultCharset()));
ParamParser parser = parse();
if (parser.getErrors() != null)
{
ParamParser.Error err = parser.getErrors()[0];
Expand Down Expand Up @@ -256,6 +250,14 @@ protected void save(Path file, Map<String, String> addParams, Map<String, String
}
}

@NotNull
protected ParamParser parse()
{
ParamParser parser = getFactory().createParamParser();
parser.parse(new ReaderInputStream(new StringReader(xml), Charset.defaultCharset()));
return parser;
}

@Deprecated //Prefer the Path version
public FileType findInputType(File file)
{
Expand All @@ -277,18 +279,9 @@ public FileType findInputType(Path file)
@Override
public abstract AbstractFileAnalysisProtocolFactory getFactory();

@Deprecated //Prefer Path version
public abstract JOB createPipelineJob(ViewBackgroundInfo info,
PipeRoot root, List<File> filesInput,
File fileParameters, @Nullable Map<String, String> variableMap) throws IOException;

//TODO convert existing File based versions to Path, then make this abstract
public JOB createPipelineJob(ViewBackgroundInfo info,
PipeRoot root, List<Path> filesInput,
Path fileParameters, @Nullable Map<String, String> variableMap) throws IOException
{
return createPipelineJob(info, root, filesInput.stream().map(Path::toFile).collect(Collectors.toList()), fileParameters.toFile(), variableMap);
}
Path fileParameters, @Nullable Map<String, String> variableMap) throws IOException;

public boolean timestampLog()
{
Expand Down
Loading