Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
74ff96c
chore: Preserve tags with nbclean
kdestin Jan 11, 2024
f9c79d7
chore: Add jupyter dev-requirements
kdestin Jan 26, 2024
7f5eeaa
feat: Add bicep files to setup an azure ai project
kdestin Jan 26, 2024
f541d81
chore: Pin versions in dev-requirements.txt
kdestin Jan 26, 2024
33ae735
test: Add a conftest.py
kdestin Jan 26, 2024
eb87b14
feat: Add a github action for running samples
kdestin Jan 26, 2024
c05fa25
refactor: Rename `openai_endpoint_name` to `azure_openai_connection_n…
kdestin Jun 12, 2024
1cd7d5c
refactor: Replace Azure.{Speech,ContentSafety,OpenAI} with AiServices
kdestin Jun 15, 2024
359ef9f
fix: Switch from workspaces/endpoints to workspaces/connections
kdestin Jun 15, 2024
574d9a1
refactor: Rename default hub and project names
kdestin Jun 17, 2024
44b2473
fix: Lower requested capacity for deployment
kdestin Jun 17, 2024
b6288b0
chore: Disable ruff ANN101
kdestin Jun 21, 2024
bcf7dc2
test: Add a pytest plugin for changed samples
kdestin Jun 24, 2024
8fffd83
chore: Move templates to .infra/templates
kdestin Jun 24, 2024
147562f
test: Add a pytest section to tox.ini
kdestin Jun 24, 2024
67dc6b9
fix: Serialize project deployments
kdestin Jun 24, 2024
d4a3dbb
chore: Update dev-requirements.txt
kdestin Nov 6, 2024
1f2482c
fix: Add missing installation extra for evaluate_nlp
kdestin Nov 7, 2024
b450834
refactor: Move user input to a cell suitable to be used with papermill
kdestin Nov 8, 2024
9f6ec31
chore: Misc notebook metadata updates
kdestin Nov 8, 2024
ca5553a
fix: Add missing credential parameters
kdestin Nov 8, 2024
97aa981
fix: Fix enum value moved to different enum
kdestin Nov 8, 2024
ec3a745
fix: Resolve broken call to Path.open
kdestin Nov 8, 2024
efdcbe8
fix: Fix incorrect environment variable names
kdestin Nov 8, 2024
6cf97bd
feat: Add support for generating role assignments
kdestin Nov 25, 2024
a3d4e31
refactor: Remove application insights
kdestin Nov 25, 2024
af56a2f
refactor: Update workspace connection to aoai and aiservices
kdestin Dec 5, 2024
54213b0
refactor: Update deployment module
kdestin Dec 5, 2024
44a6927
refactor: Update aiServices default name
kdestin Dec 5, 2024
b24774e
refactor: Update default rg name
kdestin Jan 6, 2025
569d976
fix: Resolve crash with `pytest --fixtures` from change-samples plugin
kdestin Jan 7, 2025
da6c7ee
refactor: Use a object instead of a list of objects for bicep deploym…
kdestin Jan 7, 2025
6232fde
feat: Bump gpt35 deployment to gpt4
kdestin Jan 7, 2025
3cc961f
feat: Add outputs for gpt4 deployment
kdestin Jan 7, 2025
1ff66fa
fix: Remove 'remote' extra that is no longer needed
kdestin Jan 7, 2025
8498686
style: Remove useless noqa
kdestin Jan 7, 2025
3828ac3
feat: Add .gitignores to ignore files created by samples
kdestin Jan 8, 2025
69bb351
chore: Add pytest config to pyproject.toml
kdestin Jan 8, 2025
c48bb1f
feat: Expose the project location as an output
kdestin Jan 8, 2025
65fba92
tests: Setup parameterization for evaluate scenarios
kdestin Jan 8, 2025
203f831
refactor: Move user input to a cell suitable to be used with papermill
kdestin Jan 8, 2025
942aa96
fix: Fix broken invocations of Path.open
kdestin Jan 8, 2025
ef16f48
chore: Update kernelspec displayname
kdestin Jan 8, 2025
1aa4c03
style: Format changed_samples plugin
kdestin Jan 8, 2025
7af3dc2
ci: Bump python version to 3.9
kdestin Jan 8, 2025
3dc9616
ci: Add principalId to resource deployment to enable role assignments
kdestin Jan 8, 2025
af27338
chore: Change azure ai project location to eastus2
kdestin Jan 8, 2025
1ba1541
ci: Bump pre-commit workflow to 3.9
kdestin Jan 8, 2025
4331bf6
ci: Fix branch filter for run-samples (notebooks/ -> scenarios/)
kdestin Jan 8, 2025
f9bbfec
ci: Bump az/login to v2
kdestin Jan 9, 2025
3d6732a
test: Add skips to untested samples
kdestin Jan 9, 2025
36492b7
fix,ci: Allow access to secrets
kdestin Jan 9, 2025
becef6a
fix: Enable publicNetworkAccess for aiservices
kdestin Jan 13, 2025
e0c22aa
feat: Allow specifying arbitrary git ref in changed sample plugin
kdestin Jan 13, 2025
2e05267
tests,feat: Run only changed samples
kdestin Jan 13, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.9"
- run: pip install -r dev-requirements.txt
- name: Run Pre-Commit
run: pre-commit run --all-files
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/run-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Run Samples
on:
# By design pull_request_target event run against the version of the workflow in the target branch.
# So you have to merge changes to this workflow to observe the effects.
pull_request_target:
branches:
- main
paths:
- scenarios/**
- .infra/deployments/**/*.bicep
jobs:
check-if-external:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set-environment.outputs.result }}
steps:
- uses: actions/github-script@v7
id: set-environment
with:
script: |
const actionInitiator = context.payload.sender.login;
const org = "Azure-Samples";
let isPublicMember = true;

// Check if initiator is a public member of the org
try {
await github.rest.orgs.checkPublicMembershipForUser({
org,
username: actionInitiator
});
} catch (error) {
if (error.status != 404) {
throw new Error("Unknown error", {cause: error});
}

console.debug([
`User is not a public member of the organization "${org}"`,
"",
`If you are a Microsoft employee, you can join the "${org}" org and set your org membership visibility to public: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-your-membership-in-organizations/publicizing-or-hiding-organization-membership#changing-the-visibility-of-your-organization-membership`
].join("\n"));

