From 5a51758e11c78cf8ef885b4e862a6dfbbe5f1075 Mon Sep 17 00:00:00 2001 From: Oleksandr Kozlenko Date: Mon, 27 Jan 2025 21:08:29 -0500 Subject: [PATCH] Forward cancellation tokens in QuantumJobClient --- .../Azure.Quantum.Jobs/src/QuantumJobClient.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sdk/quantum/Azure.Quantum.Jobs/src/QuantumJobClient.cs b/sdk/quantum/Azure.Quantum.Jobs/src/QuantumJobClient.cs index 165cec22de29..26aa01f7e5fb 100644 --- a/sdk/quantum/Azure.Quantum.Jobs/src/QuantumJobClient.cs +++ b/sdk/quantum/Azure.Quantum.Jobs/src/QuantumJobClient.cs @@ -67,15 +67,17 @@ public virtual async Task> GetJobAsync(string jobId, Cancel } /// Return list of jobs. + /// The cancellation token to use. public virtual Pageable GetJobs(CancellationToken cancellationToken = default) { - return PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _jobs.List() : _jobs.ListNextPage(cont))); + return PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _jobs.List(cancellationToken) : _jobs.ListNextPage(cont, cancellationToken))); } /// Return list of jobs. + /// The cancellation token to use. public virtual AsyncPageable GetJobsAsync(CancellationToken cancellationToken = default) { - return PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _jobs.ListAsync().ConfigureAwait(false) : await _jobs.ListNextPageAsync(cont).ConfigureAwait(false))); + return PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _jobs.ListAsync(cancellationToken).ConfigureAwait(false) : await _jobs.ListNextPageAsync(cont, cancellationToken).ConfigureAwait(false))); } /// Create a job. @@ -120,28 +122,28 @@ public virtual async Task CancelJobAsync(string jobId, CancellationTok /// The cancellation token to use. public virtual Pageable GetProviderStatus(CancellationToken cancellationToken = default) { - return PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _providers.GetStatus() : _providers.GetStatusNextPage(cont))); + return PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _providers.GetStatus(cancellationToken) : _providers.GetStatusNextPage(cont, cancellationToken))); } /// Get provider status. /// The cancellation token to use. public virtual AsyncPageable GetProviderStatusAsync(CancellationToken cancellationToken = default) { - return PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _providers.GetStatusAsync().ConfigureAwait(false) : await _providers.GetStatusNextPageAsync(cont).ConfigureAwait(false))); + return PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _providers.GetStatusAsync(cancellationToken).ConfigureAwait(false) : await _providers.GetStatusNextPageAsync(cont, cancellationToken).ConfigureAwait(false))); } /// Get quota status. /// The cancellation token to use. public virtual Pageable GetQuotas(CancellationToken cancellationToken = default) { - return PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _quotas.List() : _quotas.ListNextPage(cont))); + return PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _quotas.List(cancellationToken) : _quotas.ListNextPage(cont, cancellationToken))); } /// Get quota status. /// The cancellation token to use. public virtual AsyncPageable GetQuotasAsync(CancellationToken cancellationToken = default) { - return PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _quotas.ListAsync().ConfigureAwait(false) : await _quotas.ListNextPageAsync(cont).ConfigureAwait(false))); + return PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _quotas.ListAsync(cancellationToken).ConfigureAwait(false) : await _quotas.ListNextPageAsync(cont, cancellationToken).ConfigureAwait(false))); } /// Gets a URL with SAS token for a container/blob in the storage account associated with the workspace. The SAS URL can be used to upload job input and/or download job output.