Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .ado/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ schedules:
variables:
- name: QSHARP_PYTHON_TELEMETRY
value: none # Disable usage telemetry for internal test pipelines
- name: PYTEST_MAX_PARALLEL_TESTS
value: 'auto'

jobs:
- job: "Build_Azure_Quantum_Python"
Expand Down Expand Up @@ -58,7 +60,7 @@ jobs:
displayName: Set Python version

- script: |
pip install pytest pytest-azurepipelines pytest-cov pytest-regressions
pip install pytest pytest-azurepipelines pytest-cov pytest-xdist
displayName: Install pytest dependencies

- script: |
Expand All @@ -68,7 +70,7 @@ jobs:
- script: |
cd $(Build.SourcesDirectory)/azure-quantum
pip install .[qiskit,cirq,qsharp,dev]
pytest --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
pytest --numprocesses $(PYTEST_MAX_PARALLEL_TESTS) --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
displayName: Run azure-quantum unit tests

- task: PublishTestResults@2
Expand Down
6 changes: 4 additions & 2 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ variables:
value: 'xiou'
- name: QSHARP_PYTHON_TELEMETRY
value: none # Disable usage telemetry for internal test pipelines
- name: PYTEST_MAX_PARALLEL_TESTS
value: 'auto'

resources:
repositories:
Expand Down Expand Up @@ -108,7 +110,7 @@ extends:
displayName: Set Python version

- script: |
pip install pytest pytest-azurepipelines pytest-cov pytest-regressions
pip install pytest pytest-azurepipelines pytest-cov pytest-xdist
displayName: Install pytest dependencies

- script: |
Expand All @@ -118,7 +120,7 @@ extends:
- script: |
cd $(Build.SourcesDirectory)/azure-quantum
pip install .[qiskit,cirq,qsharp,dev]
pytest --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
pytest --numprocesses $(PYTEST_MAX_PARALLEL_TESTS) --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
displayName: Run Unit-tests

