Skip to content

Commit 51c5aa1

Browse files
authored
Data flow graph public preview (#136)
# Azure IoT Operations Data Flow Graphs: WASM Development (Public Preview) ## Overview This PR introduces **Azure IoT Operations Data Flow Graphs** - a powerful new capability for real-time data processing using WebAssembly (WASM) modules. This public preview enables developers to build custom data processing pipelines using Rust and Python, with support for complex workflows including branching, filtering, aggregation, and machine learning inference. ## 🚀 Key Features ### **Multi-Language WASM Development** - **Rust SDK**: Full-featured SDK with procedural macros, logging, metrics, and state store APIs - **Python Support**: componentize-py integration with generated bindings - **Docker Builders**: Streamlined containerized build environments for both languages - **Local Development**: Complete toolchain support for native development workflows ### **Rich Operator Types** - **Map**: Transform data (unit conversion, format changes) - **Filter**: Conditional data filtering based on predicates - **Branch**: Route data to different paths based on conditions - **Accumulate**: Time-windowed aggregation and statistics - **Delay**: Control timing and batch processing - **Source/Sink**: Integration with external systems ### **Production-Ready Architecture** - **Timely Dataflow**: Built on Microsoft Research's proven computational model - **Event-Time Semantics**: Process data based on when events occurred - **Hybrid Logical Clock**: Ensures causal ordering and progress guarantees - **Fault Tolerance**: Built-in support for handling failures and ensuring data consistency ## 📁 What's Included ### **Sample Applications** - graph-simple.yaml - Basic temperature conversion pipeline - `graph-complex.yaml` - Multi-sensor processing with ML inference - **10+ Rust Examples**: Temperature, humidity, image processing, data enrichment - **Python Examples**: Map, filter, branch operators with complete implementations ### **Development Tools** - **Docker Builders**: - `ghcr.io/azure-samples/explore-iot-operations/rust-wasm-builder` - `ghcr.io/azure-samples/explore-iot-operations/python-wasm-builder` - **GitHub Actions**: Automated builder image publishing - **WIT Schema**: Complete WebAssembly Interface Type definitions ### **Sample Data & Assets** - Temperature and humidity sensor payloads - Sample images for computer vision workflows - Pre-trained ONNX models (MobileNet, SqueezeNet) ## 🔧 Technical Highlights ### **Rust Development** ```rust #[map_operator(init = "temperature_converter_init")] fn temperature_converter(input: DataModel) -> DataModel { // Transform Fahrenheit to Celsius with full type safety } ``` ### **Python Development** ```python class Map(exports.Map): def process(self, message: types.DataModel) -> types.DataModel: # Process data with generated type bindings ``` ### **Graph Configuration** ```yaml operations: - operationType: "map" name: "temperature/map" module: "temperature:1.0.0" ``` ## 🛠️ Build & Deploy **Docker Builds (Recommended)**: ```bash # Rust docker run --rm -v "$(pwd):/workspace" ghcr.io/azure-samples/explore-iot-operations/rust-wasm-builder --app-name my-module # Python docker run --rm -v "$(pwd):/workspace" ghcr.io/azure-samples/explore-iot-operations/python-wasm-builder --app-name my_module --app-type map ``` **Local Development**: Full support for native Rust/Python toolchains with registry configuration ## 📊 Impact - **81 files changed, 10,835 insertions**: Comprehensive feature implementation - **Production-ready**: Based on proven academic research and production systems - **Developer-friendly**: Multiple language support with excellent tooling - **Scalable**: Distributed processing with automatic coordination ## 🔗 Integration This feature integrates with: - **Azure IoT Operations**: Native deployment and management - **Azure Container Registry**: WASM module and graph storage - **Kubernetes**: Arc-enabled cluster deployment - **ORAS**: OCI artifact distribution ## 📚 Documentation - Comprehensive README with quick start guide - Complete Rust and Python development guides - Docker builder documentation - Sample workflows and deployment instructions ## ✅ Testing - All Docker builders tested and validated - GitHub Actions workflows for automated publishing - Sample modules verified with both build methods - End-to-end validation completed
1 parent 19a3793 commit 51c5aa1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+10835
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and Publish WASM Python Builder Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main, wasm ]
7+
paths:
8+
- 'samples/wasm/python/Dockerfile'
9+
- 'samples/wasm/python/schema/**'
10+
- 'samples/wasm/python/inject_pdb.py'
11+
pull_request:
12+
branches: [ main ]
13+
paths:
14+
- 'samples/wasm/python/Dockerfile'
15+
- 'samples/wasm/python/schema/**'
16+
- 'samples/wasm/python/inject_pdb.py'
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata for Docker
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ghcr.io/azure-samples/explore-iot-operations/python-wasm-builder
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=pr
47+
type=raw,value=latest
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: samples/wasm/python
53+
file: samples/wasm/python/Dockerfile
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
platforms: linux/amd64,linux/arm64
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Push WASM Rust Builder Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main, wasm ]
7+
paths:
8+
- 'samples/wasm/rust/Dockerfile'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- 'samples/wasm/rust/Dockerfile'
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
defaults:
21+
run:
22+
shell: bash
23+
steps:
24+
- name: "Checkout GitHub Action"
25+
uses: actions/checkout@main
26+
27+
- name: "Login to GitHub Container Registry"
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{github.actor}}
32+
password: ${{secrets.GITHUB_TOKEN}}
33+
34+
- name: Extract metadata
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: ghcr.io/azure-samples/explore-iot-operations/rust-wasm-builder
39+
tags: |
40+
type=ref,event=branch
41+
type=ref,event=pr
42+
type=sha
43+
type=raw,value=latest
44+
45+
- name: "Build and Push Rust Builder Image"
46+
uses: docker/build-push-action@v5
47+
with:
48+
context: samples/wasm/rust
49+
file: samples/wasm/rust/Dockerfile
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

