Skip to content

fix: gcs_object_metadata_client can't handle required_tasks#467

Merged
kitagry merged 3 commits intomasterfrom
fix-required-task-gcs-tag
Jun 9, 2025
Merged

fix: gcs_object_metadata_client can't handle required_tasks#467
kitagry merged 3 commits intomasterfrom
fix-required-task-gcs-tag

Conversation

@kitagry
Copy link
Copy Markdown
Member

@kitagry kitagry commented Jun 6, 2025

fix #466

This pull request fix the _get_patched_obj_metadata method in gokart/gcs_obj_metadata_client.py.
In original code, we doesn't consider str type, so RecursionError was occurred. like #466 .

In this PR, I made the code simple and add tests in order to check the behaviors.

Copy link
Copy Markdown
Contributor

@hiro-o918 hiro-o918 left a comment

Choose a reason for hiding this comment

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

LGTM!

@kitagry
Copy link
Copy Markdown
Member Author

kitagry commented Jun 6, 2025

@TlexCypher Hi! Could you review this?

This comment was marked as outdated.

@Hi-king Hi-king requested a review from Copilot June 6, 2025 10:56
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 adds support for serializing required_task_outputs into object metadata in GCSObjectMetadataClient and includes a new test for this functionality.

  • Extend _get_patched_obj_metadata to include required_task_outputs
  • Implement _get_serialized_string to handle single, dict, and iterable inputs with type checking
  • Add a unit test for the new required_task_outputs parameter

Reviewed Changes

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

File Description
test/test_gcs_obj_metadata_client.py Imported RequiredTaskOutput and added test_get_patched_obj_metadata_with_required_task_outputs
gokart/gcs_obj_metadata_client.py Removed early return, added support for required_task_outputs, updated _get_serialized_string logic
Comments suppressed due to low confidence (5)

gokart/gcs_obj_metadata_client.py:117

  • The return type annotation FlattenableItems[str] doesn't reflect that this method may return dicts or lists; consider updating the type hint and/or renaming the method to match its actual outputs.
def _get_serialized_string(required_task_outputs: FlattenableItems[RequiredTaskOutput]) -> FlattenableItems[str]:

gokart/gcs_obj_metadata_client.py:98

  • The new required_task_outputs parameter isn't described in this method's docstring; please update the docstring to explain its purpose and supported types.
def _get_patched_obj_metadata(

test/test_gcs_obj_metadata_client.py:117

  • Add tests for passing a single RequiredTaskOutput instance and a dict of outputs to cover all branches in _get_serialized_string.
def test_get_patched_obj_metadata_with_required_task_outputs(self):

test/test_gcs_obj_metadata_client.py:117

  • Include a test case that verifies a TypeError is raised when an unsupported type is passed to required_task_outputs.
def test_get_patched_obj_metadata_with_required_task_outputs(self):

gokart/gcs_obj_metadata_client.py:122

  • Ensure Iterable is imported (from collections.abc or typing) to avoid a potential NameError at runtime.
elif isinstance(required_task_outputs, Iterable):

Comment thread gokart/gcs_obj_metadata_client.py Outdated

@staticmethod
def _get_serialized_string(required_task_outputs: FlattenableItems[RequiredTaskOutput]) -> FlattenableItems[str]:
def _iterable_flatten(nested_list: Iterable) -> Iterable[str]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah—since str is also an Iterable, calling:

_iterable_flatten([["a"]]) will never terminate.

The following implementation of _iterable_flatten works correctly:

def _iterable_flatten(nested_list: Iterable) -> Iterable[str]:
    for item in nested_list:
        if isinstance(item, str):
            yield item
        elif isinstance(item, Iterable):
            yield from _iterable_flatten(item)
        else:
            yield item

However, since recursion is only needed for _get_serialized_string, you removed iterable_flatten entirely, right? @kitagry

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kitagry Please include that background in the PR comment for future reference.

kitagry and others added 2 commits June 9, 2025 09:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Hi-king Hi-king force-pushed the fix-required-task-gcs-tag branch from a6f101b to ed10eb8 Compare June 9, 2025 00:30
Copy link
Copy Markdown
Member

@Hi-king Hi-king left a comment

Choose a reason for hiding this comment

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

Confirmed this logic clearly converts FlattenableItems[RequiredTaskOutput] into FlattenableItems[str]. :)

LGTM.

@kitagry kitagry merged commit 855ef94 into master Jun 9, 2025
8 checks passed
@kitagry kitagry deleted the fix-required-task-gcs-tag branch June 9, 2025 00:53
@tyzerrr
Copy link
Copy Markdown
Contributor

tyzerrr commented Jun 9, 2025

@kitagry
Sorry to be late for replying...
Thank u for fix my bug..!

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.

RecursionError: maximum recursion depth exceeded

5 participants