Skip to content

feat: add environment files support and scotty file download helper - #2861

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/962222280
Open

feat: add environment files support and scotty file download helper#2861
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/962222280

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Aug 12, 2026

Copy link
Copy Markdown

feat: add environment files support and scotty file download helper

@copybara-service
copybara-service Bot force-pushed the copybara/962222280 branch 4 times, most recently from a22fc12 to 8c2fa18 Compare August 18, 2026 06:08
@copybara-service copybara-service Bot changed the title feat: add environment.files feat: add environment files support and scotty file upload/download helpers Aug 18, 2026
@copybara-service
copybara-service Bot force-pushed the copybara/962222280 branch 3 times, most recently from b482e89 to 92535be Compare August 19, 2026 17:20
@copybara-service copybara-service Bot changed the title feat: add environment files support and scotty file upload/download helpers feat: add environment files support and scotty file download helper Aug 19, 2026
@copybara-service
copybara-service Bot force-pushed the copybara/962222280 branch 3 times, most recently from f7be0ce to cff0c08 Compare August 21, 2026 17:49
Comment on lines 849 to +864
@property
def with_raw_response(self):
return _RawResponseAccessorProxy(super().with_raw_response)

@property
def with_streaming_response(self):
return _RawResponseAccessorProxy(super().with_streaming_response)

@property
def files(self) -> GeminiNextGenEnvironmentFiles:
return getattr(self, '_files_wrapper', None)

@files.setter
def files(self, value: Any) -> None:
self._sdk_files = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

IIUC client.environments.with_raw_response.files does the following:

  1. GeminiNextGenEnvironments.with_raw_response proxies to Environments.with_raw_response -> EnvironmentWithRawResponse
  2. calls __getattr__('files') on EnvironmentWithRawResponse -> self._sdk.files.with_raw_response
  3. self._sdk.files is the wrapper's files property so returns _files_wrapper = plain GeminiNextGenEnvironmentFiles with no with_raw_response -> AttributeError: 'GeminiNextGenEnvironmentFiles' object has no attribute 'with_raw_response'

Same thing expected for client.environments.with_streaming_response.files

I think it would be wise to add tests for with_raw/streaming_response helpers

Comment on lines +857 to +864
@property
def files(self) -> GeminiNextGenEnvironmentFiles:
return getattr(self, '_files_wrapper', None)

@files.setter
def files(self, value: Any) -> None:
self._sdk_files = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think these should be nested under if not TYPE_CHECKING. By doing so mypy could raise a "Files" has no attribute "download" for client.environments.files.download(...)` for example

Suggested change
@property
def files(self) -> GeminiNextGenEnvironmentFiles:
return getattr(self, '_files_wrapper', None)
@files.setter
def files(self, value: Any) -> None:
self._sdk_files = value
@property
def files(self) -> GeminiNextGenEnvironmentFiles:
return getattr(self, '_files_wrapper', None)
@files.setter
def files(self, value: Any) -> None:
self._sdk_files = value

Comment on lines 907 to +915

@property
def files(self) -> AsyncGeminiNextGenEnvironmentFiles:
return getattr(self, '_files_wrapper', None)

@files.setter
def files(self, value: Any) -> None:
self._sdk_files = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could streamline by initializing files: GeminiNextGenEnvironmentFiles instead of self._files_wrapper:

class GeminiNextGenEnvironments(GeneratedEnvironments):
    """Public environments resource backed by the NextGen client."""

    files: GeminiNextGenEnvironmentFiles

    def __init__(self, api_client: Any):
        self._api_client = api_client
        sdk = build_google_genai_client(api_client)
        super().__init__(sdk.sdk_configuration, parent_ref=sdk)

    def _init_sdks(self) -> None:
        self.files = GeminiNextGenEnvironmentFiles(
            self.sdk_configuration,
            parent_ref=self.parent_ref,
            api_client=self._api_client,
        )
Suggested change
@property
def files(self) -> AsyncGeminiNextGenEnvironmentFiles:
return getattr(self, '_files_wrapper', None)
@files.setter
def files(self, value: Any) -> None:
self._sdk_files = value


def __init__(self, api_client: Any):
self._api_client = api_client
self._files_wrapper = AsyncGeminiNextGenEnvironmentFiles(self)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment on lines +826 to +832
env_name = (
environment
if environment.startswith('environments/')
else f'environments/{environment}'
)
clean_path = path.lstrip('/')
download_path = f'{env_name}/files/{clean_path}?alt=media'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It seems inconsistent to normalize the environment path in download() but not list() (where we pass args directly to async_wrap_sdk_call(files_sdk.list, *args, **kwargs))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants