Skip to content

Commit

Permalink
try fixing ci issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Feb 27, 2024
1 parent 210b898 commit 5ae900e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 61 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- macos-latest
- windows-latest
python:
- "3.8"
# - "3.8"
- "3.12"

defaults:
Expand All @@ -45,9 +45,11 @@ jobs:

- name: Install Helios
run: |
CMAKE_PREFIX_PATH=${CONDA_PREFIX} python -m pip install -v .
python -m pip install -v .
- name: Run tests
run: |
pwd
ls -al
python -m pytest -m exe
python -m pytest -m pyh
11 changes: 5 additions & 6 deletions pytests/test_demo_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import pytest
import fnmatch

import pyhelios

try:
import laspy
except ImportError:
Expand Down Expand Up @@ -44,14 +46,11 @@ def run_helios_executable(survey_path: Path, options=None) -> Path:

def run_helios_pyhelios(survey_path: Path, las_output: bool = True, zip_output: bool = False,
start_time: str = None, split_by_channel: bool = False, las10: bool = False) -> Path:
sys.path.append(WORKING_DIR)
import pyhelios
pyhelios.setDefaultRandomnessGeneratorSeed("43")
from pyhelios import SimulationBuilder
simB = SimulationBuilder(
simB = pyhelios.SimulationBuilder(
surveyPath=str(survey_path.absolute()),
assetsDir=WORKING_DIR + os.sep + 'assets' + os.sep,
outputDir=WORKING_DIR + os.sep + 'output' + os.sep,
assetsDir=[str(Path("assets")), os.getcwd()],
outputDir=str(Path("output")),
)
simB.setLasOutput(las_output)
simB.setLas10(las10)
Expand Down
4 changes: 4 additions & 0 deletions python/pyhelios/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib_resources as resources
import os
import subprocess
import sys

Expand All @@ -9,6 +10,9 @@ def _get_executable():


def helios_exec(args):
# Inject additional arguments to account for standard paths
args = args + ["--assets", os.getcwd()]

executable = _get_executable()
return subprocess.call([executable] + args)

Expand Down
45 changes: 0 additions & 45 deletions python/pyhelios/simulation_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,12 @@ def build(self):
# --- GETTERS and SETTERS --- #
# ----------------------------- #
def setSurveyPath(self, surveyPath):
# TODO Remove ---
print(f'surveyPath: "{surveyPath}"')
# --- TODO Remove
self.validatePath(surveyPath)
self.surveyPath = surveyPath

def setAssetsDir(self, assetsDir):
self.validateDir(assetsDir)
self.assetsDir = assetsDir

def setOutputDir(self, outputDir):
# self.validateDir(outputDir) # note: the output dir does not have to exist at this point
# as it can be created by (py)helios when running it
self.outputDir = outputDir

def setNumThreads(self, numThreads):
Expand Down Expand Up @@ -287,44 +280,6 @@ def addTranslateFilter(self, x, y, z, id):

# --- VALIDATION METHODS --- #
# ---------------------------- #
def validatePath(self, path):
if not os.path.exists(path):
raise PyHeliosToolsException(
'SimulationBuilder EXCEPTION!\n\t'
'Path \'{p}\' does not exist'.format(p=path)
)

if not os.path.isfile(path):
raise PyHeliosToolsException(
'SimulationBuilder EXCEPTION!\n\t'
'Path \'{p}\' does not point to a file'.format(p=path)
)

if not os.access(path, os.R_OK):
raise PyHeliosToolsException(
'SimulationBuilder EXCEPTION!\n\t'
'Cannot read path \'{p}\''.format(p=path)
)

def validateDir(self, dir):
if not os.path.exists(dir):
raise PyHeliosToolsException(
'SimulationBuilder EXCEPTION!\n\t'
'Dir \'{d}\' does not exist'.format(d=dir)
)

if not os.path.isdir(dir):
raise PyHeliosToolsException(
'SimulationBuilder EXCEPTION!\n\t'
'Dir \'{d}\' does not point to a directory'.format(d=dir)
)

if not (os.access(dir, os.R_OK) and os.access(dir, os.X_OK)):
raise PyHeliosToolsException(
'SimulationBuilder EXCEPTION!\n\t'
'Cannot access directory \'{d}\''.format(d=dir)
)

def validateNumThreads(self, numThreads):
if isnan(numThreads):
raise PyHeliosToolsException(
Expand Down
2 changes: 0 additions & 2 deletions src/filems/util/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ std::vector<std::string> FileUtils::handleFilePath(
std::map<std::string, ObjectT> & params,
const std::vector<std::string> & assetsDir
){
std::vector<std::string> filePaths(0);
std::string path;
bool extendedFilePath = false;

Expand All @@ -32,7 +31,6 @@ std::vector<std::string> FileUtils::handleFilePath(
catch(std::exception &e){
try{
path = boost::get<std::string const &>(params["filepath"]);
filePaths.push_back(path);
}
catch(std::exception &e2){
std::stringstream ss;
Expand Down
4 changes: 2 additions & 2 deletions src/pybinds/PyHelios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ BOOST_PYTHON_MODULE(_pyhelios){
class_<PyHeliosSimulation>("Simulation", init<>())
.def(init<
std::string,
std::vector<std::string>,
list,//std::vector<std::string>,
std::string,
size_t,
bool,
Expand All @@ -87,7 +87,7 @@ BOOST_PYTHON_MODULE(_pyhelios){
>())
.def(init<
std::string,
std::vector<std::string>,
list,//std::vector<std::string>,
std::string,
size_t,
bool,
Expand Down
15 changes: 12 additions & 3 deletions src/pybinds/PyHeliosSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ using pyhelios::PyScanningStripWrapper;

namespace fms = helios::filems;

template<typename T>
std::vector<T> py_list_to_std_vector(const boost::python::object& iterable)
{
return std::vector<T>(boost::python::stl_input_iterator< T >(iterable),
boost::python::stl_input_iterator< T >());
}


// *** CONSTRUCTION / DESTRUCTION *** //
// ************************************ //
PyHeliosSimulation::PyHeliosSimulation(
std::string surveyPath,
std::vector<std::string> assetsPath,
//std::vector<std::string> assetsPath,
boost::python::list assetsPath,
std::string outputPath,
size_t numThreads,
bool lasOutput,
Expand All @@ -43,7 +52,7 @@ PyHeliosSimulation::PyHeliosSimulation(
this->zipOutput = zipOutput;
this->splitByChannel = splitByChannel;
this->surveyPath = surveyPath;
this->assetsPath = assetsPath;
this->assetsPath = py_list_to_std_vector<std::string>(assetsPath);
this->outputPath = outputPath;
if(numThreads == 0) this->numThreads = std::thread::hardware_concurrency();
else this->numThreads = numThreads;
Expand All @@ -54,7 +63,7 @@ PyHeliosSimulation::PyHeliosSimulation(
this->parallelizationStrategy = parallelizationStrategy;
this->chunkSize = chunkSize;
this->warehouseFactor = warehouseFactor;
xmlreader = std::make_shared<XmlSurveyLoader>(surveyPath, assetsPath);
xmlreader = std::make_shared<XmlSurveyLoader>(surveyPath, this->assetsPath);
}
PyHeliosSimulation::~PyHeliosSimulation() {
if(thread != nullptr) delete thread;
Expand Down
3 changes: 2 additions & 1 deletion src/pybinds/PyHeliosSimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class PyHeliosSimulation{
*/
PyHeliosSimulation(
std::string surveyPath,
std::vector<std::string> assetsPath = std::vector<std::string>{"assets/"},
//std::vector<std::string> assetsPath = std::vector<std::string>{"assets/"},
boost::python::list assetsPath,
std::string outputPath = "output/",
size_t numThreads = 0,
bool lasOutput = false,
Expand Down

0 comments on commit 5ae900e

Please sign in to comment.