-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused CI file and bootstrap file and add back recording scrip…
…ts (#571) * Remove unused CI file and bootstrap file * Add devcontainer for running recordings * Add powershell to devcontainer
- Loading branch information
1 parent
bd4fc51
commit cf424ed
Showing
6 changed files
with
357 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "Generate Recordings", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/python:3.12", | ||
"features": { | ||
"ghcr.io/devcontainers/features/conda:1": {}, | ||
"ghcr.io/devcontainers/features/powershell:1": {} | ||
}, | ||
"customizations": { | ||
"codespaces": { | ||
"openFiles": [] | ||
}, | ||
"vscode": { | ||
"extensions": [ | ||
"quantum.qsharp-lang-vscode", | ||
"ms-python.python" | ||
] | ||
} | ||
}, | ||
"secrets": { | ||
"AZURE_CLIENT_ID": { | ||
"description": "The client ID of your Azure Quantum service principal." | ||
}, | ||
"AZURE_CLIENT_SECRET": { | ||
"description": "The client secret of your Azure Quantum service principal." | ||
}, | ||
"AZURE_TENANT_ID": { | ||
"description": "The tenant ID of your Azure Quantum service principal." | ||
}, | ||
"AZURE_QUANTUM_SUBSCRIPTION_ID": { | ||
"description": "The subscription ID of your Azure Quantum workspace." | ||
}, | ||
"AZURE_QUANTUM_WORKSPACE_RG": { | ||
"description": "The resource group of your Azure Quantum workspace." | ||
}, | ||
"AZURE_QUANTUM_WORKSPACE_NAME": { | ||
"description": "The name of your Azure Quantum workspace." | ||
}, | ||
"AZURE_QUANTUM_WORKSPACE_LOCATION": { | ||
"description": "The location of your Azure Quantum workspace." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
<# | ||
.SYNOPSIS | ||
Includes utility cmdlets for working with conda both locally, | ||
and in Azure Pipelines and other hosted environments. | ||
#> | ||
|
||
function Test-CondaEnabled { | ||
<# | ||
.SYNOPSIS | ||
Tests if conda has been enabled for shell | ||
use (e.g.: if conda activate will work). | ||
#> | ||
|
||
# The shell hook for conda creates a new cmdlet called | ||
# Invoke-Conda that is then aliased to `conda`. If the | ||
# full name (without an alias) is available, then the hook | ||
# has been run already. | ||
if ($null -ne (Get-Command Invoke-Conda -ErrorAction SilentlyContinue)) { | ||
return $true; | ||
} | ||
return $false; | ||
} | ||
|
||
function Enable-Conda { | ||
<# | ||
.SYNOPSIS | ||
Attempts to enable conda for shell usage, first using | ||
the CONDA environment variable for the path, falling back | ||
to PATH, and then failing. | ||
If conda is already enabled, this cmdlet does nothing, | ||
so that this cmdlet is idempotent. | ||
#> | ||
|
||
if (Test-CondaEnabled) { return $true; } | ||
|
||
if ("$Env:CONDA" -ne "") { | ||
# Try and run the shell hook from the path nominated | ||
# by CONDA. | ||
|
||
# On Windows, this is $Env:CONDA/Scripts/conda.exe, while on | ||
# Linux and macOS, this is $Env:CONDA/bin/conda. | ||
|
||
if ($IsWindows) { | ||
$condaBin = Join-Path $Env:CONDA "Scripts" "conda.exe"; | ||
} else { | ||
$condaBin = Join-Path $Env:CONDA "bin" "conda"; | ||
} | ||
|
||
if ($null -eq (Get-Command $condaBin -ErrorAction SilentlyContinue)) { | ||
Write-Error "##[error] conda binary was expected at $condaBin (CONDA = $Env:CONDA), but was not found."; | ||
throw; | ||
} | ||
|
||
(& $condaBin shell.powershell hook) | Out-String | Invoke-Expression; | ||
} else { | ||
(conda shell.powershell hook) | Out-String | Invoke-Expression; | ||
} | ||
} | ||
|
||
function Use-CondaEnv { | ||
param ( | ||
[string] $EnvName | ||
) | ||
<# | ||
.SYNOPSIS | ||
Activates a conda environment, reporting the new configuration | ||
after having done so. If conda has not already been enabled, this | ||
cmdlet will enable it before activating. | ||
#> | ||
|
||
Enable-Conda | ||
# NB: We use the PowerShell cmdlet created by the conda shell hook here | ||
# to avoid accidentally using the conda binary. | ||
Enter-CondaEnvironment $EnvName | ||
Write-Host "##[info]Activated Conda env: $(Get-PythonConfiguration | Out-String)" | ||
} | ||
|
||
function Install-Package() { | ||
param( | ||
[string] $EnvName, | ||
[string] $PackageName, | ||
[bool] $FromSource | ||
) | ||
# Activate env | ||
Use-CondaEnv $EnvName | ||
# Install package | ||
if ($True -eq $FromSource) { | ||
$ParentPath = Split-Path -parent $PSScriptRoot | ||
$AbsPackageDir = Join-Path $ParentPath $PackageName | ||
Write-Host "##[info]Install package $AbsPackageDir in development mode for env $EnvName" | ||
pip install -e $AbsPackageDir | ||
} else { | ||
Write-Host "##[info]Install package $PackageName for env $EnvName" | ||
pip install $PackageName | ||
} | ||
} | ||
|
||
function Get-PythonConfiguration { | ||
<# | ||
.SYNOPSIS | ||
Returns a table describing the current Python configuration, | ||
useful for diagnostic purposes. | ||
#> | ||
|
||
$table = @{}; | ||
|
||
$python = (Get-Command python -ErrorAction SilentlyContinue); | ||
if ($null -ne $python) { | ||
$table["PythonLocation"] = $python.Source; | ||
try { | ||
$table["PythonVersion"] = & $python --version; | ||
} catch { } | ||
} | ||
|
||
# If the CONDA environment variable is set, allow that to override | ||
# the local PATH. | ||
$conda = Get-Command conda -ErrorAction SilentlyContinue; | ||
|
||
if ($null -ne $conda) { | ||
$table["CondaLocation"] = $conda.Source; | ||
try { | ||
$table["CondaVersion"] = & $conda --version; | ||
} catch { } | ||
} | ||
|
||
# If the conda hook has already been run, we can get some additional | ||
# information for the table. | ||
if (Test-CondaEnabled) { | ||
try { | ||
$env = Get-CondaEnvironment | Where-Object -Property Active; | ||
if ($null -ne $env) { | ||
$table["CondaEnvName"] = $env.Name; | ||
$table["CondaEnvPath"] = $env.Path; | ||
} | ||
} catch { } | ||
} | ||
|
||
$table | Write-Output; | ||
} |
Oops, something went wrong.