Skip to content

Commit

Permalink
Isisminer has been refactored to be callable and Makefile tests conve…
Browse files Browse the repository at this point in the history
…rted to gtest format (#5579)

* Fixed minor misspellings in error messages. Addresses #5516.

* Test data added for isisminer. Addresses #5516.

* Converted isisminer Makefile tests to gtest format. Addresses #5516.

* Converted isisminer application to callable function. Addresses #5516.

* Minor tweak to isisminer csvwriter test. Addresses #5516.

* Added compareCsvLineCustomDelimiter method, specifically for isisminer testing support. Addresses #5516.

* Removed isisminer Makefile tests (replaced by gtests) and updated CHANGELOG reflecting conversion of isisminer to callable app. Addresses #5516.

* Replace isis cube in /isis/tests/data/isisminer/gistest with isd and label files. Minor tweaks to FunctionalTestsIsisminer.cpp. History entry added to isisminer.xml. Addresses #5516.

* Minor changes for conversion of isisminer to callable app. Addresses #5516.

* Had to add data file index.lbl to the .gitignore file for it to be uploaded. Addresses #5516.
  • Loading branch information
kledmundson authored Sep 11, 2024
1 parent 60e884f commit c6b5df4
Show file tree
Hide file tree
Showing 42 changed files with 9,924 additions and 430 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ release.
- Added backplane options for SunIllumination and SurfaceObliqueDetectorResolution to phocube [#5467](https://github.com/DOI-USGS/ISIS3/issues/5467)

### Changed
- Isisminer has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5516](https://github.com/USGS-Astrogeology/ISIS3/issues/5516)
- Algebra has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5594](https://github.com/USGS-Astrogeology/ISIS3/issues/5594)
- Photrim has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5581](https://github.com/USGS-Astrogeology/ISIS3/issues/5581)
- Bandtrim has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5571](https://github.com/USGS-Astrogeology/ISIS3/issues/5571)
Expand All @@ -53,6 +54,7 @@ release.
- Changed `qwt` dependency version to 6.2.0 or below [#5498](https://github.com/DOI-USGS/ISIS3/issues/5498)
- Pinned `suitesparse` dependency version to maximum not including 7.7.0 [#5496](https://github.com/DOI-USGS/ISIS3/issues/5496)


### Fixed
- Fixed a bug in noproj.cpp which left a persisent lbl file after running noproj. [#5577] (https://github.com/DOI-USGS/ISIS3/issues/5577)
- Fixed a bug in QVIEW's FindTool in which camera was prioritized over projction [#5508](https://github.com/DOI-USGS/ISIS3/issues/5508)
Expand Down
4 changes: 2 additions & 2 deletions isis/src/base/apps/isisminer/ResourceManagerStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Isis {
* @param definition ResourceManager Strategy PVL object
* definition
* @param globals List of global keywords to use in argument substitutions
* @throw IException::User "Invalid operations requestined in ResourceManager."
* @throw IException::User "Invalid operations requested in ResourceManager."
*/
ResourceManagerStrategy::ResourceManagerStrategy(const PvlObject &definition,
const ResourceList &globals) :
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace Isis {
// Handle any errors encountered
if ( !exceptions.empty() ) {
IException ie(IException::User,
"Invalid operations requestined in ResourceManager.",
"Invalid operations requested in ResourceManager.",
_FILEINFO_);
BOOST_FOREACH ( IException e, exceptions ) {
ie.append(e);
Expand Down
1 change: 1 addition & 0 deletions isis/src/base/apps/isisminer/ResourceManagerStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace Isis {
* @history 2015-05-08 Kris Becker - Modify constructor to take a global
* resources list; modified apply() method to accept
* a global resource list.
* @history 2024-07-15 Ken Edmundson - Fixed minor mispellings in error messages.
*/
class ResourceManagerStrategy : public Strategy {

Expand Down
178 changes: 178 additions & 0 deletions isis/src/base/apps/isisminer/isisminer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/** This is free and unencumbered software released into the public domain.
The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

// std library
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

// Qt library
#include <QList>
#include <QScopedPointer>
//#include <QString>
#include <QStringList>
#include <QTime>
#include <QElapsedTimer>

// boost library
#include <boost/foreach.hpp>

// ISIS
#include "Application.h"
#include "Database.h"
#include "FileName.h"
#include "GisGeometry.h"
#include "IString.h"
#include "Progress.h"
#include "Pvl.h"
#include "PvlFlatMap.h"
#include "Resource.h"
#include "SqlQuery.h"
#include "SqlRecord.h"
#include "Strategy.h"
#include "StrategyFactory.h"

#include "isisminer.h"

using namespace std;

namespace Isis {

// Program constants
const QString isisminer_program = "isisminer";
const QString isisminer_version = "1.0";
const QString isisminer_revision = "$Revision: 6513 $";
const QString isisminer_runtime = Application::DateTime();

/**
* Isisminer assists in the identification, manipulation,
* and output of data from a variety of data sources. It
* runs a series of algorithms (or Strategies) that perform
* various operations on input sources (or Resources).
*
* @param ui UserInterface object containing parameters
*/
void isisminer(UserInterface &ui) {

// File containing isisminer configuration run
QString configFile = ui.GetFileName("CONFIG");

// open optional, global parameter file if provided
// file is for use in global variable pool
if ( ui.WasEntered("GLOBALS") ) {
Pvl pvl_globals(ui.GetFileName("GLOBALS"));

return isisminer(configFile, ui, &pvl_globals);
}

return isisminer(configFile, ui);
}


/**
* Isisminer assists in the identification, manipulation,
* and output of data from a variety of data sources. It
* runs a series of algorithms (or Strategies) that perform
* various operations on input sources (or Resources).
*
* @param ui UserInterface object containing parameters
*
* @throws IException::User "Ill-formed PARAMETERS [PARAMETERS] - use form @key:val"
*
*/
void isisminer(QString &configFileName, UserInterface &ui,
Pvl *pvl_globals) {

StrategyFactory *factory = StrategyFactory::instance();

SharedResource globals(new Resource("Globals"));
globals->add("Program", isisminer_program);
globals->add("Version", isisminer_version);
globals->add("Revision", isisminer_revision);
globals->add("RunTime", isisminer_runtime);

// File containing isisminer configuration run
globals->add("CONFIG", configFileName);

// Add parameters provided by user to global resources
if ( ui.WasEntered("PARAMETERS") ) {
QString parameters = ui.GetString("PARAMETERS");
globals->add("PARAMETERS", parameters);

// Split by separate parameters
QStringList parmlist = parameters.split("@", Qt::SkipEmptyParts);
BOOST_FOREACH (QString parm, parmlist) {
// Split values from keyword name
QStringList keyval = parm.split(":", Qt::SkipEmptyParts);
if ( keyval.size() != 2 ) {
QString mess = "Ill-formed PARAMETERS (" + parm + ") - use form @key:val";
throw IException(IException::User, mess, _FILEINFO_);
}

// Now split multi string values and construct the Pvl keyword
QString keyname = keyval[0];
QStringList values = keyval[1].split(",", Qt::SkipEmptyParts);
PvlKeyword keyword(keyname);
BOOST_FOREACH ( QString val, values) {
keyword.addValue(val);
}

// Add the parameter to global parameters
globals->add(keyword);
}
}

// Add to factory
factory->addGlobal(globals);

// If provided, load optional, global parameter
// file for use in global variable pool
if ( pvl_globals != nullptr ) {
SharedResource gfile(new Resource("GlobalFileResources", PvlFlatMap(*pvl_globals)));
factory->addGlobal(gfile);
globals->add("GLOBALS", ui.GetFileName("GLOBALS"));
}

// Create strategies (computations, constraints, ranks, sorts, etc...)
cout << "\nCreating strategies...\n";
StrategyList strategies = factory->buildRun(configFileName);
cout << "Finished creating " << factory->manufactured() << " strategies...\n";

// Input resource list preserved for subsequent processing
ResourceList resources;
QTime runTime = QTime::currentTime();
BOOST_FOREACH ( SharedStrategy strategy, strategies ) {
QTime stime = QTime::currentTime();
cout << "\nRunning " << strategy->type() << "::" << strategy->name()
<< " (TimeIn: " << stime.toString("hh:mm:ss.zzz")
<< ")\n"
<< "Description: " << strategy->description() << "\n";
QElapsedTimer stimer;
stimer.start();
int n = strategy->apply(resources);
unsigned int ntotal = strategy->totalProcessed();
cout << n << " of " << ntotal << " processed in "
<< strategy->type() << "::" << strategy->name()
<< " (TimeOut: " << QTime::currentTime().toString("hh:mm:ss.zzz") << ")\n";
cout << "ElapsedTime(s): " << stimer.elapsed() / 1000 << "\n";
}

// Get total elapsed time
QTime totalT(0,0);
totalT = totalT.addMSecs(runTime.msecsTo(QTime::currentTime()));
cout << "\nSession complete in " << totalT.toString("hh:mm:ss.zzz")
<< " of elapsed time\n";

return;
}
}

23 changes: 23 additions & 0 deletions isis/src/base/apps/isisminer/isisminer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/** This is free and unencumbered software released into the public domain.
The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#ifndef isisminer_h
#define isisminer_h

#include "Pvl.h"
#include "UserInterface.h"

#include <QString>

namespace Isis{
extern void isisminer(UserInterface &ui);
extern void isisminer(QString &configFileName, UserInterface &ui,
Pvl *pvl_globals=nullptr);
}

#endif
5 changes: 5 additions & 0 deletions isis/src/base/apps/isisminer/isisminer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4694,6 +4694,11 @@ End
the number of keywords created/Resource. This allows the jigsaw residual
file to read the rejected column.
</change>
<change name="Ken Edmundson" date="2024-08-07">
Converted isisminer to callable function. Also converted all Makefile
tests to gtest format. Moved some data from isis data area to
"isis/tests/data/isisminer".
</change>
</history>

<groups>
Expand Down
Loading

0 comments on commit c6b5df4

Please sign in to comment.