Skip to content

Conversation

PauloVLB
Copy link
Member

@PauloVLB PauloVLB commented Oct 10, 2025

This PR is a follow-up to #4976, addressing the feedback and discussions from the original review. The primary focus is on refactoring and code quality improvements.

(Note: This PR involves a significant amount of code being moved to more appropriate modules.)


Quick summary:

  • Moved local setup functions into the setup.py module
  • Updated imports to be module-level, adhering to style guidelines.
  • Added a --local-logging flag to butler to enable convenient local log output during development.
  • Reduced the reliance on mocks in tests
  • Implemented logic to correctly handle minimized_keys during setup.
  • Improved error handling to be more Pythonic.
  • Removed unnecessary type hints and enhanced overall test reliability.

@PauloVLB PauloVLB marked this pull request as ready for review October 15, 2025 16:34
Copy link
Contributor

@javanlacerda javanlacerda left a comment

Choose a reason for hiding this comment

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

lgtm


# Make fuzzer executable.
os.chmod(fuzzer_path, 0o750)
os.chmod(fuzzer_path, _EXECUTABLE_PERMISSIONS)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

upload_url: str):
def archive_testcase_and_dependencies_in_gcs(
resource_list,
testcase_path: str, # pylint: disable=line-too-long
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line-too-long can be removed. ?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I've removed and runned lint again. Thanks!

@PauloVLB PauloVLB requested a review from vitaliset October 16, 2025 12:28
@ViniciustCosta
Copy link
Collaborator

Could you provide a quick evidence of these changes working?


try:
_, testcase_file_path = _get_testcase_file_and_path(testcase)
if testcase.minimized_keys and testcase.minimized_keys != 'NA':
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use the _is_testcase_minimized method here?


def set_local_log_only():
"""Force logs to be local-only."""
set_value('LOG_TO_GCP', '')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add a short comment explaining that we set this to an empty string because currently the logs module does not correctly evaluate env vars (i.e., 'false' is evaluated to true).

return archived, absolute_filename, zip_filename


def setup_local_testcase(testcase: data_types.Testcase) -> str | None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a preprocess_setup_testcase method which you don't define a local version. Is there a reason?

Also, I noticed that in this function, it sets the APP_ARGS based on the return of _get_application_arguments, which you do only in the reproduce module. Maybe you could try to do it here instead and using this helper method?

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for the reproduce butler."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

go/pystyle#test-docs

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.

4 participants