Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/assets-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
pull_request:
branches:
- main
types:
- opened
- labeled
- unlabeled
- synchronize
- reopened
workflow_dispatch:
inputs:
asset_dirs:
Expand Down Expand Up @@ -71,10 +77,17 @@ jobs:
run: pip install -e $scripts_azureml_assets_dir

- name: Validate assets
id: validate_assets
run: python -u $scripts_assets_dir/validate_assets.py -i "${{ github.event.inputs.asset_dirs || env.default_asset_dirs }}" -a $asset_config_filename -c "${{ needs.check-directory-file-changes.outputs.files-changed }}" -n -I -C -b -t -e
env:
SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Check PR labels for "mlflow noncompliant exception" label if MLFlow model was detected
if: fromJSON(steps.validate_assets.outputs.mlflow_model_detected || 'false') && !contains(github.event.pull_request.labels.*.name, 'mlflow noncompliant exception')
run: |
echo "::error::This PR contains an MLFlow model which is banned from the model catalog. Please reach out to System Registry Content team if you have any questions."
exit 1

- name: Validate source tree
run: python -u $scripts_assets_dir/validate_tree.py -i "${{ github.event.inputs.asset_dirs || env.default_asset_dirs }}"

Expand Down
4 changes: 4 additions & 0 deletions scripts/azureml-assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 1.17.0 (Unreleased)
### 🚀 New Features

## 1.16.84 (2025-05-29)
### 🚀 New Features
- [#4207](https://github.com/Azure/azureml-assets/pull/4207) Detect if MLFlow model was updated

## 1.16.83 (2025-05-22)
### 🚀 New Features
- [#4208](https://github.com/Azure/azureml-assets/pull/4208) Fix for python 3.9 - remove union typing
Expand Down
30 changes: 30 additions & 0 deletions scripts/azureml-assets/azureml/assets/validate_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,32 @@ def validate_model_spec(asset_config: assets.AssetConfig) -> int:
return error_count


def validate_mlflow_model(asset_config: assets.AssetConfig) -> int:
"""Validate if model is of type MLFlow.

Args:
asset_config (assets.AssetConfig): asset config for model spec
"""
model_config = None

try:
load_model(asset_config.spec_with_path)
model_config: assets.ModelConfig = asset_config.extra_config_as_object()
except Exception:
logger.log_warning("Could not validate if model is of type MLFlow due to invalid spec or model config")
return

if model_config.type == assets.config.ModelType.MLFLOW:
logger.log_warning(f"{asset_config.name} is a model of type {model_config.type.value} "
f"which is banned from the model catalog")

# Update mlflow_model_detected variable for Github Actions only
if "GITHUB_OUTPUT" in os.environ:
logger.print("Setting GITHUB_OUTPUT env variable for mlflow_model_detected=true")
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print("mlflow_model_detected=true", file=f)


def get_validated_models_assets_map(model_validation_results_dir: str):
"""Return model assets map."""
try:
Expand Down Expand Up @@ -1083,6 +1109,10 @@ def validate_assets(input_dirs: List[Path],
if check_tests:
error_count += validate_tests(asset_config)

# Validate if MLFlow model
if asset_config.type == assets.AssetType.MODEL:
validate_mlflow_model(asset_config)

if asset_config.type == assets.AssetType.ENVIRONMENT:
# Validate Dockerfile
error_count += validate_dockerfile(asset_config.extra_config_as_object())
Expand Down
2 changes: 1 addition & 1 deletion scripts/azureml-assets/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="azureml-assets",
version="1.16.83",
version="1.16.84",
description="Utilities for publishing assets to Azure Machine Learning system registries.",
author="Microsoft Corp",
packages=find_packages(),
Expand Down
Loading