Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added handling of relative paths #2384

Merged
merged 9 commits into from
Apr 12, 2024
Merged

Added handling of relative paths #2384

merged 9 commits into from
Apr 12, 2024

Conversation

bstrzele
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@mzegla mzegla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -3,7 +3,7 @@
"mediapipe_config_list": [
{
"name":"python_model",
"graph_path":"/workspace/graph.pbtxt"
"graph_path":"./graph.pbtxt"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it work if we go only with "graph.pbtxt"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that works too

@@ -422,7 +422,7 @@ Status MediapipeGraphDefinition::initializeNodes() {
}

std::shared_ptr<PythonNodeResources> nodeResources = nullptr;
Status status = PythonNodeResources::createPythonNodeResources(nodeResources, config.node(i), pythonBackend);
Status status = PythonNodeResources::createPythonNodeResources(nodeResources, config.node(i), pythonBackend, mgconfig.getBasePath());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the base_path an absolute path to the directory with config.json or graph.pbtxt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mgconfig.getBasePath() return path to graph.pbtxt

@@ -2260,7 +2260,7 @@ TEST_F(PythonFlowTest, FinalizePassTest) {
ASSERT_TRUE(::google::protobuf::TextFormat::ParseFromString(pbTxt, &config));

std::shared_ptr<PythonNodeResources> nodeResources = nullptr;
ASSERT_EQ(PythonNodeResources::createPythonNodeResources(nodeResources, config.node(0), getPythonBackend()), StatusCode::OK);
ASSERT_EQ(PythonNodeResources::createPythonNodeResources(nodeResources, config.node(0), getPythonBackend(), ""), StatusCode::OK);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is empty string a possible value? If createPythonNodeResources is not called with empty string as a basePath in any real scenario then this setting does not provide valueable information and might be misleading.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible in regular use case when pbtxt is located on file system. In case of these tests every value is equally valid, since there is no actual basePath in those scenarios.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, in that case can you add two tests for checking if base_path is passed as expected?
One with relative handler path, second with absolute and confirm that kwargs["base_path"] on the Python side is correct.

@@ -112,24 +113,29 @@ void createOutputTagNameMapping(std::shared_ptr<PythonNodeResources>& nodeResour
}
}

Status PythonNodeResources::createPythonNodeResources(std::shared_ptr<PythonNodeResources>& nodeResources, const ::mediapipe::CalculatorGraphConfig::Node& graphNodeConfig, PythonBackend* pythonBackend) {
Status PythonNodeResources::createPythonNodeResources(std::shared_ptr<PythonNodeResources>& nodeResources, const ::mediapipe::CalculatorGraphConfig::Node& graphNodeConfig, PythonBackend* pythonBackend, std::string basePath) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid ambiguity can we rename argument basePath to graphPath and then basePath could be used instead of parentPath. This way we instantly know that createPythonNodeResources gets path to the graph configuration, but preparePythonNodeInitializeArguments gets path to the handler file parent directory. Currently we use name basePath in more than one place, but it doesn't mean the same thing.

@@ -48,7 +48,7 @@ struct PythonNodeResources {
void finalize();

private:
static py::dict preparePythonNodeInitializeArguments(const ::mediapipe::CalculatorGraphConfig::Node& graphNodeConfig, std::string basePath);
static py::dict preparePythonNodeInitializeArguments(const ::mediapipe::CalculatorGraphConfig::Node& graphNodeConfig, std::string graphPath);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually here it would be basePath

@dtrawins dtrawins changed the base branch from llm_token_reporting to main April 12, 2024 13:09
@dtrawins dtrawins merged commit 73c3387 into main Apr 12, 2024
9 checks passed
@dtrawins dtrawins deleted the llm_relative_paths branch July 16, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants