Skip to content

Commit

Permalink
Add patch to make main look like Ziggy-0.3.0-20230214
Browse files Browse the repository at this point in the history
Rebasing the Ziggy-0.3.0 release onto main didn't go smoothly this time.
  • Loading branch information
wohler committed Feb 23, 2023
1 parent 130509f commit 67106d8
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 305 deletions.
158 changes: 0 additions & 158 deletions buildSrc/src/main/java/gov/nasa/ziggy/buildutil/ZiggyCpp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.gradle.api.Project;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.Input;

Expand All @@ -30,163 +29,6 @@
*
*/
public class ZiggyCpp extends DefaultTask {

/**
* Data and methods used to perform the C++ compile and link.
*/
private ZiggyCppPojo ziggyCppPojo = new ZiggyCppPojo();

/**
* Default constructor. Provides the ZiggyCppPojo object with directories for the
* project and default options, if set
*/
public ZiggyCpp() {
Project project = getProject();
ziggyCppPojo.setBuildDir(project.getBuildDir());
ziggyCppPojo.setRootDir(pipelineRootDir(project));
if (project.hasProperty(ZiggyCppPojo.DEFAULT_COMPILE_OPTIONS_GRADLE_PROPERTY)) {
ziggyCppPojo.setCompileOptions(ZiggyCppPojo.gradlePropertyToList(
project.property(ZiggyCppPojo.DEFAULT_COMPILE_OPTIONS_GRADLE_PROPERTY)));
}
if (project.hasProperty(ZiggyCppPojo.DEFAULT_LINK_OPTIONS_GRADLE_PROPERTY)) {
ziggyCppPojo.setLinkOptions(ZiggyCppPojo.gradlePropertyToList(
project.property(ZiggyCppPojo.DEFAULT_LINK_OPTIONS_GRADLE_PROPERTY)));
}
if (project.hasProperty(ZiggyCppPojo.DEFAULT_RELEASE_OPTS_GRADLE_PROPERTY)) {
ziggyCppPojo.setReleaseOptimizations(ZiggyCppPojo.gradlePropertyToList(
project.findProperty(ZiggyCppPojo.DEFAULT_RELEASE_OPTS_GRADLE_PROPERTY)));
}
if (project.hasProperty(ZiggyCppPojo.DEFAULT_DEBUG_OPTS_GRADLE_PROPERTY)) {
ziggyCppPojo.setDebugOptimizations(ZiggyCppPojo.gradlePropertyToList(
project.findProperty(ZiggyCppPojo.DEFAULT_DEBUG_OPTS_GRADLE_PROPERTY)));
}
}

/**
* Returns the root directory of the pipeline
* @param project Current project
* @return rootDir if the pipelineRootDir project property is not set; if that
* property is set, the contents of the pipelineRootDir property are returned as a File
*/
public static File pipelineRootDir(Project project) {
File pipelineRootDir = null;
if (project.hasProperty(ZiggyCppPojo.PIPELINE_ROOT_DIR_PROP_NAME)) {
pipelineRootDir = new File(project.property(
ZiggyCppPojo.PIPELINE_ROOT_DIR_PROP_NAME).toString());
} else {
pipelineRootDir = project.getRootDir();
}
return pipelineRootDir;
}

/** Provides access to the ZiggyCppPojo action() method for Gradle. */
@TaskAction
public void action() {
ziggyCppPojo.action();
}

/**
* Provides access to the ZiggyCppPojo list of C++ files for Gradle, and
* specifies for gradle that those files are the inputs for this task.
* @return List of C++ files found in the C++ source file directory.
*/
@InputFiles
public List<File> getCppFiles() {
return ziggyCppPojo.getCppFiles();
}

/**
* Provides Gradle with access to the ZiggyCppPojo File that will be the final product
* of the build. Also specifies that this file is the output for this task.
* @return File containing the target product for a task.
*/
@OutputFile
public File getBuiltFile() {
return ziggyCppPojo.getBuiltFile();
}

// Below are setters and getters for the ZiggyCppPojo members that must be mutated
// by ZiggyCpp tasks in gradle. In principle only setters are needed, but in the
// interest of sanity getters are also provided. Note that not all ZiggyCppPojo
// members need to be set by ZiggyCpp, there are a number that are used internally
// and are not set as part of a task.
//
// Note that the setters take Object and List<Object> rather than String and List<String>.
// This is because Gradle allows its text string objects to be either Java String class or
// Groovy GString class. Consequently, we pass everything to ZiggyCppPojo as Objects, and
// ZiggyCppPojo uses the toString() methods to convert everything to Java Strings.

// Path to the C++ source files
public void setCppFilePaths(List<Object> cppFilePaths) {
ziggyCppPojo.setCppFilePaths(cppFilePaths);
}
@Input
public List<String> getCppFilePaths() {
return ziggyCppPojo.getCppFilePaths();
}

// Paths for include files
public void setIncludeFilePaths(List<? extends Object> includeFilePaths) {
ziggyCppPojo.setIncludeFilePaths(includeFilePaths);
}
@Input
public List<String> getIncludeFilePaths() {
return ziggyCppPojo.getIncludeFilePaths();
}

// paths for libraries that must be linked in
public void setLibraryPaths(List<? extends Object> libraryPaths) {
ziggyCppPojo.setLibraryPaths(libraryPaths);
}
@Input
public List<String> getLibraryPaths() {
return ziggyCppPojo.getLibraryPaths();
}

// Libraries that must be linked in
public void setLibraries(List<? extends Object> libraries) {
ziggyCppPojo.setLibraries(libraries);
}
@Input
public List<String> getLibraries() {
return ziggyCppPojo.getLibraries();
}

// compiler options
public void setCompileOptions(List<? extends Object> compileOptions) {
ziggyCppPojo.setCompileOptions(compileOptions);;
}
@Input
public List<String> getCompileOptions() {
return ziggyCppPojo.getCompileOptions();
}

// linker options
public void setLinkOptions(List<? extends Object> linkOptions) {
ziggyCppPojo.setLinkOptions(linkOptions);
}
@Input
public List<String> getLinkOptions() {
return ziggyCppPojo.getLinkOptions();
}

// output type (executable, shared library, static library)
public void setOutputType(Object outputType) {
ziggyCppPojo.setOutputType(outputType);
}
@Input
public BuildType getOutputType() {
return ziggyCppPojo.getOutputType();
}

// Name of file to be produced
public void setOutputName(Object name) {
ziggyCppPojo.setOutputName(name);
}
@Input
public String getOutputName() {
return ziggyCppPojo.getOutputName();
}

/**
* Data and methods used to perform the C++ compile and link.
Expand Down
2 changes: 1 addition & 1 deletion doc/user-manual/data-receipt.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Let's fix that now.

[[Previous]](delete-tasks.md)
[[Up]](user-manual.md)
[[Next]](data-receipt-execution.md)
[[Next]](data-receipt-execution.md)
2 changes: 1 addition & 1 deletion doc/user-manual/delete-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ This is the same idea, except it's the pop-up menu for the instance table, and y

[[Previous]](rerun-task.md)
[[Up]](ziggy-gui-troubleshooting.md)
[[Next]](select-hpc.md)data-receipt.md)
[[Next]](select-hpc.md)
2 changes: 1 addition & 1 deletion doc/user-manual/downloading-and-building-ziggy.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="pipeline-architecture.md">[Previous]</a> <a href="user-manual.md">[Up]</a> <a href="configuring-pipeline.md">[Next]</a>
<!-- -*-visual-line-*- -->

[[Previous]](pipeline-architecture.md)
[[Up]](user-manual.md)
Expand Down
3 changes: 1 addition & 2 deletions doc/user-manual/event-handler-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[[Up]](event-handler.md)
[[Next]](event-handler-labels.md)

## Event Handler: Examples
## Event Handler Examples

Now that we've looked at the general concept of event handlers, and we've talked about how to define an event handler, let's work through some examples using the sample pipeline.

Expand Down Expand Up @@ -185,4 +185,3 @@ The first column is the event ID -- this is a simple, monotonically-increasing i
[[Previous]](event-handler-definition.md)
[[Up]](event-handler.md)
[[Next]](event-handler-labels.md)

5 changes: 2 additions & 3 deletions doc/user-manual/event-handler-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[[Up]](event-handler.md)
[[Next]](event-handler-definition.md)

## Event Handler: Introduction
## Introduction to Event Handlers

Ziggy's predecessors in the pipeline infrastructure field (the Kepler SOC's PI module and TESS SPOC's Spiffy) were designed to require a lot of in-person handling by pipeline users. In particular, they had no capacity to take actions without somebody, somewhere, issuing a command or pressing a button on the console.

Expand Down Expand Up @@ -160,5 +160,4 @@ As soon as the pipeline starts, Ziggy deletes the ready files for reeves-gabrels

[[Previous]](event-handler.md)
[[Up]](event-handler.md)
[[Next]](event-handler-definition.md)event-handler-definition.md)

[[Next]](event-handler-definition.md))
2 changes: 1 addition & 1 deletion doc/user-manual/event-handler-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[[Up]](event-handler.md)
[[Next]](dusty-corners.md)

## Event Handler: Algorithms
## Sending Event Information to Algorithms

The event handler, and all of the information associated with it, is mainly intended for use by Ziggy: Ziggy uses the information to select a pipeline to start, to figure out which data receipt directories it can import, etc. That said, it's possible that event information can be useful to the algorithms as well. In the case when an algorithm runs in a pipeline that got kicked off by an event, there can be some value in giving the algorithm information about the handler and the event.

Expand Down
2 changes: 1 addition & 1 deletion doc/user-manual/remote-dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ Alternately, you may want to discard all your changes and start over tuning the

[[Previous]](select-hpc.md)
[[Up]](select-hpc.md)
[[Next]](hpc-cost.md)hpc-cost.md)
[[Next]](hpc-cost.md)
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ public static boolean validAcknowledgementExists(Path workingDir, Manifest manif
xmlManager = new ValidatingXmlManager<>(Acknowledgement.class);
Acknowledgement ack = xmlManager.unmarshal(acknowledgementPath.toFile());
return ack.transferStatus.equals(DataReceiptStatus.VALID);
} catch (InstantiationException | IllegalAccessException | SAXException | JAXBException
| IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
} catch (InstantiationException | IllegalAccessException | SAXException | JAXBException e) {
throw new PipelineException(
"Unable to read acknowledgement " + acknowledgementPath.toString(), e);
}
Expand Down Expand Up @@ -417,11 +416,11 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return false;
}
AcknowledgementEntry other = (AcknowledgementEntry) obj;
return Objects.equals(name, other.name) && Objects.equals(checksum, other.checksum)
&& size == other.size && transferStatus == other.transferStatus
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gov/nasa/ziggy/data/management/Manifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return false;
}
ManifestEntry other = (ManifestEntry) obj;
return Objects.equals(checksum, other.checksum) && Objects.equals(name, other.name)
&& size == other.size;
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/gov/nasa/ziggy/module/PipelineInputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,11 @@ public void writeSubTaskInputs(int seqNum) {
String moduleName = moduleName();
String filename = ModuleInterfaceUtils.inputsFileName(moduleName, seqNum);
log.info("Writing file " + filename + " to sub-task directory");

// Note: you might think that we shouldn't need this getProperty call when
// constructing the File for use as the inputs file. And you'd be right! The
// problem is that starting in Java 11, changing the user.dir property doesn't
// change the working directory, but does change the value of the system
// property. Thus we need to include its value here so that unit tests work
// correctly.
File f = new File(System.getProperty("user.dir"), ModuleInterfaceUtils.inputsFileName(moduleName, seqNum));
hdf5ModuleInterface.writeFile(
f, this,
true);
hdf5ModuleInterface.writeFile(DirectoryProperties.workingDir()
.resolve(ModuleInterfaceUtils.inputsFileName(moduleName, seqNum))
.toFile(), this, true);
// hdf5ModuleInterface.writeFile(
// new File(ModuleInterfaceUtils.inputsFileName(moduleName, seqNum)), this, true);
ModuleInterfaceUtils.writeCompanionXmlFile(this, moduleName, seqNum);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gov/nasa/ziggy/util/io/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public static Set<PosixFilePermission> modeToPosixFilePermissions(int mode) {
*/
public static void cleanDirectoryTree(Path directory, boolean force) throws IOException {
if (force) {
setPosixPermissionsRecursively(directory, "rw-r--r--", "rwxr-xr-x");
prepareDirectoryTreeForOverwrites(directory);
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
for (Path file : stream) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/gov/nasa/ziggy/ZiggyDirectoryRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Statement apply(Statement statement, Description description) {
Files.createDirectories(directory);

// Clean the new directory prior to use.
FileUtil.cleanDirectoryTree(directory);
FileUtil.cleanDirectoryTree(directory, true);

return new Statement() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -34,8 +33,8 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
//import com.google.common.io.Files;

import gov.nasa.ziggy.ZiggyDirectoryRule;
import gov.nasa.ziggy.ZiggyPropertyRule;
import gov.nasa.ziggy.data.management.DataFileTestUtils.DataFileInfoSample1;
import gov.nasa.ziggy.data.management.DataFileTestUtils.DataFileInfoSample2;
Expand All @@ -46,7 +45,6 @@
import gov.nasa.ziggy.pipeline.definition.PipelineDefinitionNode;
import gov.nasa.ziggy.pipeline.definition.PipelineTask;
import gov.nasa.ziggy.pipeline.definition.crud.PipelineTaskCrud;
import gov.nasa.ziggy.services.config.PropertyNames;
import gov.nasa.ziggy.uow.TaskConfigurationParameters;

/**
Expand All @@ -56,7 +54,7 @@
*/
public class DataFileManagerTest {

private String datastoreRoot = new File(Filenames.BUILD_TEST, "datastore").getAbsolutePath();
private String datastoreRoot;
private String taskDirRoot;
private String taskDir;
private String subtaskDir;
Expand All @@ -76,7 +74,7 @@ public class DataFileManagerTest {
public ZiggyDirectoryRule directoryRule = new ZiggyDirectoryRule();

public ZiggyPropertyRule datastoreRootDirPropertyRule = new ZiggyPropertyRule(
DATASTORE_ROOT_DIR_PROP_NAME, datastoreRoot);
DATASTORE_ROOT_DIR_PROP_NAME, directoryRule, "datastore");

@Rule
public ZiggyPropertyRule useSymlinksPropertyRule = new ZiggyPropertyRule(USE_SYMLINKS_PROP_NAME,
Expand All @@ -101,7 +99,7 @@ public void setup() throws IOException {
this.taskDirRoot = taskDirRoot.toString();
makeTaskDir("pa-5-10");

Path externalTemp = dirRule.testDirPath().resolve("tmp");
Path externalTemp = directoryRule.directory().resolve("tmp");
Files.createDirectories(externalTemp);
externalTempDir = externalTemp.toAbsolutePath().toString();

Expand Down Expand Up @@ -131,17 +129,6 @@ public void setup() throws IOException {
DataFileTestUtils.initializeDataFileTypeSamples();
}

@After
public void teardown() throws InterruptedException, IOException {
// NB: execution is so fast that some deleteDirectory commands fail because
// (apparently) write-locks have not yet had time to release! Address this by
// adding a short nap.
Thread.sleep(10);
FileUtils.deleteDirectory(new File(taskDirRoot));
FileUtil.setPosixPermissionsRecursively(new File(datastoreRoot).toPath(), "rwxrwxrwx");
FileUtils.forceDelete(new File(Filenames.BUILD_TEST));
}

private void makeTaskDir(String taskDirName) {
File taskDir = new File(taskDirRoot, taskDirName);
taskDir.mkdirs();
Expand Down
Loading

0 comments on commit 67106d8

Please sign in to comment.