Skip to content
Open
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
3 changes: 3 additions & 0 deletions cli/azd/extensions/azure.ai.rle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
artifacts/
registry-artifacts/
17 changes: 17 additions & 0 deletions cli/azd/extensions/azure.ai.rle/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"

linters:
default: none
enable:
- gosec
- lll
- unused
- errorlint
settings:
lll:
line-length: 220
tab-width: 4

formatters:
enable:
- gofmt
5 changes: 5 additions & 0 deletions cli/azd/extensions/azure.ai.rle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 0.1.0-preview

- Initial preview scaffold for the RLE extension with `create`, `modify`, and `version` commands.
153 changes: 153 additions & 0 deletions cli/azd/extensions/azure.ai.rle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Azure AI RLE extension for azd

The `azure.ai.rle` extension adds the `azd ai rle` command group.

## Local setup

### 1. Install prerequisites

Install:

- Azure Developer CLI (`azd`): https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd
- Go: https://go.dev/doc/install
- Git, for local development and for fetching the managed Loom recipe: https://git-scm.com/downloads
- Python: https://www.python.org/downloads/
- uv, for running the Loom training recipe: https://docs.astral.sh/uv/getting-started/installation/

Verify:

```powershell
azd version
go version
git --version
python --version
```

`az login` is not required for the current `init`/`deploy` flow because deploy calls the RLE control plane directly.

### 2. Check out the branch

```powershell
git fetch origin
git checkout farhannawaz/rle-cli
cd cli\azd\extensions\azure.ai.rle
```

### 3. Configure the RLE control plane

```powershell
$env:RLE_ENDPOINT = "http://localhost:5000"
$env:RLE_PROJECT_NAME = "demo-3"
```

`http://localhost:5000` is also the built-in default, so you can omit `RLE_ENDPOINT` when using a local RLE control plane. To target the hosted control plane, set `RLE_ENDPOINT` to its URL.

For `invoke`, provide the Azure AI project endpoint as a parameter:

```powershell
az login
```

The environment image is no longer configured through an environment variable. By default,
`deploy` registers a per-environment image named after the environment (for example
`devrle.azurecr.io/code-rl:latest`). Use `--image <reference>` to deploy a specific prebuilt
image instead.

### 4. Install the extension into azd

Run these commands from the extension directory:

```powershell
azd extension install microsoft.azd.extensions
azd x build
azd x pack
azd x publish
azd extension install azure.ai.rle --source local --force
```

`azd x build` builds the extension artifacts. `azd x pack` and `azd x publish`
register them in the local azd extension source, and `azd extension install`
makes the `azd ai rle` command group available in any terminal.

Verify:

```powershell
azd ai rle --help
azd ai rle version
```

After making local code changes, rebuild and update the installed extension with:

```powershell
azd x build
azd x pack
azd x publish
azd extension install azure.ai.rle --source local --force
```

### 5. Initialize a local RLE session

```powershell
azd ai rle init code_rl
```

Init creates a local session folder named `code_rl`, including an OpenEnv-style FastAPI package, `Dockerfile`, `rle.yaml`, and azd-managed dependencies under `.azd-rle\deps`.

Deploy from the session folder:

```powershell
cd .\code_rl
azd ai rle deploy --project omi-build-demo-uae
```

Deploy creates or updates the RLE environment and saves the project plus environment id/version locally in `.azd-rle.json`.

### 6. Run Loom training

```powershell
azd ai rle invoke `
--recipe code_rl_with_rle `
--project-endpoint "https://omi-build-demo-uae.services.ai.azure.com/api/projects/omi-build-demo-uae"
```

Invoke runs the selected Loom recipe's `train_azure.py` entrypoint with values from `.azd-rle.json`.
It passes the deployed RLE environment id, project, and control-plane endpoint to the Loom recipe,
which uses `rle_sdk` to lease sandboxes and call `reset`/`step` during training.

Invoke fetches Loom branch `code_rl_with_rle` into `.azd-rle\recipes\loom`
and uses the RLE SDK wheel copied by `init`. You do not need a separate local Loom checkout
or a separately installed RLE SDK package. The managed Git checkout is shallow, single-branch,
and tagless (`--depth 1 --single-branch --no-tags`). In the future this recipe dependency can
move from Git to a published package.

After fetching Loom, invoke patches only the managed copy of `loom-cookbook\pyproject.toml`
so `uv` resolves `azure-ai-finetuning-sessions` from the fetched Loom checkout and `rle-sdk`
from `.azd-rle\deps`.

The default invoke settings are:

```text
num_tasks=4
model_name=Qwen/Qwen3-32B
renderer_name=qwen3_disable_thinking
max_tokens=1200
lora_rank=32
group_size=4
groups_per_batch=1
max_steps=1
loss_fn=importance_sampling
seed=42
eval_every=999999
save_every=999999
remove_constant_reward_groups=true
```

Override the recipe, task count, or model with flags, for example:

```powershell
azd ai rle invoke `
--recipe code_rl_with_rle `
--project-endpoint "https://omi-build-demo-uae.services.ai.azure.com/api/projects/omi-build-demo-uae" `
--num-tasks 4 `
--model-name "Qwen/Qwen3-32B"
```
78 changes: 78 additions & 0 deletions cli/azd/extensions/azure.ai.rle/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Ensure script fails on any error
$ErrorActionPreference = 'Stop'

# Get the directory of the script
$EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path

# Change to the script directory
Set-Location -Path $EXTENSION_DIR

