Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1be3808
chore: Preserve tags with nbclean
kdestin Jan 11, 2024
3accb23
chore: Add jupyter dev-requirements
kdestin Jan 26, 2024
3824443
feat: Add bicep files to setup an azure ai project
kdestin Jan 26, 2024
e8f228e
chore: Pin versions in dev-requirements.txt
kdestin Jan 26, 2024
0b09760
test: Add a conftest.py
kdestin Jan 26, 2024
4859c89
feat: Add a github action for running samples
kdestin Jan 26, 2024
52e2fca
refactor: Rename `openai_endpoint_name` to `azure_openai_connection_n…
kdestin Jun 12, 2024
9aea168
refactor: Replace Azure.{Speech,ContentSafety,OpenAI} with AiServices
kdestin Jun 15, 2024
e1e4833
fix: Switch from workspaces/endpoints to workspaces/connections
kdestin Jun 15, 2024
717bdfe
refactor: Rename default hub and project names
kdestin Jun 17, 2024
0d0049d
fix: Lower requested capacity for deployment
kdestin Jun 17, 2024
66e6083
chore: Disable ruff ANN101
kdestin Jun 21, 2024
a7a059f
test: Add a pytest plugin for changed samples
kdestin Jun 24, 2024
2bd43b4
chore: Move templates to .infra/templates
kdestin Jun 24, 2024
1057414
test: Add a pytest section to tox.ini
kdestin Jun 24, 2024
4024502
fix: Serialize project deployments
kdestin Jun 24, 2024
7158473
chore: Update dev-requirements.txt
kdestin Nov 6, 2024
d17e66a
fix: Add missing installation extra for evaluate_nlp
kdestin Nov 7, 2024
435bd97
refactor: Move user input to a cell suitable to be used with papermill
kdestin Nov 8, 2024
6a62356
chore: Misc notebook metadata updates
kdestin Nov 8, 2024
dec56e7
fix: Add missing credential parameters
kdestin Nov 8, 2024
759514b
fix: Fix enum value moved to different enum
kdestin Nov 8, 2024
295e344
fix: Resolve broken call to Path.open
kdestin Nov 8, 2024
91a8f5c
fix: Fix incorrect environment variable names
kdestin Nov 8, 2024
c6be454
feat: Add support for generating role assignments
kdestin Nov 25, 2024
037ae5b
refactor: Remove application insights
kdestin Nov 25, 2024
de4ecb5
refactor: Update workspace connection to aoai and aiservices
kdestin Dec 5, 2024
82a8b8f
refactor: Update deployment module
kdestin Dec 5, 2024
45722d8
refactor: Update aiServices default name
kdestin Dec 5, 2024
9b25f1d
refactor: Update default rg name
kdestin Jan 6, 2025
f5b2969
fix: Resolve crash with `pytest --fixtures` from change-samples plugin
kdestin Jan 7, 2025
e65b085
refactor: Use a object instead of a list of objects for bicep deploym…
kdestin Jan 7, 2025
6aa8e76
feat: Bump gpt35 deployment to gpt4
kdestin Jan 7, 2025
112467f
feat: Add outputs for gpt4 deployment
kdestin Jan 7, 2025
1ec3a57
fix: Remove 'remote' extra that is no longer needed
kdestin Jan 7, 2025
90bca75
style: Remove useless noqa
kdestin Jan 7, 2025
1ad5298
feat: Add .gitignores to ignore files created by samples
kdestin Jan 8, 2025
7ce0ebb
chore: Add pytest config to pyproject.toml
kdestin Jan 8, 2025
3b2354a
feat: Expose the project location as an output
kdestin Jan 8, 2025
71478f7
tests: Setup parameterization for evaluate scenarios
kdestin Jan 8, 2025
b8447ca
refactor: Move user input to a cell suitable to be used with papermill
kdestin Jan 8, 2025
a4e4a37
fix: Fix broken invocations of Path.open
kdestin Jan 8, 2025
cebd600
chore: Update kernelspec displayname
kdestin Jan 8, 2025
036a057
style: Format changed_samples plugin
kdestin Jan 8, 2025
e72e0f4
ci: Bump python version to 3.9
kdestin Jan 8, 2025
7924232
ci: Add principalId to resource deployment to enable role assignments
kdestin Jan 8, 2025
e14dd33
chore: Change azure ai project location to eastus2
kdestin Jan 8, 2025
ab38573
ci: Bump pre-commit workflow to 3.9
kdestin Jan 8, 2025
9c76e57
ci: Fix branch filter for run-samples (notebooks/ -> scenarios/)
kdestin Jan 8, 2025
016f558
ci: Bump az/login to v2
kdestin Jan 9, 2025
2c971d3
test: Add skips to untested samples
kdestin Jan 9, 2025
9616d56
fix,ci: Allow access to secrets
kdestin Jan 9, 2025
ac6406d
debug: test
kdestin Jan 9, 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
61 changes: 61 additions & 0 deletions .github/workflows/run-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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 isPublicMember = await octokit.rest.orgs.checkPublicMembershipForUser({
org: "Azure-Samples",
username: actionInitiator
});
const isPullRequestEvent = ["pull_request", "pull_request_target"].includes(context.eventName)
if (isPublicMember && isPullRequestEvent) {
return "external-contribution"
}
return ""
result-encoding: string
run-samples:
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: |
az deployment sub create --location eastus \
--template-file .infra/deployment/main.bicep \
--parameters principalType=ServicePrincipal \
--parameters principalId=${{ secrets.AZURE_CLIENT_ID }} \
-o json > deployment.json
- name: Run samples
run:
pytest
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
17 changes: 17 additions & 0 deletions .infra/deployment/modules/role_assignment.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
param principalId string
param principalType string
param roleDefinitionId string

resource roleDefinition 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
scope: resourceGroup()
name: roleDefinitionId
}

resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(resourceGroup().id, principalId, roleDefinition.id)
properties: {
roleDefinitionId: roleDefinition.id
principalId: principalId
principalType: principalType
}
}
Loading
Loading