docker/wasm-rust-build/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG RUST_VERSION=1.85
2+
FROM rust:${RUST_VERSION}-alpine
3+
4+
ARG ARCH="x86_64"
5+
6+
RUN apk add --no-cache clang lld musl-dev git perl make cmake
7+
RUN rustup target add wasm32-wasip2 ${ARCH}-unknown-linux-gnu
8+
9+
# Set up environment for Cargo registry
10+
ENV CARGO_REGISTRIES_AZURE_VSCODE_TINYKUBE_INDEX="sparse+https://pkgs.dev.azure.com/azure-iot-sdks/iot-operations/_packaging/preview/Cargo/index/"
11+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
12+
13+
WORKDIR /src

docker/wasm-rust-build/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# WASM Rust Build Base Image
2+
3+
This Docker image provides a base environment for building WebAssembly (WASM) applications with Rust targeting the `wasm32-wasip2` platform.
4+
5+
## Features
6+
7+
- Based on Alpine Linux with Rust 1.85
8+
- Pre-configured for WASM compilation with `wasm32-wasip2` target
9+
- Required build tools: clang, lld, musl-dev, git, perl, make, cmake
10+
- Environment variables for Azure IoT Operations Cargo registry
11+
12+
## Usage
13+
14+
This base image is intended to be used as a build stage in multi-stage Docker builds for WASM operators:
15+
16+
```dockerfile
17+
ARG IMAGE=ghcr.io/azure-samples/explore-iot-operations/wasm-rust-build:latest
18+
FROM $IMAGE AS operator-build
19+
20+
ARG APP_NAME
21+
ARG BUILD_MODE="release"
22+
23+
WORKDIR /src
24+
COPY ./Cargo.toml ./Cargo.toml
25+
COPY ./src ./src
26+
27+
RUN if [ "${BUILD_MODE}" = "release" ]; then \
28+
cargo build --release --target wasm32-wasip2; \
29+
else \
30+
cargo build --target wasm32-wasip2; \
31+
fi
32+
33+
FROM scratch
34+
ARG BUILD_MODE
35+
ARG APP_NAME
36+
COPY --from=operator-build "/src/target/wasm32-wasip2/${BUILD_MODE}/${APP_NAME}.wasm" "${APP_NAME}.wasm"
37+
ENTRYPOINT [ "${APP_NAME}.wasm" ]
38+
```
39+
40+
## Build Arguments
41+
42+
- `RUST_VERSION`: Rust version to use (default: 1.85)
43+
- `ARCH`: Target architecture (default: x86_64)
44+
45+
## Environment Variables
46+
47+
- `CARGO_REGISTRIES_AZURE_VSCODE_TINYKUBE_INDEX`: Azure IoT Operations Cargo registry URL
48+
- `CARGO_NET_GIT_FETCH_WITH_CLI`: Use Git CLI for fetching dependencies
49+
50+
## Publishing
51+
52+
This image is automatically built and published to GitHub Container Registry via GitHub Actions when changes are made to the `docker/wasm-rust-build/` directory.

0 commit comments

Comments
 (0)