Skip to content

Commit

Permalink
added findfeaturesSegment script (#5091)
Browse files Browse the repository at this point in the history
* added findfeaturesSegment script

* now parrallelized

* updated logging code

* added help string

* added help string

* added envs and fixed progress bar output

* staging things

* added python stuff, fixed segment issues, addressed coments

* addressing comments

* added more doc strings

* made pybindings on by default

* addressing comments

* fixed some things, local testing

* updated install steps

* added basic tests

* reverting ale pin

* changed license

* turn on pybindings in jenkins

* renamed script

* shadow rename?
  • Loading branch information
Kelvinrr authored Aug 18, 2023
1 parent 3d77a87 commit 53e3bc0
Show file tree
Hide file tree
Showing 22 changed files with 2,236 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pipeline {
cd build
cmake -GNinja -DJP2KFLAG=ON \
-DKAKADU_INCLUDE_DIR=${KAKADU_HEADERS} \
-Dpybindings=OFF \
-Dpybindings=ON \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \
../isis
Expand Down Expand Up @@ -117,6 +117,8 @@ pipeline {
cd $WORKSPACE/isis/pytests
pytest .
cd $WORKSPACE/isis/python_bindings/tests
pytest .
'''
}
}
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- defaults

dependencies:
- kalasiris
- ale=0.9.1
- armadillo
- boost=1.72
Expand Down Expand Up @@ -48,6 +49,7 @@ dependencies:
- opencv>=4.5.2
- openssl>=1.1.1k
- pcl >= 1.10.0
- plio
- protobuf<3.20
- python>=3.7.11
- pytest
Expand Down
9 changes: 4 additions & 5 deletions isis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ option(buildMissions "Build the mission specific modules" ON )
option(buildStaticCore "Build libisis static as well as dynamic" OFF )
option(buildTests "Set up unit, application, and module tests." ON )
option(JP2KFLAG "Whether or not to build using JPEG2000 support" OFF )
option(pybindings "Turn on to build Python bindings" OFF )
option(pybindings "Turn on to build Python bindings" ON )

# if cmake install prefix is not set, and conda env is activated, use the
# conda env as the install directory.
Expand Down Expand Up @@ -309,10 +309,6 @@ if(APPLE)
find_package(OpenGL REQUIRED)
endif(APPLE)

if(pybindings)
find_package(Python REQUIRED)
endif()

# Iterate through all variables and extract the libraries and include directories
get_cmake_property(_variableNames VARIABLES) # Get All VARIABLES

Expand Down Expand Up @@ -378,6 +374,9 @@ include_directories(${CMAKE_BINARY_DIR}/inc)
set(CORE_LIB_NAME isis)
message(STATUS "CORE LIB: ${CORE_LIB_NAME}")

if(pybindings)
add_subdirectory(python_bindings)
endif()

# Specify relative library include paths which will be set up on
# the installed files.
Expand Down
1 change: 0 additions & 1 deletion isis/cmake/AddIsisModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include(CodeGeneration)

# Incorporate an application folder
function(add_isis_app folder libDependencies)

# The internal build name will be different than the output name
# - This deals with problems compiling same-named targets on case-insensitive machines.
get_filename_component(appName ${folder} NAME)
Expand Down
49 changes: 49 additions & 0 deletions isis/python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.14)

# Setup for SWIG
set(CMAKE_SWIG_FLAGS)
find_package(SWIG REQUIRED)
include(UseSWIG)
list(APPEND CMAKE_SWIG_FLAGS "-py3;-DPY3")

message(STATUS "SWIG flags: " ${CMAKE_SWIG_FLAGS} )

# Setup for Python linking
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

# Setup for wrapper library
set(ASTROSET_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/astroset")
set(ASTROSET_SOURCES astroset.i
UserInterface.i
)

set(ASTROSET_APPS apps/)

set_source_files_properties(${ASTROSET_SOURCES} PROPERTIES CPLUSPLUS ON)
swig_add_library(astroset
LANGUAGE python
SOURCES ${ASTROSET_SOURCES}
OUTPUT_DIR ${ASTROSET_OUTPUT_DIR})
swig_link_libraries(astroset isis Python3::Module)
set_target_properties(astroset PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
set_target_properties(astroset PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${ASTROSET_OUTPUT_DIR})

# Create the files to install the Python wrapper
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in
${CMAKE_CURRENT_BINARY_DIR}/setup.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
${ASTROSET_OUTPUT_DIR}/__init__.py
COPYONLY)

file(COPY ${ASTROSET_APPS}
DESTINATION
${ASTROSET_OUTPUT_DIR}/apps/)

set(ASTROSET_APP_XML_FILES "apps/findFeaturesSegment/findFeaturesSegment.xml")
file(COPY ${ASTROSET_APP_XML_FILES} DESTINATION ${CMAKE_BINARY_DIR}/bin/xml/ )
install(FILES ${ASTROSET_APP_XML_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/xml/)

# Setup to run setup tools on install
install(CODE "execute_process(COMMAND $ENV{CONDA_PREFIX}/bin/pip install ${CMAKE_CURRENT_BINARY_DIR}/ --prefix=${CMAKE_INSTALL_PREFIX}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")

42 changes: 42 additions & 0 deletions isis/python_bindings/UserInterface.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
%module(package="astroset") UserInterface


%{
#include "Gui.h"
#include "Pvl.h"
#include "UserInterface.h"
%}

%include <QVector>
%include <QString>

// Rename the constructors to Python-friendly names
%rename(UserInterfaceFromArgsv) UserInterface(const QString &xmlfile, int &argc, char *argv[]);
%rename(UserInterfaceFromList) UserInterface(const QString &xmlfile, QVector<QString> &args);

%rename(GetFileName) IsisAml::GetFileName(QString const &) const;
%rename(GetFileNameWithExt) IsisAml::GetFileName(QString const &, QString) const;
%rename(GetFileNames) IsisAml::GetFileName(QString const &, std::vector<QString> &) const;

%rename(GetAsString) IsisAml::GetAsString(QString const &) const;
%rename(GetAsStrings) IsisAml::GetAsString(QString const &, std::vector<QString> &) const;

%rename(GetString) IsisAml::GetString(QString const &) const;
%rename(GetStrings) IsisAml::GetString(QString const &, std::vector<QString> &) const;

%rename(GetCubeNameWithExt) IsisAml::GetCubeName(QString const &,QString) const;
%rename(GetCubeName) IsisAml::GetCubeName(QString const &) const;

%rename(GetInteger) IsisAml::GetInteger(const QString &) const;
%rename(GetIntegers) IsisAml::GetInteger(const QString &, std::vector<int> &) const;

%rename(GetDouble) IsisAml::GetDouble(const QString &) const;
%rename(GetDoubles) IsisAml::GetDouble(const QString &, std::vector<int> &) const;

%rename(GetBoolean) IsisAml::GetBoolean(const QString &) const;
%rename(GetBooleans) IsisAml::GetBoolean(const QString &, std::vector<bool> &) const;

%include "Pvl.h"
%include "IsisAml.h"
%include "UserInterface.h"

22 changes: 22 additions & 0 deletions isis/python_bindings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from .astroset import *

from pathlib import Path
import os

try:
ISISROOT = Path(os.environ["ISISROOT"])
except KeyError:
raise EnvironmentError("Please set ISISROOT before importing anything")

def init_application(args):
appname = os.path.basename(args[0])
args = args[1:]

xmlpath = Path(appname).with_suffix(".xml")
if not xmlpath.exists() or not xmlpath.is_file():
xmlpath = ISISROOT / "bin" / "xml" / xmlpath
print(xmlpath)
if not xmlpath.exists():
raise FileExistsError(f"{appname} does not have an XML file")

return UserInterfaceFromList(str(xmlpath), args)
1 change: 1 addition & 0 deletions isis/python_bindings/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import findFeaturesSegment
Empty file.
Loading

0 comments on commit 53e3bc0

Please sign in to comment.