Skip to content

refactor: centralize unusable file path checks - #468

Merged
kstonekuan merged 3 commits into
Hebbian-Robotics:mainfrom
Kaileshwar16:refactor/unusable-file-path
Sep 10, 2026
Merged

refactor: centralize unusable file path checks#468
kstonekuan merged 3 commits into
Hebbian-Robotics:mainfrom
Kaileshwar16:refactor/unusable-file-path

Conversation

@Kaileshwar16

Copy link
Copy Markdown
Contributor

Summary

Centralizes the repeated unusable-file-path validation used across storage and runtime code.

The new private _refuse_unusable_file_path() helper lives in storage.py, since that module already owns local path handling and both runtime modules already depend on it.

Changes

  • Added _refuse_unusable_file_path(path: Path) in src/hflow/storage.py

  • Replaced the duplicated directory / missing-file checks in:

    • LocalStorageRoot.fetch()
    • fetch_uri()
    • render_deploy_bundle()
    • render_bundle()
  • Preserved the existing behavior:

    • directories raise FileNotFoundError with errno.EISDIR
    • missing files raise FileNotFoundError with errno.ENOENT
    • the path is still passed as the third argument so filename and OS error text remain unchanged
  • Kept the reasoning for using FileNotFoundError instead of IsADirectoryError in one place on the helper

Validation

Ran:

uv sync --locked --all-extras
uv run ruff check
uv run ruff format --check
uv run ty check
uv run pytest -q

Result:

1638 passed, 7 skipped

Also confirmed the four existing storage regression tests pass with the helper in place.

As requested in the issue, I temporarily replaced the helper body with pass and confirmed all four regression tests fail because FileNotFoundError is no longer raised.

I also checked the current test suite for the four call sites. On the current main, both runtime sites now have missing-file and directory-path coverage, so the issue note that at least one site is untested appears to be outdated.

Closes #467

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

👋 Hi @Kaileshwar16 — thank you so much for your first contribution to HFlow!

A maintainer will review your pull request as soon as possible. In the meantime:

💡 Tip: one open pull request per contributor at a time. Issues with an assignee are taken; everything else is fair game.

We are excited to have you here and appreciate your help making the project better! 🙌

The issue named four sites. There are six: render_bundle and
render_deploy_bundle each run the same pair on config.requirements_file.
Both carried the comment 'for the reason above', and 'above' was the
explanation this PR moved onto the helper, so leaving them behind left
two comments pointing at nothing.

@kstonekuan kstonekuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Merging.

Two notes.

You are right that both runtime sites have coverage now, so ignore point 3 of the issue. I checked all of them by deleting each call individually, and every one turns a test red.

The issue also undercounted. There are six sites, not four: render_bundle and render_deploy_bundle each run the same pair on config.requirements_file. Both of those carried # FileNotFoundError, not IsADirectoryError, for the reason above., and "above" was the explanation this PR moves onto the helper, so leaving them behind left two comments pointing at nothing. I pushed a commit routing them through the helper too, dropping the now-unused errno and os imports, and adding the three-argument reasoning to the helper comment.

Validated on the merged result: ruff, ruff format, ty, 1713 passed / 6 skipped.

helper body neutered                12 failed
helper drops the directory clause    6 failed
helper drops the third argument      4 failed
site: LocalStorageRoot.fetch         3 failed
site: fetch_uri local branch         3 failed
site: render_bundle pipeline         2 failed
site: render_bundle requirements     1 failed
site: render_deploy_bundle pipeline  2 failed
site: render_deploy_bundle reqs      1 failed

The good first issue pool is best kept for newcomers, so for your next one, #480 is yours if you want it, or the higher-leverage version: run HFlow against a real corpus (Egocentric-10K or Egocentric-100K on Hugging Face) and report what breaks, what is slow, and what is awkward. That is the feedback we cannot generate ourselves.

@kstonekuan
kstonekuan merged commit 2a08a9f into Hebbian-Robotics:main Sep 10, 2026
6 checks passed
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.

Four sites hand-roll the same is-a-directory / not-found errno pair, two with byte-identical comments

2 participants