Skip to content

MINIFICPP-2606 Improve logging for python virtualenv initialization #2008

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lordgamez
Copy link
Contributor

https://issues.apache.org/jira/browse/MINIFICPP-2606


Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.

@lordgamez lordgamez requested a review from Copilot August 13, 2025 15:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves logging for Python virtual environment initialization by enhancing error handling and output capture. The changes focus on better visibility into the Python dependency installation process when issues occur.

  • Replaced std::system with a custom executeProcess function to capture command output
  • Added error handling and detailed logging for virtual environment creation and package installation
  • Enhanced Python dependency installer with progress bar suppression and better error reporting

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
PythonDependencyInstaller.cpp Added executeProcess function for better command execution with output capture and enhanced error logging for virtualenv operations
dependency_installer.py Fixed deprecated AST attribute access, added progress bar suppression, and improved error handling for pip installation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@lordgamez lordgamez marked this pull request as ready for review August 15, 2025 10:59
#define pclose _pclose
#endif

std::pair<int, std::string> executeProcess(const std::string& command) {
Copy link
Member

Choose a reason for hiding this comment

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

For the return type, I'd use an aggregate struct instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in e63c7c0

Comment on lines 67 to 76
std::string result;
while (fgets(buffer.data(), gsl::narrow<int>(buffer.size()), pipe) != nullptr) {
result += buffer.data();
}
Copy link
Member

Choose a reason for hiding this comment

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

An ostringstream would fit this problem better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in e63c7c0

#endif

std::pair<int, std::string> executeProcess(const std::string& command) {
std::array<char, 256> buffer{};
Copy link
Member

Choose a reason for hiding this comment

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

At the very least I'd increase the buffer size, and use the common buffer size constant.

Suggested change
std::array<char, 256> buffer{};
std::array<char, utils::configuration::DEFAULT_BUFFER_SIZE> buffer{};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in e63c7c0

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.

3 participants