Skip to content

Commit

Permalink
Don't require python to just instantiate tool classes. (#8128)
Browse files Browse the repository at this point in the history
* Don't require python to just instantiate tool classes.
  • Loading branch information
cmnbroad authored Dec 23, 2022
1 parent 273bfa9 commit 633aa4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ public class CNNScoreVariants extends TwoPassVariantWalker {
@Argument(fullName = "python-profile", shortName = "python-profile", doc = "Run the tool with the Python CProfiler on and write results to this file.", optional = true)
private File pythonProfileResults;

// Create the Python executor. This doesn't actually start the Python process, but verifies that
// the requestedPython executable exists and can be located.
final StreamingPythonScriptExecutor<String> pythonExecutor = new StreamingPythonScriptExecutor<>(true);
private StreamingPythonScriptExecutor<String> pythonExecutor;

private List<String> batchList = new ArrayList<>(inferenceBatchSize);

Expand Down Expand Up @@ -284,6 +282,10 @@ public void onTraversalStart() {
}
}

// Create the Python executor. This doesn't actually start the Python process, but verifies that
// the requestedPython executable exists and can be located.
pythonExecutor = new StreamingPythonScriptExecutor<>(true);

final VCFHeader inputHeader = getHeaderForVariants();
if (inputHeader.getGenotypeSamples().size() > 1) {
logger.warn("CNNScoreVariants is a single sample tool but the input VCF has more than 1 sample.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,19 @@ public class CNNVariantTrain extends CommandLineProgram {
@Argument(fullName = "annotation-set", shortName = "annotation-set", doc = "Which set of annotations to use.", optional = true)
private String annotationSet = "best_practices";

// Start the Python executor. This does not actually start the Python process, but fails if python can't be located
final PythonScriptExecutor pythonExecutor = new PythonScriptExecutor(true);
private PythonScriptExecutor pythonExecutor;


@Override
protected void onStartup() {
PythonScriptExecutor.checkPythonEnvironmentForPackage("vqsr_cnn");
// Start the Python executor. This does not actually start the Python process, but fails if python can't be located
pythonExecutor = new PythonScriptExecutor(true);
}

@Override
protected Object doWork() {

final Resource pythonScriptResource = new Resource("training.py", CNNVariantTrain.class);
List<String> arguments = new ArrayList<>(Arrays.asList(
"--data_dir", inputTensorDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ public class CNNVariantWriteTensors extends CommandLineProgram {
@Argument(fullName = "max-tensors", shortName = "max-tensors", doc = "Maximum number of tensors to write.", optional = true, minValue = 0)
private int maxTensors = 1000000;

// Start the Python executor. This does not actually start the Python process, but fails if python can't be located
final PythonScriptExecutor pythonExecutor = new PythonScriptExecutor(true);
private PythonScriptExecutor pythonExecutor;

@Override
protected void onStartup() {
PythonScriptExecutor.checkPythonEnvironmentForPackage("vqsr_cnn");

// Start the Python executor. This does not actually start the Python process, but fails if python can't be located
pythonExecutor = new PythonScriptExecutor(true);
}

@Override
protected Object doWork() {

final Resource pythonScriptResource = new Resource("training.py", CNNVariantWriteTensors.class);
List<String> arguments = new ArrayList<>(Arrays.asList(
"--reference_fasta", reference,
Expand Down

0 comments on commit 633aa4a

Please sign in to comment.