From 26ffcb9aeea34e3f7275b3fc398157387987c0c4 Mon Sep 17 00:00:00 2001 From: Jessica Marquis Date: Wed, 17 Apr 2024 13:35:19 -0400 Subject: [PATCH] Change Example filter 1 input file parameter to not accept all extensions --- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 26 ++++++++++++------- .../src/TestOne/Filters/ExampleFilter1.cpp | 4 +-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index f50d29c261..ee5f645368 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -521,7 +521,8 @@ PYBIND11_MODULE(simplnx, mod) parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, BoolParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, ChoicesParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); - parameters.def("__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); + parameters.def( + "__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); py::class_> iArrayThreshold(mod, "IArrayThreshold"); @@ -643,7 +644,8 @@ PYBIND11_MODULE(simplnx, mod) }, "Returns true if there is a DataStructure object at the given path"); - dataStructure.def("exists", [](DataStructure& self, const DataPath& path) { return (nullptr != self.getData(path)); }, "Returns true if there is a DataStructure object at the given path"); + dataStructure.def( + "exists", [](DataStructure& self, const DataPath& path) { return (nullptr != self.getData(path)); }, "Returns true if there is a DataStructure object at the given path"); dataStructure.def("hierarchy_to_str", [](DataStructure& self) { std::stringstream ss; self.exportHierarchyAsText(ss); @@ -1339,10 +1341,12 @@ PYBIND11_MODULE(simplnx, mod) }, "name"_a, "path"_a); pipeline.def("execute", &ExecutePipeline); - pipeline.def("__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); + pipeline.def( + "__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); pipeline.def("__len__", &Pipeline::size); pipeline.def("size", &Pipeline::size); - pipeline.def("__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); + pipeline.def( + "__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); pipeline.def( "insert", [internals](Pipeline& self, Pipeline::index_type index, const IFilter& filter, const py::dict& args) { @@ -1356,12 +1360,14 @@ PYBIND11_MODULE(simplnx, mod) pipeline.def("remove", &Pipeline::removeAt, "index"_a); pipelineFilter.def("get_args", [internals](PipelineFilter& self) { return ConvertArgsToDict(*internals, self.getParameters(), self.getArguments()); }); - pipelineFilter.def("set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); - pipelineFilter.def("get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); - pipelineFilter.def("name", [](PipelineFilter& self) { return self.getFilter()->name(); }, "Returns the C++ name of the filter"); - pipelineFilter.def("human_name", [](PipelineFilter& self) { return self.getFilter()->humanName(); }, "Returns the human facing name of the filter"); - - + pipelineFilter.def( + "set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); + pipelineFilter.def( + "get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); + pipelineFilter.def( + "name", [](PipelineFilter& self) { return self.getFilter()->name(); }, "Returns the C++ name of the filter"); + pipelineFilter.def( + "human_name", [](PipelineFilter& self) { return self.getFilter()->humanName(); }, "Returns the human facing name of the filter"); py::class_ pyFilter(mod, "PyFilter"); pyFilter.def(py::init<>([](py::object object) { return std::make_unique(std::move(object)); })); diff --git a/src/Plugins/TestOne/src/TestOne/Filters/ExampleFilter1.cpp b/src/Plugins/TestOne/src/TestOne/Filters/ExampleFilter1.cpp index 9cfaf94fbc..387243c6da 100644 --- a/src/Plugins/TestOne/src/TestOne/Filters/ExampleFilter1.cpp +++ b/src/Plugins/TestOne/src/TestOne/Filters/ExampleFilter1.cpp @@ -72,8 +72,8 @@ Parameters ExampleFilter1::parameters() const params.insert(std::make_unique(k_InputDir_Key, "Input Directory", "Example input directory help text", "Data", FileSystemPathParameter::ExtensionsType{}, FileSystemPathParameter::PathType::InputDir)); params.insert(std::make_unique(k_InputFile_Key, "Input File", "Example input file help text", "/opt/local/bin/ninja", FileSystemPathParameter::ExtensionsType{}, - FileSystemPathParameter::PathType::InputFile, true)); - params.insert(std::make_unique(k_OutputDir_Key, "Ouptut Directory", "Example output directory help text", "Output Data", FileSystemPathParameter::ExtensionsType{}, + FileSystemPathParameter::PathType::InputFile, false)); + params.insert(std::make_unique(k_OutputDir_Key, "Output Directory", "Example output directory help text", "Output Data", FileSystemPathParameter::ExtensionsType{}, FileSystemPathParameter::PathType::OutputDir)); params.insert(std::make_unique(k_OutputFile_Key, "Output File", "Example output file help text", "", FileSystemPathParameter::ExtensionsType{}, FileSystemPathParameter::PathType::OutputFile));