isPublicMember = false;
}


const isPullRequestEvent = ["pull_request", "pull_request_target"].includes(context.eventName);

if (!(isPublicMember && isPullRequestEvent)) {
return "external-contribution";
}
return "";
result-encoding: string
run-samples:
permissions:
contents: 'read'
id-token: 'write'
needs: check-if-external
runs-on: ubuntu-latest
# Require manual approval if initiator is not a public member of Azure-Samples
environment: ${{ needs.check-if-external.outputs.environment }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install dev dependencies
run: |
pip install -r dev-requirements.txt
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy resources
run: |
principalId="$(az ad sp show --id ${{ secrets.AZURE_CLIENT_ID }} -o tsv --query id)"
az deployment sub create --location eastus \
--template-file .infra/deployment/main.bicep \
--parameters principalType=ServicePrincipal \
--parameters principalId="$principalId" \
-o json > deployment.json
- name: Run samples
run:
pytest --changed-samples-only-from ${{ github.base_ref }}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@

# Ignore output of infra deployment used for testing
deployment.json

.virtual_documents/

# Ignore output files generated by running samples
*.output.ipynb
*output.json
*output.jsonl
*outputs.json
*outputs.jsonl
*result.json
*result.jsonl
*results.json
*results.jsonl

## Python Gitignore
## From: https://github.com/github/gitignore/blob/main/Python.gitignore

Expand Down
110 changes: 110 additions & 0 deletions .infra/deployment/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
targetScope = 'subscription'
param workspaceName string = 'azureai_samples_hub'
param projectName string = 'azureai_samples_proj'
param resourceGroupName string = 'rg-azureai-samples-validation-${utcNow('yyyyMM')}'
param location string = 'eastus2'
@description('The ID of the principal (user, service principal, etc...) to create role assignments for.')
param principalId string = ''

@description('The Type of the principal (user, service principal, etc...) to create role assignments for.')
@allowed([ 'User', 'ServicePrincipal', '' ])
param principalType string = ''

var acsName = 'acs-samples-${uniqueString(rg.id, workspaceName, workspaceName)}'

resource rg 'Microsoft.Resources/resourceGroups@2023-07-01' = {
#disable-next-line use-stable-resource-identifiers
name: resourceGroupName
location: location
}

module acs 'modules/acs.bicep' = { name: 'acs', params: { name: acsName, location: location }, scope: rg }

module workspace_hub 'modules/workspace_hub.bicep' = {
name: 'workspace-hub'
params: {
location: location
name: workspaceName
searchName: acs.outputs.name

}
scope: rg
}

module project 'modules/ai_project.bicep' = {
name: 'project'
params: {
location: location
workspaceHubID: workspace_hub.outputs.id
name: projectName
}
scope: rg
}

var deployments = {
gpt4: {
name: 'gpt-4'
properties: {
model: {
format: 'OpenAI'
name: 'gpt-4'
version: '1106-Preview'
}
}
}

text_embedding_ada_002: {
name: 'text-embedding-ada-002'
properties: {
model: {
format: 'OpenAI'
name: 'text-embedding-ada-002'
version: '2'
}
raiPolicyName: 'Microsoft.Default'
versionUpgradeOption: 'OnceNewDefaultVersionAvailable'
type: 'Azure.OpenAI'
sku: {
name: 'Standard'
capacity: 1
}
}
}
}

var roleDefinitionIds = [
'a001fd3d-188f-4b5d-821b-7da978bf7442' // Cognitive Services OpenAI Contributor
'ba92f5b4-2d11-453d-a403-e96b0029c9fe' // Storage Blob Data Contributor
]

module role_assignments 'modules/role_assignment.bicep' = [for rd in roleDefinitionIds: if (!empty(principalId)) {
name: 'role_assignment-${rd}'
params: {
principalId: principalId
principalType: principalType
roleDefinitionId: rd
}
scope: rg
}]

@batchSize(1)
module project_deployments 'modules/ai_project_deployment.bicep' = [for deployment in items(deployments): {
name: 'project_deployment-${deployment.value.name}'
params: {
name: deployment.value.name
properties: deployment.value.properties
ai_services_name: workspace_hub.outputs.ai_services_name
}
scope: rg
}]

@description('The ID of the subscription deployed to.')
output subscription_id string = subscription().subscriptionId
@description('The name of the resource group deployed to.')
output resource_group_name string = rg.name
@description('The name of the Azure AI Project.')
output project_name string = project.outputs.name
output project_location string = project.outputs.location
output azure_openai_endpoint string = workspace_hub.outputs.azure_openai_endpoint
output azure_openai_gpt4_api_version string = '2024-08-01-preview'
output azure_openai_gpt4_deployment_name string = deployments.gpt4.name
58 changes: 58 additions & 0 deletions .infra/deployment/modules/acs.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@description('Service name must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and is limited between 2 and 60 characters in length.')
@minLength(2)
@maxLength(60)
param name string

@allowed([
'free'
'basic'
'standard'
'standard2'
'standard3'
'storage_optimized_l1'
'storage_optimized_l2'
])
@description('The pricing tier of the search service you want to create (for example, basic or standard).')
param sku string = 'standard'

@description('Replicas distribute search workloads across the service. You need at least two replicas to support high availability of query workloads (not applicable to the free tier).')
@minValue(1)
@maxValue(12)
param replicaCount int = 1

@description('Partitions allow for scaling of document count as well as faster indexing by sharding your index over multiple search units.')
@allowed([
1
2
3
4
6
12
])
param partitionCount int = 1

@description('Applicable only for SKUs set to standard3. You can set this property to enable a single, high density partition that allows up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU.')
@allowed([
'default'
'highDensity'
])
param hostingMode string = 'default'

@description('Location for all resources.')
param location string = resourceGroup().location

resource search 'Microsoft.Search/searchServices@2020-08-01' = {
name: name
location: location
sku: {
name: sku
}
properties: {
replicaCount: replicaCount
partitionCount: partitionCount
hostingMode: hostingMode
}
}

output name string = search.name
output id string = search.id
22 changes: 22 additions & 0 deletions .infra/deployment/modules/ai_project.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
param name string
param nameFriendly string = name
param workspaceHubID string
param location string = resourceGroup().location

resource project 'Microsoft.MachineLearningServices/workspaces@2023-10-01' = {
name: name
#disable-next-line BCP187
kind: 'Project'
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
friendlyName: nameFriendly
#disable-next-line BCP037
hubResourceId: workspaceHubID
}
}

