Skip to content

fix: add logging option for directory creation in get_full_path#929

Open
wakonig wants to merge 2 commits into
mainfrom
chore/log_dir_creation
Open

fix: add logging option for directory creation in get_full_path#929
wakonig wants to merge 2 commits into
mainfrom
chore/log_dir_creation

Conversation

@wakonig
Copy link
Copy Markdown
Member

@wakonig wakonig commented Jun 2, 2026

Description

get_full_path creates the directory by default. To be able to migrate to a less-permissive service account, we need to move the file access to the file writer service. For now, we should get a better awareness of methods that actually create them. To this end, I propose to add a log to the directory creation. We can monitor it later with grafana.
I would expect that they actually don't create the directory as the file writer should create it as soon as the scan is opened but there could be a timing issue.

Type of Change

  • Add log to the get_full_path
  • Add a wait_for_directory helper method

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bec_lib/bec_lib/file_utils.py 81.81% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@wakonig wakonig self-assigned this Jun 2, 2026
@wakonig wakonig marked this pull request as ready for review June 2, 2026 11:27
Copilot AI review requested due to automatic review settings June 2, 2026 11:27
Copy link
Copy Markdown
Contributor

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 aims to improve observability around directory creation performed by bec_lib.file_utils.get_full_path, to help identify unexpected directory creation while migrating toward a less-permissive service account. It also introduces a small polling helper to wait for directory availability.

Changes:

  • Added an optional warning log in get_full_path when it is about to create a missing directory.
  • Added wait_for_directory(path, timeout, interval) helper for polling until a directory exists (or timing out).
  • Added unit tests covering wait_for_directory success/timeout behavior.

Reviewed changes

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

File Description
bec_server/bec_server/file_writer/file_writer_manager.py Passes a new flag to suppress directory-creation logging when calling get_full_path.
bec_lib/bec_lib/file_utils.py Extends get_full_path with a logging option and adds wait_for_directory.
bec_lib/tests/test_file_utils.py Adds tests for wait_for_directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bec_lib/bec_lib/file_utils.py
Comment thread bec_lib/bec_lib/file_utils.py
Comment thread bec_server/bec_server/file_writer/file_writer_manager.py
Comment thread bec_server/bec_server/file_writer/file_writer_manager.py
@wakonig wakonig requested a review from a team June 2, 2026 11:31
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.

2 participants