Skip to content

Commit

Permalink
Re-enable default holohub data path
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Aug 22, 2024
1 parent a73140a commit 9b38b15
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 6 additions & 3 deletions applications/endoscopy_tool_tracking/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class App : public holoscan::Application {
std::string source_ = "replayer";
std::string visualizer_name = "holoviz";
Record record_type_ = Record::NONE;
std::string datapath = "data/endoscopy";
std::string datapath = "";
};

/** Helper function to parse the command line arguments */
Expand Down Expand Up @@ -309,12 +309,15 @@ int main(int argc, char** argv) {
if (data_directory.empty()) {
// Get the input data environment variable
auto input_path = std::getenv("HOLOSCAN_INPUT_PATH");
if (input_path == nullptr || input_path[0] == '\0') {
if (input_path != nullptr && input_path[0] != '\0') {
data_directory = std::string(input_path);
} else if (std::filesystem::is_directory(std::filesystem::current_path() / "data/endoscopy")) {
data_directory = std::string((std::filesystem::current_path() / "data/endoscopy").c_str());
} else {
HOLOSCAN_LOG_ERROR(
"Input data not provided. Use --data or set HOLOSCAN_INPUT_PATH environment variable.");
exit(-1);
}
data_directory = std::string(input_path);
}

if (config_path.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def compose(self):


if __name__ == "__main__":
default_data_path = f"{os.getcwd()}/data/endoscopy"
# Parse args
parser = ArgumentParser(description="Endoscopy tool tracking demo application.")
parser.add_argument(
Expand Down Expand Up @@ -303,8 +304,8 @@ def compose(self):
parser.add_argument(
"-d",
"--data",
default=os.environ.get("HOLOSCAN_INPUT_PATH", None),
help=("Set the data path"),
default=os.environ.get("HOLOSCAN_INPUT_PATH", default_data_path),
help=("Set the data path (default: %(default)s)."),
)
args = parser.parse_args()
record_type = args.record_type
Expand All @@ -316,6 +317,13 @@ def compose(self):
else:
config_file = args.config

# handle case where HOLOSCAN_INPUT_PATH is set with no value
if len(args.data) == 0:
args.data = default_data_path

if not os.path.isdir(args.data):
raise ValueError(f"Data path '{args.data}' does not exist. Use --data or set HOLOSCAN_INPUT_PATH environment variable.")

app = EndoscopyApp(record_type=record_type, source=args.source, data=args.data)
app.config(config_file)
app.run()
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ for k, v in obj[project_type]["run"].items():
workdir="cd ${holohub_build_dir}"
fi

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}"
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}"
local reset_environment="export PYTHONPATH=${PYTHONPATH} && export HOLOHUB_DATA_PATH=\"${HOLOHUB_DATA_PATH}\" && export HOLOSCAN_INPUT_PATH=\"${HOLOSCAN_INPUT_PATH}\""

if [ ${verbose} ]; then
Expand Down

0 comments on commit 9b38b15

Please sign in to comment.