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

Pipeline Object FileList Fix #4372

Merged
merged 7 commits into from
Mar 20, 2021
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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ release.

- Fixed relative paths not being properly converted to absolute paths in isisVarInit.py [4274](https://github.com/USGS-Astrogeology/ISIS3/issues/4274)
- Fixed issue where serial numbers for Kaguya TC and MI image could not be generated. [4235](https://github.com/USGS-Astrogeology/ISIS3/issues/4235)
- Fixed hardcoded file naming in the hijitter app dealing with output from pipeline. [#4372](https://github.com/USGS-Astrogeology/ISIS3/pull/4372)
- Fixed "About Qview" to point to website documentation. [4333](https://github.com/USGS-Astrogeology/ISIS3/issues/4333)

### Changed

- Updated the FileList object to handle files that do not contain a trailing new line character. [#4372](https://github.com/USGS-Astrogeology/ISIS3/pull/4372)

- Refactored Blob class to be used by classes that serialize to a Cube instead of inherited from. Impacted classes are GisBlob, History, ImagePolygon, OriginalLabel, OriginalXmlLabel, StrethBlob, StringBlob, and Table. [#4082](https://github.com/USGS-Astrogeology/ISIS3/issues/4082)

- Fixed hi2isis MRO:ADC_TIMING_SETTINGS label conversion issue [4290](https://github.com/USGS-Astrogeology/ISIS3/issues/4290)
Expand Down
3 changes: 1 addition & 2 deletions isis/src/base/apps/cubeit/cubeit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@
</brief>
<description>
Each file in this list, one per line, will be added to
the output cube in the order they appear. The last file
in the list must followed by a blank line.
the output cube in the order they appear.
</description>
<filter>
*.lis
Expand Down
11 changes: 5 additions & 6 deletions isis/src/base/objs/FileList/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ namespace Isis {
Isis::IString s;
bool bHasQuotes = false;

in.getline(buf, 65536);
bool isComment = false;
while (!in.eof()) {
do {
in.getline(buf, 65536);

s = buf;
string::size_type loc = s.find("\"", 0);

Expand All @@ -108,7 +109,6 @@ namespace Isis {

isComment = false;
if(strlen(buf) == 0) {
in.getline(buf, 65536);
continue;
}
for (int index = 0; index < (int)strlen(buf); index++) {
Expand All @@ -125,7 +125,6 @@ namespace Isis {
}
}
if (isComment) {
in.getline(buf, 65536);
continue;
}
else {
Expand All @@ -138,9 +137,9 @@ namespace Isis {
}

this->push_back(s.ToQt());
in.getline(buf, 65536);
}
}

} while(!in.eof());
if (this->size() == 0) {
string msg = "Input Stream Empty";
throw IException(IException::User, msg, _FILEINFO_);
Expand Down
42 changes: 16 additions & 26 deletions isis/src/base/objs/Pipeline/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ find files of those names at the top level of this repository. **/
#include "Application.h"
#include "Preference.h"
#include "Progress.h"
#include "TextFile.h"
#include "FileList.h"
#include "FileName.h"

using namespace Isis;
Expand Down Expand Up @@ -236,13 +236,13 @@ namespace Isis {

QStringList listData = cmd.split(" ");
QString listFileName = listData.takeFirst();
TextFile listFile(listFileName, "overwrite");
FileList listFile;

while (!listData.isEmpty()) {
listFile.PutLine(listData.takeFirst());
listFile.push_back(listData.takeFirst());
}

listFile.Close();
listFile.write(listFileName);
}
else {
// Nothing special is happening, just execute the program
Expand Down Expand Up @@ -353,21 +353,9 @@ namespace Isis {
*/
void Pipeline::SetInputListFile(const QString &inputParam) {
UserInterface &ui = Application::GetUserInterface();
FileName inputFileName = FileName(ui.GetFileName(inputParam));

TextFile filelist(FileName(ui.GetFileName(inputParam)).expanded());
QString filename;
int branch = 1;

while (filelist.GetLineNoFilter(filename)) {
p_originalInput.push_back(filename);
p_inputBranches.push_back(inputParam + toString(branch));
p_virtualBands.push_back("");
p_finalOutput.push_back(FileName(filename).name());

branch ++;
}

p_outputListNeedsModifiers = true;
SetInputListFile(inputFileName);
}


Expand All @@ -380,15 +368,16 @@ namespace Isis {
* to p_inputBranches
*/
void Pipeline::SetInputListFile(const FileName &inputFileName) {
TextFile filelist(inputFileName.expanded());
QString filename;
FileList filelist(inputFileName.expanded());
FileName filename;
int branch = 1;

while (filelist.GetLineNoFilter(filename)) {
p_originalInput.push_back(filename);
p_inputBranches.push_back(FileName(inputFileName).expanded() + " " + QString(branch));
p_finalOutput.push_back(FileName(filename).name());
while (!filelist.isEmpty()) {
filename = filelist.takeFirst();
p_originalInput.push_back(filename.expanded());
p_inputBranches.push_back(inputFileName.name() + toString(branch));
p_virtualBands.push_back("");
p_finalOutput.push_back(filename.name());

branch ++;
}
Expand Down Expand Up @@ -536,10 +525,11 @@ namespace Isis {
void Pipeline::SetOutputListFile(const FileName &outputFileNameList) {
p_finalOutput.clear();

TextFile filelist(outputFileNameList.expanded());
FileList filelist(outputFileNameList.expanded());
QString filename;

while (filelist.GetLineNoFilter(filename)) {
while (!filelist.isEmpty()) {
filename = filelist.takeFirst().expanded();
p_finalOutput.push_back(filename);
}

Expand Down
5 changes: 5 additions & 0 deletions isis/src/base/objs/Pipeline/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ namespace Isis {
* control statements. References # 795.
* @history 2016-08-28 Kelvin Rodriguez - Removed useless if statement comparing
* a reference variable to Null. Part of porting to OS X 10.11.
* @history 2021-17-03 Adam Paquette - Update SetInputListFile to use the
* FileList object rather than the TextFile object.
* Also updated SetInputListFile isisparameter
* function to chain into the SetInputListFile FileName
* function.
*/
class Pipeline {
public:
Expand Down
26 changes: 13 additions & 13 deletions isis/src/base/objs/Pipeline/Pipeline.truth
Original file line number Diff line number Diff line change
Expand Up @@ -420,20 +420,20 @@ PIPELINE -------> unitTest3 <------- PIPELINE

Testing listing methods
PIPELINE -------> unitTest4 <------- PIPELINE
cubeatt FROM="fileA" TO="./fileA.jitter.copy.FROM1.cub"
cubeatt FROM="fileB" TO="./fileB.jitter.copy.FROM2.cub"
cubeatt FROM="fileC" TO="./fileC.jitter.copy.FROM3.cub"
spiceinit FROM="./fileA.jitter.copy.FROM1.cub" ATTACH="NO"
spiceinit FROM="./fileB.jitter.copy.FROM2.cub" ATTACH="NO"
spiceinit FROM="./fileC.jitter.copy.FROM3.cub" ATTACH="NO"
echo -e "\n./fileA.jitter.copy.FROM1.cub\n./fileB.jitter.copy.FROM2.cub\n./fileC.jitter.copy.FROM3.cub" > ./appjit.lis
cubeatt FROM="fileA" TO="./fileA.jitter.copy.unitTest.lis1.cub"
cubeatt FROM="fileB" TO="./fileB.jitter.copy.unitTest.lis2.cub"
cubeatt FROM="fileC" TO="./fileC.jitter.copy.unitTest.lis3.cub"
spiceinit FROM="./fileA.jitter.copy.unitTest.lis1.cub" ATTACH="NO"
spiceinit FROM="./fileB.jitter.copy.unitTest.lis2.cub" ATTACH="NO"
spiceinit FROM="./fileC.jitter.copy.unitTest.lis3.cub" ATTACH="NO"
echo -e "\n./fileA.jitter.copy.unitTest.lis1.cub\n./fileB.jitter.copy.unitTest.lis2.cub\n./fileC.jitter.copy.unitTest.lis3.cub" > ./appjit.lis
appjit FROMLIST="./appjit.lis" MASTER="MASTER.cub" DEGREE="1"
noproj FROM="./fileA.jitter.copy.FROM1.cub" TO="./fileA.jitter.cub" MATCH="MATCH.cub"
noproj FROM="./fileB.jitter.copy.FROM2.cub" TO="./fileB.jitter.cub" MATCH="MATCH.cub"
noproj FROM="./fileC.jitter.copy.FROM3.cub" TO="./fileC.jitter.cub" MATCH="MATCH.cub"
rm ./fileA.jitter.copy.FROM1.cub
rm ./fileB.jitter.copy.FROM2.cub
rm ./fileC.jitter.copy.FROM3.cub
noproj FROM="./fileA.jitter.copy.unitTest.lis1.cub" TO="./fileA.jitter.cub" MATCH="MATCH.cub"
noproj FROM="./fileB.jitter.copy.unitTest.lis2.cub" TO="./fileB.jitter.cub" MATCH="MATCH.cub"
noproj FROM="./fileC.jitter.copy.unitTest.lis3.cub" TO="./fileC.jitter.cub" MATCH="MATCH.cub"
rm ./fileA.jitter.copy.unitTest.lis1.cub
rm ./fileB.jitter.copy.unitTest.lis2.cub
rm ./fileC.jitter.copy.unitTest.lis3.cub
rm ./appjit.lis
PIPELINE -------> unitTest4 <------- PIPELINE

Expand Down
12 changes: 7 additions & 5 deletions isis/src/mro/apps/hijitter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ void IsisMain() {
}

// the outputs from this pipeline are temporary files created by cubeatt
std::vector<QString> outputs = mainPipeline.OriginalBranches();
for (int i = 0; i < g_numFiles; i++) {
g_tempFiles.push_back(FileName("$TEMPORARY/noproj.FROM"
+ toString(i + 1) + ".cub").expanded());
g_tempFiles.push_back(FileName("$TEMPORARY/noproj." + outputs[i] + ".cub").expanded());
}

// Do some calculations, delete the final outputs from the pipeline
Expand Down Expand Up @@ -508,6 +508,8 @@ void processNoprojFiles(Pipeline &p) {
hijitregProg.SetMaximumSteps(1);
hijitregProg.CheckStatus();

std::vector<QString> outputs = p.OriginalBranches();

for (int i = 0; i < g_numFiles - 1; i++) {
// If this CCD and the consecutive CCD are both in the input list,
// use the current cubes in the pipeline to create an output flat
Expand All @@ -525,8 +527,8 @@ void processNoprojFiles(Pipeline &p) {
QString flatFileName = tempDir + "/first" + toString(g_ccdNumbers[i])
+ "-" + toString(g_ccdNumbers[i+1]) + ".flat";
QString params = "";
params += "FROM=" + tempDir + "/noproj.FROM" + toString(i + 1) + ".cub";
params += " MATCH=" + tempDir + "/noproj.FROM" + toString(i + 2) + ".cub";
params += "FROM=" + tempDir + "/noproj." + outputs[i] + ".cub";
params += " MATCH=" + tempDir + "/noproj." + outputs[i + 1] + ".cub";
params += " REGDEF=" + ui.GetFileName("REGDEF");
params += " FLAT=" + flatFileName;

Expand Down Expand Up @@ -610,7 +612,7 @@ void processNoprojFiles(Pipeline &p) {
throw IException(IException::Programmer, msg, _FILEINFO_);
}

Cube cube(FileName("$TEMPORARY/noproj.FROM1.cub").expanded(), "r");
Cube cube(FileName("$TEMPORARY/noproj." + outputs[0] + ".cub").expanded(), "r");
Camera *cam = CameraFactory::Create(cube);

double lineRate = cam->DetectorMap()->LineRate();
Expand Down
13 changes: 13 additions & 0 deletions isis/tests/FileListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@ TEST(FileList, FileNameConstructor)
fl1.write(output);
EXPECT_STREQ(expectedOutput.c_str(), output.str().c_str());
}

TEST(FileList, FileNameNoNewLine)
{
std::istringstream input(
"/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.cpp\n"
"/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.h");
std::ostringstream output;
std::string expectedOutput = "/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.cpp\n"
"/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.h\n";
Isis::FileList fl1(input);
fl1.write(output);
EXPECT_STREQ(expectedOutput.c_str(), output.str().c_str());
}