# Create a safe version of EXTENSION_ID replacing dots with dashes
$EXTENSION_ID_SAFE = $env:EXTENSION_ID -replace '\.', '-'

# Define output directory
$OUTPUT_DIR = if ($env:OUTPUT_DIR) { $env:OUTPUT_DIR } else { Join-Path $EXTENSION_DIR "bin" }

# Create output directory if it doesn't exist
if (-not (Test-Path -Path $OUTPUT_DIR)) {
New-Item -ItemType Directory -Path $OUTPUT_DIR | Out-Null
}

# Get Git commit hash and build date
$COMMIT = git rev-parse HEAD
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to get git commit hash"
exit 1
}
$BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ")

# List of OS and architecture combinations
if ($env:EXTENSION_PLATFORM) {
$PLATFORMS = @($env:EXTENSION_PLATFORM)
}
else {
$PLATFORMS = @(
"windows/amd64",
"windows/arm64",
"darwin/amd64",
"darwin/arm64",
"linux/amd64",
"linux/arm64"
)
}

$APP_PATH = "$env:EXTENSION_ID/internal/cmd"

# Loop through platforms and build
foreach ($PLATFORM in $PLATFORMS) {
$OS, $ARCH = $PLATFORM -split '/'

$OUTPUT_NAME = Join-Path $OUTPUT_DIR "$EXTENSION_ID_SAFE-$OS-$ARCH"

if ($OS -eq "windows") {
$OUTPUT_NAME += ".exe"
}

Write-Host "Building for $OS/$ARCH..."

# Delete the output file if it already exists
if (Test-Path -Path $OUTPUT_NAME) {
Remove-Item -Path $OUTPUT_NAME -Force
}

# Set environment variables for Go build
$env:GOOS = $OS
$env:GOARCH = $ARCH

go build `
-ldflags="-X '$APP_PATH.Version=$env:EXTENSION_VERSION' -X '$APP_PATH.Commit=$COMMIT' -X '$APP_PATH.BuildDate=$BUILD_DATE'" `
-o $OUTPUT_NAME

if ($LASTEXITCODE -ne 0) {
Write-Host "An error occurred while building for $OS/$ARCH"
exit 1
}
}

Write-Host "Build completed successfully!"
Write-Host "Binaries are located in the $OUTPUT_DIR directory."
66 changes: 66 additions & 0 deletions cli/azd/extensions/azure.ai.rle/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Get the directory of the script
EXTENSION_DIR="$(cd "$(dirname "$0")" && pwd)"

# Change to the script directory
cd "$EXTENSION_DIR" || exit

# Create a safe version of EXTENSION_ID replacing dots with dashes
EXTENSION_ID_SAFE="${EXTENSION_ID//./-}"

# Define output directory
OUTPUT_DIR="${OUTPUT_DIR:-$EXTENSION_DIR/bin}"

# Create output and target directories if they don't exist
mkdir -p "$OUTPUT_DIR"

# Get Git commit hash and build date
COMMIT=$(git rev-parse HEAD)
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)

# List of OS and architecture combinations
if [ -n "$EXTENSION_PLATFORM" ]; then
PLATFORMS=("$EXTENSION_PLATFORM")
else
PLATFORMS=(
"windows/amd64"
"windows/arm64"
"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/arm64"
)
fi

APP_PATH="$EXTENSION_ID/internal/cmd"

# Loop through platforms and build
for PLATFORM in "${PLATFORMS[@]}"; do
OS=$(echo "$PLATFORM" | cut -d'/' -f1)
ARCH=$(echo "$PLATFORM" | cut -d'/' -f2)

OUTPUT_NAME="$OUTPUT_DIR/$EXTENSION_ID_SAFE-$OS-$ARCH"

if [ "$OS" = "windows" ]; then
OUTPUT_NAME+='.exe'
fi

echo "Building for $OS/$ARCH..."

# Delete the output file if it already exists
[ -f "$OUTPUT_NAME" ] && rm -f "$OUTPUT_NAME"

# Set environment variables for Go build
GOOS=$OS GOARCH=$ARCH go build \
-ldflags="-X '$APP_PATH.Version=$EXTENSION_VERSION' -X '$APP_PATH.Commit=$COMMIT' -X '$APP_PATH.BuildDate=$BUILD_DATE'" \
-o "$OUTPUT_NAME"

if [ $? -ne 0 ]; then
echo "An error occurred while building for $OS/$ARCH"
exit 1
fi
done

echo "Build completed successfully!"
echo "Binaries are located in the $OUTPUT_DIR directory."
4 changes: 4 additions & 0 deletions cli/azd/extensions/azure.ai.rle/cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import: ../../.vscode/cspell.yaml
words:
- RLE
- azdai
24 changes: 24 additions & 0 deletions cli/azd/extensions/azure.ai.rle/extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/refs/heads/main/cli/azd/extensions/extension.schema.json
capabilities:
- custom-commands
- metadata
description: Manage RLE resources from your terminal. (Preview)
displayName: RLE (Preview)
id: azure.ai.rle
language: go
namespace: ai.rle
tags:
- ai
- rle
usage: azd ai rle <command> [options]
version: 0.1.0-preview
examples:
- name: init
description: Scaffold a local RLE environment.
usage: azd ai rle init code_rl
- name: deploy
description: Create or update the RLE environment.
usage: azd ai rle deploy
- name: invoke
description: Run the Loom RLE training recipe.
usage: azd ai rle invoke --recipe code_rl_with_rle
Loading
Loading