output name string = project.name
output location string = project.location
32 changes: 32 additions & 0 deletions .infra/deployment/modules/ai_project_deployment.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
param name string
param properties object
param ai_services_name string

var defaults = {
raiPolicyName: 'Microsoft.Default'
versionUpgradeOption: 'OnceNewDefaultVersionAvailable'
type: 'Azure.OpenAI'
sku: {
name: 'Standard'
capacity: 20
}
}

var properties_with_defaults = union(defaults, properties)

#disable-next-line BCP081
resource aiResource 'Microsoft.CognitiveServices/accounts@2024-06-01-preview' existing = {
name: ai_services_name

}

#disable-next-line BCP081
resource deployment 'Microsoft.CognitiveServices/accounts/deployments@2024-06-01-preview' = {
parent: aiResource
name: name
sku: properties_with_defaults.sku
properties: {
model: properties_with_defaults.model
versionUpgradeOption: properties_with_defaults.versionUpgradeOption
}
}
15 changes: 15 additions & 0 deletions .infra/deployment/modules/container_registry.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
param name string
param location string = resourceGroup().id

resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' = {
name: name
location: location
sku: {
name: 'Standard'
}
properties: {
adminUserEnabled: false
}
}

output id string = containerRegistry.id
19 changes: 19 additions & 0 deletions .infra/deployment/modules/keyvault.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
param name string
param location string = resourceGroup().location
param tenantId string = tenant().tenantId

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: name
location: location
properties: {
tenantId: tenantId
sku: {
name: 'standard'
family: 'A'
}
accessPolicies: []
enableSoftDelete: true
}
}

output id string = keyVault.id
Loading
Loading