Skip to content

Method updates following another api review meeting#47757

Merged
dargilco merged 18 commits into
mainfrom
dargilco/remove-download-to-file-overloads
Jun 30, 2026
Merged

Method updates following another api review meeting#47757
dargilco merged 18 commits into
mainfrom
dargilco/remove-download-to-file-overloads

Conversation

@dargilco

@dargilco dargilco commented Jun 29, 2026

Copy link
Copy Markdown
Member

After further consultation with the architects, we decided to roll back the Python support for file upload/download to/from disk.

This means that instead of these 4 methods on the .agent sub-client:

  • download_session_file_as_bytes
  • download_session_file_to_path
  • download_code_as_bytes
  • download_code_to_path

We'll just use the two emitted ones:

  • download_session_file
  • download_code

It also means we remove the upload_session_file overload that accepted file_path: Union[str, "os.PathLike[str]"], and just leave the emitted method that accepts content: bytes. In future releases, this will expand to support content: Union[bytes, IO[bytes]].

This PR also includes renaming "agent_session_id" input argument in session file method to just "session_id", to match the argument name in session methods.

This PR also includes reverting to the original "path" input argument name when uploading a session file. I previously did a client rename of this to "remote_path", since I had hand-written method to upload from file on disk, and it had an input argument name "file_path". At the time I wanted it to be clear what's the local path for upload and the remove path (in the session sandbox) where the file is written. Since I removed the upload session file from disk method, there is no longer a need to make that distinction. So I'm reverting back to the original name as used in REST APIs.

This PR also include flattening the method create_version_from_code, and simplifying code to be of type IO[bytes] only.

@dargilco dargilco self-assigned this Jun 29, 2026
@dargilco dargilco marked this pull request as ready for review June 30, 2026 03:47
Copilot AI review requested due to automatic review settings June 30, 2026 03:47

Copilot AI 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.

Pull request overview

This PR rolls back the Python-specific disk-based file helper methods on the hosted-agents sub-client of azure-ai-projects, following an architecture review. The custom download_session_file_to_path, download_code_to_path, download_session_file_as_bytes, download_code_as_bytes methods and the upload_session_file overload accepting a file_path are removed in favor of the emitted methods: download_session_file, download_code, and upload_session_file(content=bytes). The previously private _upload_session_file is promoted to public, and samples plus generated API metadata are updated accordingly.

Changes:

  • Remove the disk I/O helper methods and the file_path/overload-based upload_session_file from the _patch_agents customization layer (sync + async).
  • Rename generated operations (download_code_as_bytesdownload_code, download_session_file_as_bytesdownload_session_file, _upload_session_fileupload_session_file) and their request builders, with matching updates to api.md, api.metadata.yml, and apiview-properties.json.
  • Update hosted-agent samples to read file bytes manually and call the streamlined methods.

Note (outside PR scope): tests/sessions/test_agent_session_files_crud.py, its async counterpart, and docs/public-methods.md still reference the removed methods (download_session_file_as_bytes, download_session_file_to_path, download_code_to_path); these were not updated in this PR and would break/be out of sync.

Reviewed changes

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

Show a summary per file
File Description
operations/_patch_agents.py Removes disk-based helpers/overloads; leaves hashlib/os/Path imports now unused
aio/operations/_patch_agents_async.py Async counterpart of the same removal; same now-unused imports
operations/_operations.py Renames generated download/upload methods and request builders
aio/operations/_operations.py Async rename of the same generated methods and imports
samples/.../sample_sessions_files_upload_download.py Reads bytes and calls upload_session_file(content=...) / download_session_file
samples/.../sample_sessions_files_upload_download_async.py Async version of the sample update
samples/.../sample_create_hosted_agent_from_code.py Uses download_code + in-memory sha256; stale "streaming" comment
samples/.../sample_create_hosted_agent_from_code_async.py Async version; same stale comment
apiview-properties.json Updates cross-language method mappings and version
api.md / api.metadata.yml Regenerated API surface and hash

@dargilco dargilco enabled auto-merge (squash) June 30, 2026 21:12
@dargilco dargilco merged commit 9272f01 into main Jun 30, 2026
20 checks passed
@dargilco dargilco deleted the dargilco/remove-download-to-file-overloads branch June 30, 2026 21:13
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.

3 participants