- task: PublishTestResults@2
Expand Down
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"pythonTestExplorer.testFramework": "pytest",
"pythonTestExplorer.outputs.showOutputsOnRun": true,
"testExplorer.useNativeTesting": false,
"testExplorer.showOnRun": true,
"testExplorer.addToEditorContextMenu": true,
"python.testing.pytestArgs": [
"./azure-quantum/tests/unit",
"-n",
"auto",
"--dist",
"loadgroup",
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
219 changes: 105 additions & 114 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions azure-quantum/.vscode/settings.json

This file was deleted.

67 changes: 7 additions & 60 deletions azure-quantum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,20 @@

# Azure Quantum #

[![Build Status](https://dev.azure.com/ms-quantum-public/Microsoft%20Quantum%20(public)/_apis/build/status/microsoft.qdk-python?branchName=main)](https://dev.azure.com/ms-quantum-public/Microsoft%20Quantum%20(public)/_build/latest?definitionId=32&branchName=main) [![PyPI version](https://badge.fury.io/py/azure-quantum.svg)](https://badge.fury.io/py/azure-quantum)
[![PyPI version](https://badge.fury.io/py/azure-quantum.svg)](https://badge.fury.io/py/azure-quantum)

Azure Quantum is Microsoft's cloud service for running Quantum Computing programs and circuits with our quantum partners and technologies. The `azure-quantum` package for Python provides functionality for interacting with Azure Quantum workspaces, including creating jobs, listing jobs, and retrieving job results. For more information, view the [Azure Quantum Documentation](https://learn.microsoft.com/en-us/azure/quantum/).
Azure Quantum is Microsoft's cloud service for running Quantum Computing programs. The `azure-quantum` package for Python provides functionality for interacting with Azure Quantum workspaces, including creating jobs, listing jobs, and retrieving job results. For more information, view the [Azure Quantum Documentation](https://learn.microsoft.com/en-us/azure/quantum/).

This package supports submitting quantum programs or circuits written with Python. To submit quantum programs written with Q#, Microsoft's Domain-specific language for Quantum Programming, view [Submit Q# Jobs to Azure Quantum](https://learn.microsoft.com/azure/quantum/how-to-submit-jobs).

## Installation ##

The package is released on PyPI and can be installed via `pip`:

```bash
pip install azure-quantum
```

To use `azure-quantum` for submitting quantum circuits expressed with [Qiskit](https://pypi.org/project/qiskit), install with optional dependencies:

```bash
pip install azure-quantum[qiskit]
```

To use `azure-quantum` for submitting quantum circuits expressed with [Cirq](https://pypi.org/project/cirq), install with optional dependencies:

```bash
pip install azure-quantum[cirq]
```
- For default installation - `pip install azure-quantum`
- Submit quantum circuits written in [Q#](https://pypi.org/project/qsharp) - `pip install azure-quantum[qsharp]`
- Submit quantum circuits written in [Qiskit](https://pypi.org/project/qiskit) - `pip install azure-quantum[qiskit]`
- Submit quantum circuits written in [Cirq](https://pypi.org/project/cirq) - `pip install azure-quantum[cirq]`

## Getting started and Quickstart guides ##

Expand Down Expand Up @@ -77,49 +66,7 @@ result = job.get_results()

## Examples ##

You can find example Python scripts that use the Azure Quantum Python API in the [examples](https://github.com/microsoft/qdk-python/tree/main/azure-quantum/examples) directory.

## Development Setup ##

For developers who want to contribute to this package or run tests locally, follow these steps:

### Prerequisites

- Python 3.9 or later
- Git
- Powershell

### Setting up the development environment

1. Clone the repository:
```bash
git clone https://github.com/microsoft/qdk-python.git
cd qdk-python/azure-quantum
```

2. Set up a virtual environment and install development dependencies:
```powershell
# On Windows (PowerShell)
.\eng\Setup-Dev-Env.ps1
```

3. Run the tests:
```bash
pytest tests/unit/
```

4. (Optional) Install additional provider dependencies:
```bash
# For specific providers
pip install -e .[pulser,quil]

# For all providers (requires Rust toolchain for PyQuil)
pip install -e .[all]
```

### Running Tests

The development environment includes pytest for running unit tests. See [tests/README.md](tests/README.md) for detailed testing instructions.
You can find example Python scripts that use the Azure Quantum Python API in the [samples](https://github.com/microsoft/azure-quantum-python/tree/main/samples) directory.

## Contributing ##

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def get_credential_or_default(self) -> Any:
or defaults to a new DefaultAzureCredential.
"""
return (self.credential
or DefaultAzureCredential())
or DefaultAzureCredential(exclude_interactive_browser_credential=False))

def get_auth_policy(self) -> Any:
"""
Expand Down
1 change: 1 addition & 0 deletions azure-quantum/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest>=7.1.2
pytest-xdist>=3.8.0,<4.0
vcrpy>=4.3.1 # fixes https://github.com/kevin1024/vcrpy/issues/688
azure-devtools>=1.2.0,<2.0
graphviz>=0.20.1
12 changes: 10 additions & 2 deletions azure-quantum/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ This will force the recording files to be deleted before running the tests.

To run the tests in recording or live mode, make sure:

- You have installed [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest).
- You're logged into your Azure Entra ID Tenant in the Azure CLI - `az login` (or `az login --tenant <tenantId>`).
- You have a client app registered in Microsoft Entra ID (formerly Azure Active Directory)
- The client app is configured with [certificate-based authentication](https://learn.microsoft.com/en-us/entra/identity/authentication/how-to-certificate-based-authentication)
- The client app has "Contributor" permissions to your Azure Quantum Workspace
- You have "Quantum Workspace Owner" or "Quantum Workspace Data Contributor" or "Contributor" role on the Azure Quantum Workspace against which you would like to capture the recordings.
- You have all necessary Providers added to the Azure Quantum Workspace.
- The following environment variables are set:
- `AZURE_CLIENT_ID` - application (client) ID from Microsoft Entra ID
- `AZURE_TENANT_ID` - directory (tenant) ID from Microsoft Entra ID
- `AZURE_CLIENT_CERTIFICATE_PATH` - path to PEM or PKCS12 certificate file (including the private key) that is configured for the client app
- `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN=True` - prompts Azure.Identity to set X5C header (specifying certificate chain) required to support SNI authentication
- `AZURE_QUANTUM_SUBSCRIPTION_ID` - ID of the Subscription where Azure Quantum Workspace is deployed
- `AZURE_QUANTUM_WORKSPACE_RG` - name of the Resource Group where Azure Quantum Workspace is deployed
- `AZURE_QUANTUM_WORKSPACE_NAME` - name of the Azure Quantum Workspace
Expand Down Expand Up @@ -154,3 +159,6 @@ skip_older_version = pytest.mark.skipif(__version__ != "0.0.1" and __version__ <
def test_my_test(self):
pass
```

Additionally, some of the Live Tests are marked with `@pytest.mark.xdist_group(name="<targetName>")` annotation.
This is to avoid failing concurrent tests when they're waiting in the same target queue on the provider side.
4 changes: 2 additions & 2 deletions azure-quantum/tests/unit/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from azure.quantum import Job
from azure.quantum.target import Target
from azure.identity import ClientSecretCredential, AzureCliCredential
from azure.identity import ClientSecretCredential, EnvironmentCredential


ZERO_UID = "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -304,7 +304,7 @@ def create_workspace(
client_secret=PLACEHOLDER)

workspace = Workspace(
credential=credential if credential else AzureCliCredential(),
credential=credential if credential else EnvironmentCredential(),
subscription_id=connection_params.subscription_id,
resource_group=connection_params.resource_group,
name=connection_params.workspace_name,
Expand Down
Loading
Loading