Skip to content

Commit f5f27b8

Browse files
authored
Re-enable default holohub data path for Endoscopy Tool Tracking (#475)
* Re-enable default holohub data path Signed-off-by: Victor Chang <vicchang@nvidia.com> * Fix formatting Signed-off-by: Victor Chang <vicchang@nvidia.com> --------- Signed-off-by: Victor Chang <vicchang@nvidia.com>
1 parent a73140a commit f5f27b8

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

applications/endoscopy_tool_tracking/cpp/main.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class App : public holoscan::Application {
273273
std::string source_ = "replayer";
274274
std::string visualizer_name = "holoviz";
275275
Record record_type_ = Record::NONE;
276-
std::string datapath = "data/endoscopy";
276+
std::string datapath = "";
277277
};
278278

279279
/** Helper function to parse the command line arguments */
@@ -309,12 +309,15 @@ int main(int argc, char** argv) {
309309
if (data_directory.empty()) {
310310
// Get the input data environment variable
311311
auto input_path = std::getenv("HOLOSCAN_INPUT_PATH");
312-
if (input_path == nullptr || input_path[0] == '\0') {
312+
if (input_path != nullptr && input_path[0] != '\0') {
313+
data_directory = std::string(input_path);
314+
} else if (std::filesystem::is_directory(std::filesystem::current_path() / "data/endoscopy")) {
315+
data_directory = std::string((std::filesystem::current_path() / "data/endoscopy").c_str());
316+
} else {
313317
HOLOSCAN_LOG_ERROR(
314318
"Input data not provided. Use --data or set HOLOSCAN_INPUT_PATH environment variable.");
315319
exit(-1);
316320
}
317-
data_directory = std::string(input_path);
318321
}
319322

320323
if (config_path.empty()) {

applications/endoscopy_tool_tracking/python/endoscopy_tool_tracking.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def compose(self):
275275

276276

277277
if __name__ == "__main__":
278+
default_data_path = f"{os.getcwd()}/data/endoscopy"
278279
# Parse args
279280
parser = ArgumentParser(description="Endoscopy tool tracking demo application.")
280281
parser.add_argument(
@@ -303,8 +304,8 @@ def compose(self):
303304
parser.add_argument(
304305
"-d",
305306
"--data",
306-
default=os.environ.get("HOLOSCAN_INPUT_PATH", None),
307-
help=("Set the data path"),
307+
default=os.environ.get("HOLOSCAN_INPUT_PATH", default_data_path),
308+
help=("Set the data path (default: %(default)s)."),
308309
)
309310
args = parser.parse_args()
310311
record_type = args.record_type
@@ -316,6 +317,15 @@ def compose(self):
316317
else:
317318
config_file = args.config
318319

320+
# handle case where HOLOSCAN_INPUT_PATH is set with no value
321+
if len(args.data) == 0:
322+
args.data = default_data_path
323+
324+
if not os.path.isdir(args.data):
325+
raise ValueError(
326+
f"Data path '{args.data}' does not exist. Use --data or set HOLOSCAN_INPUT_PATH environment variable."
327+
)
328+
319329
app = EndoscopyApp(record_type=record_type, source=args.source, data=args.data)
320330
app.config(config_file)
321331
app.run()

run

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ for k, v in obj[project_type]["run"].items():
841841
workdir="cd ${holohub_build_dir}"
842842
fi
843843

844-
local environment="export PYTHONPATH=\${PYTHONPATH}:${holoscan_sdk_install}/../../../python/lib:${holohub_build_dir}/python/lib:${SCRIPT_DIR} && export HOLOHUB_DATA_PATH=${holohub_data_dir} && export HOLOSCAN_INPUT_PATH=${holohub_data_dir}"
844+
local environment="export PYTHONPATH=\${PYTHONPATH}:${holoscan_sdk_install}/../../../python/lib:${holohub_build_dir}/python/lib:${SCRIPT_DIR} && export HOLOHUB_DATA_PATH=${holohub_data_dir} && export HOLOSCAN_INPUT_PATH=${HOLOSCAN_INPUT_PATH:=$holohub_data_dir}"
845845
local reset_environment="export PYTHONPATH=${PYTHONPATH} && export HOLOHUB_DATA_PATH=\"${HOLOHUB_DATA_PATH}\" && export HOLOSCAN_INPUT_PATH=\"${HOLOSCAN_INPUT_PATH}\""
846846

847847
if [ ${verbose} ]; then

0 commit comments

Comments
 (0)