Skip to content

Make a single GCS object usable as Data - #314

Open
JyotinderSingh wants to merge 3 commits into
keras-team:mainfrom
JyotinderSingh:fix-single-gcs-object-data
Open

Make a single GCS object usable as Data#314
JyotinderSingh wants to merge 3 commits into
keras-team:mainfrom
JyotinderSingh:fix-single-gcs-object-data

Conversation

@JyotinderSingh

Copy link
Copy Markdown
Collaborator

Description

Data("gs://bucket/dir/file.h5") resolved to the wrong thing on both data paths, silently.

  • Download: _download_data listed the prefix dir/file.h5/, which matches no object, so the ref resolved to an empty directory. It now tries a direct object fetch first and falls back to the prefix listing, which is what an uploaded local file needs (its ref names the content-hash directory, not the object). An is_dir=False ref that matches neither raises FileNotFoundError naming the URI.

  • FUSE: GCS FUSE mounts the object's parent, and _resolve_fuse_single_file returned os.listdir(mount)[0]: an arbitrary sibling whenever the parent held more than one object. It now picks the object out by the name in the ref's URI, and raises instead of guessing when that name is absent from a populated mount.

Covered against fake-gcs-server, with parent directories holding several objects, plus docker-tier roundtrips that read the file back inside a real container.

Contributor Agreement

  • I am a human, and not a bot.
  • I will be responsible for responding to review comments in a timely manner.
  • I will work with the maintainers to push this PR forward until submission.
  • I will test the changes on my cloud setup and provide proof of successful validation.

`Data("gs://bucket/dir/file.h5")` resolved to the wrong thing on both
paths, silently.

Download: `_download_data` listed the prefix `dir/file.h5/`, which
matches no object, so the ref resolved to an empty directory. It now
tries a direct object fetch first and falls back to the prefix listing,
which is what an uploaded local file needs (its ref names the
content-hash directory, not the object). An `is_dir=False` ref that
matches neither raises `FileNotFoundError` naming the URI.

FUSE: GCS FUSE mounts the object's parent, and
`_resolve_fuse_single_file` returned `os.listdir(mount)[0]` — an
arbitrary sibling whenever the parent held more than one object. It now
picks the object out by the name in the ref's URI, and raises instead of
guessing when that name is absent from a populated mount.

Covered against fake-gcs-server, with parent directories holding several
objects, plus docker-tier roundtrips that read the file back inside a
real container.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for single-file and single-object Data references in Kinetic, ensuring they resolve directly to file paths rather than directories for both downloaded data and GCS FUSE mounts. It introduces logic to download single objects directly and locate them within FUSE-mounted parent directories, accompanied by comprehensive tests and documentation updates. The review feedback suggests optimizing the _download_object helper by removing the redundant blob.exists() check and instead catching google.cloud.exceptions.NotFound during the download attempt to eliminate an unnecessary network round-trip.

Comment thread kinetic/runner/remote_runner.py Outdated
@codecov-commenter

codecov-commenter commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.53846% with 102 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a6adb41). Learn more about missing BASE report.

Files with missing lines Patch % Lines
kinetic/runner/remote_runner_test.py 0.00% 75 Missing ⚠️
kinetic/backend/execution_test.py 0.00% 21 Missing ⚠️
kinetic/backend/k8s_utils_test.py 0.00% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #314   +/-   ##
=======================================
  Coverage        ?   36.70%           
=======================================
  Files           ?       83           
  Lines           ?    15340           
  Branches        ?        0           
=======================================
  Hits            ?     5631           
  Misses          ?     9709           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Attempt the download and catch NotFound instead of checking exists()
first. google-cloud-storage opens the destination before it learns the
object is missing, but deletes it again on NotFound (>= 3.10, our
floor), so the miss leaves the target directory clean for the fallback
prefix listing that uploaded-file refs depend on.
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