Skip to content

Quantum: Add Job.list_attachments() - #768

Merged
Scott Carda (ScottCarda-MS) merged 2 commits into
microsoft:mainfrom
v-elegacheva:ekaterina/job-list-attachments
Aug 13, 2026
Merged

Quantum: Add Job.list_attachments()#768
Scott Carda (ScottCarda-MS) merged 2 commits into
microsoft:mainfrom
v-elegacheva:ekaterina/job-list-attachments

Conversation

@v-elegacheva

@v-elegacheva v-elegacheva commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new Job.list_attachments() method to the Azure Quantum Python SDK that lists every blob in a job's Azure Storage output container, returning lightweight metadata (name, size, last modified) for each. This gives Python users a programmatic way to discover a job's associated files, without downloading them, complementing the existing upload_attachment / download_attachment methods.

Changes

  • base_job.py- Added list_attachments() -> list[BlobProperties]. It resolves the job's linked storage container (from self.details.container_uri, falling back to workspace.get_container_uri(job_id=self.id) ), opens a ContainerClient, and returns list(container_client.list_blobs()). Returning BlobProperties` keeps the API consisten with other types listing APIs in the package rather than returning ad-hoc dicts.
  • test_job_attachments.py (new)- unit tests

Testing

testing_job_attachments.py - 2 tests, all passing:

  • test_list_attachments_returns_container_blobs: returns the container's blob as-is.
  • test_list_attachments_uses_workspace_container_when_unset: falls back to workspace.get_container_uri(job_id= ...) when the job has no linked container URI.
  • Manual E2E test against a real Azure Quantum workspace

@v-elegacheva
v-elegacheva requested a lite review from Copilot August 11, 2026 19:46
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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

Adds a new Job.list_attachments() API to enumerate blob names in a job’s output/input container, enabling callers to discover available attachments without downloading them.

Changes:

  • Introduces BaseJob.list_attachments() that resolves the effective container URI (job-linked or workspace-derived) and lists blob names.
  • Adds unit tests covering default container URI usage, workspace fallback, and explicit override behavior.

Reviewed changes

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

File Description
azure-quantum/azure/quantum/job/base_job.py Adds list_attachments() to list blob names from the job container.
azure-quantum/tests/test_job_attachments.py New tests validating container resolution logic and returned blob name list.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
@v-elegacheva
v-elegacheva force-pushed the ekaterina/job-list-attachments branch from 5f7359c to 1b2582d Compare August 11, 2026 19:55
@v-elegacheva
v-elegacheva requested a lite review from Copilot August 11, 2026 19:56
@v-elegacheva v-elegacheva changed the title Add Job.list_attachments() to enumerate a job's output container blobs Quantum: Add Job.list_attachments() Aug 11, 2026

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

azure-quantum/azure/quantum/job/base_job.py:366

  • download_attachment() returns the result of readall() (bytes), but the new return type annotation is list[str]. This makes the public API type contract incorrect for callers and static type checking.
    def download_attachment(
        self,
        name: str,
        container_uri: Optional[str] = None
    ) -> list[str]:

@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@v-elegacheva
v-elegacheva force-pushed the ekaterina/job-list-attachments branch from 1b2582d to 64815d4 Compare August 12, 2026 17:47
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@v-elegacheva
v-elegacheva requested a lite review from Copilot August 12, 2026 17:48
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

azure-quantum/azure/quantum/job/base_job.py:396

  • list_attachments is a public API but its return type is annotated as plain list, which loses key/value information for callers. Since the method always returns a list of dicts with string keys, consider tightening the return annotation.
    def list_attachments(
        self,
        container_uri: Optional[str] = None
    ) -> list:

azure-quantum/azure/quantum/job/base_job.py:366

  • download_attachment now advertises a list[str] return type, but it returns the result of readall() (bytes). This makes the public type contract incorrect and can break type checking / IDE hints.

This issue also appears on line 393 of the same file.

    def download_attachment(
        self,
        name: str,
        container_uri: Optional[str] = None
    ) -> list[str]:

@v-elegacheva
v-elegacheva marked this pull request as ready for review August 12, 2026 20:19
@v-elegacheva
v-elegacheva requested a review from a team as a code owner August 12, 2026 20:19
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@v-elegacheva
v-elegacheva marked this pull request as draft August 12, 2026 20:21
@ScottCarda-MS
Scott Carda (ScottCarda-MS) marked this pull request as ready for review August 12, 2026 22:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@ScottCarda-MS
Scott Carda (ScottCarda-MS) marked this pull request as draft August 12, 2026 22:12
Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
@v-elegacheva
v-elegacheva force-pushed the ekaterina/job-list-attachments branch from 64815d4 to 08dc1d3 Compare August 12, 2026 23:20
@v-elegacheva
v-elegacheva requested a lite review from Copilot August 12, 2026 23:28
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

azure-quantum/azure/quantum/job/base_job.py:409

  • The PR description says Job.list_attachments(container_uri: Optional[str] = None) should resolve the container from an explicit argument (if provided) and return lightweight metadata dicts (name/size/lastModified). The current implementation has no container_uri parameter and returns raw BlobProperties objects, so the public API does not match the described contract. Consider aligning this method with the existing upload_attachment/download_attachment container resolution logic and returning metadata dicts.
    def list_attachments(self) -> list[BlobProperties]:
        """ Lists the attachments in the job's linked storage container. Attachments are blobs of
            data created as part of the Job's execution, or they can be uploaded directly from Python
            using the upload_attachment method.

azure-quantum/tests/test_job_attachments.py:39

  • If list_attachments() is intended (per PR description) to return lightweight metadata dicts, this test should validate the returned shape rather than returning the raw blob objects from list_blobs(). As written, the test would pass even if the method did no projection and returned SDK objects directly.
def test_list_attachments_returns_container_blobs(mock_container_client):
    job = _job_with_container()

    blob_a = Mock()
    blob_b = Mock()

azure-quantum/tests/test_job_attachments.py:54

  • The PR description states there are 3 tests, including coverage for an explicit container_uri override. This file currently has only 2 tests and does not verify that an explicit container_uri is preferred over job_details.container_uri / workspace.get_container_uri(...). Adding that test would prevent regressions in the container-resolution precedence.
@patch("azure.quantum.job.base_job.ContainerClient")
def test_list_attachments_uses_workspace_container_when_unset(mock_container_client):
    workspace = Mock()
    workspace.get_container_uri.return_value = CONTAINER_URI
    job = _job_with_container(container_uri=None, workspace=workspace)

    container = mock_container_client.from_container_url.return_value
    container.list_blobs.return_value = []

    result = job.list_attachments()

    workspace.get_container_uri.assert_called_once_with(job_id="job-id")
    mock_container_client.from_container_url.assert_called_once_with(CONTAINER_URI)
    assert result == []

@v-elegacheva
v-elegacheva marked this pull request as ready for review August 13, 2026 17:30
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ScottCarda-MS

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ScottCarda-MS
Scott Carda (ScottCarda-MS) merged commit 4640862 into microsoft:main Aug 13, 2026
6 checks passed
@v-elegacheva
v-elegacheva deleted the ekaterina/job-list-attachments branch August 13, 2026 19:39
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.

4 participants