name: Playground Integration Tests (Isolated Steps)

on:
  workflow_dispatch:
    inputs:
      test_step:
        description: 'Which step to test'
        required: false
        default: 'all'
        type: choice
        options:
          - all
          - credentials
          - data_loading
          - preprocessing
          - model_training
          - create_submit_getleaderboard
          - model_types
          - keras_model_types
          - torch_model_types
          - compas_multiframework
          - compas_short
          - justice_equity_challenge
          - region_aware_naming
      install_source:
        description: 'Install aimodelshare from repo (editable) or PyPI'
        required: false
        default: 'repo'
        type: choice
        options:
          - repo
          - pypi
      pypi_version:
        description: 'Optional: specify a PyPI version (e.g. 0.6.3). Leave blank for latest.'
        required: false
        default: ''

permissions:
  contents: read

concurrency:
  group: playground-integration-tests
  cancel-in-progress: true

jobs:
  test-credentials:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'credentials' }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    env:
      USERNAME: ${{ secrets.AIMODELSHARE_USERNAME }}
      PASSWORD: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test credential configuration only
        run: |
          pytest -vv tests/test_playgrounds_nodataimport.py::test_configure_credentials --tb=long

  test-data-loading:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'data_loading' }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test data loading from seaborn
        run: |
          python -c "
          import seaborn as sns
          penguins = sns.load_dataset('penguins')
          penguins_clean = penguins.dropna()
          assert 'sex' in penguins_clean.columns
          assert 'bill_length_mm' in penguins_clean.columns
          print('✓ Data loading test passed')
          "

  test-preprocessing:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'preprocessing' }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test data preprocessing
        run: |
          python -c "
          import seaborn as sns
          from sklearn.compose import ColumnTransformer
          from sklearn.pipeline import Pipeline
          from sklearn.preprocessing import StandardScaler
          from sklearn.model_selection import train_test_split
          penguins = sns.load_dataset('penguins').dropna()
          X = penguins[['bill_length_mm','bill_depth_mm','flipper_length_mm','body_mass_g']]
          y = penguins['sex']
          X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2,random_state=42)
          preprocess = ColumnTransformer([('num', Pipeline([('scaler', StandardScaler())]), X.columns.tolist())])
          preprocess.fit(X_train)
          def preprocessor(d): return preprocess.transform(d)
          assert preprocessor(X_train).shape[0] == X_train.shape[0]
          print('✓ Preprocessing test passed')
          "

  test-model-training:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'model_training' }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test model training
        run: |
          python -c "
          import seaborn as sns
          from sklearn.compose import ColumnTransformer
          from sklearn.pipeline import Pipeline
          from sklearn.preprocessing import StandardScaler
          from sklearn.linear_model import LogisticRegression
          from sklearn.model_selection import train_test_split
          penguins = sns.load_dataset('penguins').dropna()
          X = penguins[['bill_length_mm','bill_depth_mm','flipper_length_mm','body_mass_g']]
          y = penguins['sex']
          X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2,random_state=42)
          preprocess = ColumnTransformer([('num', Pipeline([('scaler', StandardScaler())]), X.columns.tolist())])
          preprocess.fit(X_train)
          def preprocessor(d): return preprocess.transform(d)
          model = LogisticRegression()
          model.fit(preprocessor(X_train), y_train)
          preds = model.predict(preprocessor(X_test))
          print(f'Generated {len(preds)} predictions')
          print('✓ Model training test passed')
          "

  test-playground-create-submit-deploy-leaderboard:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'create_submit_getleaderboard' }}
    runs-on: ubuntu-latest
    timeout-minutes: 15
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      TF_CPP_MIN_LOG_LEVEL: "2"
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: "1"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test model submission + leaderboard retrieval
        run: |
          python -c "
          import os
          import seaborn as sns, pandas as pd
          from sklearn.compose import ColumnTransformer
          from sklearn.pipeline import Pipeline
          from sklearn.preprocessing import StandardScaler
          from sklearn.linear_model import LogisticRegression
          from sklearn.model_selection import train_test_split
          from aimodelshare.playground import ModelPlayground, Experiment, Competition
          from aimodelshare.aws import get_aws_token
          from aimodelshare.modeluser import get_jwt_token, create_user_getkeyandpassword
          import traceback, logging
          try:
            os.environ['AWS_TOKEN']=get_aws_token()
            os.environ['AWS_ACCESS_KEY_ID_AIMS']=os.environ.get('AWS_ACCESS_KEY_ID')
            os.environ['AWS_SECRET_ACCESS_KEY_AIMS']=os.environ.get('AWS_SECRET_ACCESS_KEY')
            os.environ['AWS_REGION_AIMS']=os.environ.get('AWS_REGION')
          except Exception:
            logging.error(traceback.format_exc())
          try:
            import boto3
            client = boto3.client('sts',
              aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID'),
              aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY'))
            client.get_caller_identity()
          except Exception:
            logging.error(traceback.format_exc())
          try:
            os.environ['AWS_TOKEN']=get_aws_token()
            get_jwt_token(os.environ.get('username'), os.environ.get('password'))
            create_user_getkeyandpassword()
          except Exception:
            logging.error(traceback.format_exc())
          penguins = sns.load_dataset('penguins').dropna()
          X = penguins[['bill_length_mm','bill_depth_mm','flipper_length_mm','body_mass_g']]
            y = penguins['sex']
          from sklearn.model_selection import train_test_split
          X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2,random_state=42)
          eval_labels = list(y_test)
          preprocess = ColumnTransformer([('num', Pipeline([('scaler', StandardScaler())]), X.columns.tolist())])
          preprocess.fit(X_train)
          def preprocessor(d): return preprocess.transform(d)
          from sklearn.linear_model import LogisticRegression
          model = LogisticRegression()
          model.fit(preprocessor(X_train), y_train)
          preds = model.predict(preprocessor(X_test))
          playground = ModelPlayground(input_type='tabular', task_type='classification', private=True)
          playground.create(eval_data=eval_labels, public=True)
          playground.submit_model(model=model,
                                  preprocessor=None,
                                  prediction_submission=preds,
                                  input_dict={'description':'CI test','tags':'integration'},
                                  submission_type='experiment')
          playground.submit_model(model=model,
                                  preprocessor=preprocessor,
                                  prediction_submission=preds,
                                  input_dict={'description':'CI test','tags':'integration'},
                                  submission_type='experiment')
          data = playground.get_leaderboard()
          if isinstance(data, dict):
            import pandas as pd
            df = pd.DataFrame(data)
            assert not df.empty, 'Leaderboard dict converted to empty DataFrame'
            print(df.head())
          else:
            import pandas as pd
            assert isinstance(data, pd.DataFrame), 'Leaderboard did not return a DataFrame'
            assert not data.empty, 'Leaderboard DataFrame is empty'
            print(data.head())
          print('✓ Leaderboard retrieval test passed')
          "

  test-playground-sklearn-model-types:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'model_types' }}
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      TF_CPP_MIN_LOG_LEVEL: "2"
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: "1"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test sklearn model types submission
        run: |
          pytest -vv tests/test_playground_model_types.py

  test-playground-keras-model-types:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'keras_model_types' }}
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      TF_CPP_MIN_LOG_LEVEL: "2"
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: "1"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test keras model types submission
        run: |
          pytest -vv tests/test_playground_keras_model_types.py

  test-playground-torch-model-types:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'torch_model_types' }}
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: "1"
      AIMS_NON_INTERACTIVE: "1"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test torch model types submission
        run: |
          pytest -vv tests/test_playground_torch_model_types.py

  test-playground-compas-multiframework:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'compas_multiframework' }}
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      TF_CPP_MIN_LOG_LEVEL: "2"
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: "1"
      AIMS_NON_INTERACTIVE: "1"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript requests
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test COMPAS multi-framework submission
        run: |
          pytest -vv -s tests/test_playground_compas_multiframework.py

  test-playground-compas-short:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'compas_short' }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      TF_CPP_MIN_LOG_LEVEL: "2"
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: "1"
      AIMS_NON_INTERACTIVE: "1"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript requests
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Test COMPAS short multi-framework submission
        run: |
          pytest -vv -s tests/test_playground_compas_multiframework_short.py

  test-playground-justice-equity-challenge:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'justice_equity_challenge' }}
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      username: ${{ secrets.AIMODELSHARE_USERNAME }}
      password: ${{ secrets.AIMODELSHARE_PASSWORD }}
      AWS_ACCESS_KEY_ID: ${{ secrets.DATA_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DATA_AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: us-east-1
      AIMODELSHARE_SUPPRESS_OPTIONAL_WARNINGS: '1'
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v3
        with:
          terraform_wrapper: false
      - name: Initialize Terraform and get API URL
        working-directory: infra
        run: |
          terraform init
          terraform workspace select dev || terraform workspace new dev
          set +e
          API_URL=$(terraform output -raw api_base_url 2>&1)
          TF_EXIT_CODE=$?
          set -e
          if [ $TF_EXIT_CODE -eq 0 ] && [ -n "$API_URL" ] && [ "$API_URL" != "null" ]; then
            echo "MORAL_COMPASS_API_BASE_URL=$API_URL" >> $GITHUB_ENV
            echo "✓ API base URL set: $API_URL"
          else
            echo "⚠ Could not retrieve API base URL from terraform outputs (exit code: $TF_EXIT_CODE)"
            echo "Test will be skipped if URL cannot be resolved"
          fi
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython 'PyJWT<2.0' matplotlib seaborn importlib_resources onnxscript requests
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Run Justice & Equity moral compass challenge integration test
        run: |
          pytest -vv -s tests/test_playground_moral_compass_challenge.py

  test-region-aware-naming:
    if: ${{ github.event.inputs.test_step == 'all' || github.event.inputs.test_step == 'region_aware_naming' }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    env:
      AWS_REGION: us-east-1
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies + aimodelshare
        run: |
          pip install boto3 onnx onnxmltools onnxruntime Pympler scikeras shortuuid skl2onnx tf2onnx wget
          if [ "${{ github.event.inputs.install_source }}" = "pypi" ]; then
            if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
              pip install "aimodelshare==${{ github.event.inputs.pypi_version }}"
            else
              pip install aimodelshare
            fi
          else
            pip install -e .
          fi
          pip install pytest scikit-learn pandas numpy opencv-python-headless tensorflow pydot regex psutil IPython "PyJWT<2.0" matplotlib seaborn importlib_resources onnxscript
          pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
      - name: Run region-aware naming tests
        run: |
          pytest -vv -s tests/test_region_aware_naming.py

  integration-summary:
    needs:
      - test-credentials
      - test-data-loading
      - test-preprocessing
      - test-model-training
      - test-playground-create-submit-deploy-leaderboard
      - test-playground-sklearn-model-types
      - test-playground-keras-model-types
      - test-playground-torch-model-types
      - test-playground-compas-multiframework
      - test-playground-compas-short
      - test-playground-justice-equity-challenge
      - test-region-aware-naming
    runs-on: ubuntu-latest
    if: always()
    steps:
      - name: Summary
        run: |
          echo "=== Integration Test Summary ==="
          echo "Install Source: ${{ github.event.inputs.install_source }}"
          if [ -n "${{ github.event.inputs.pypi_version }}" ]; then
            echo "PyPI Version: ${{ github.event.inputs.pypi_version }}"
          fi
          echo "Credentials: ${{ needs.test-credentials.result }}"
          echo "Data Loading: ${{ needs.test-data-loading.result }}"
          echo "Preprocessing: ${{ needs.test-preprocessing.result }}"
          echo "Model Training: ${{ needs.test-model-training.result }}"
          echo "Model Submission / Leaderboard: ${{ needs.test-playground-create-submit-deploy-leaderboard.result }}"
          echo "Sklearn Model Types: ${{ needs.test-playground-sklearn-model-types.result }}"
          echo "Keras Model Types: ${{ needs.test-playground-keras-model-types.result }}"
          echo "Torch Model Types: ${{ needs.test-playground-torch-model-types.result }}"
          echo "COMPAS Multi-Framework: ${{ needs.test-playground-compas-multiframework.result }}"
          echo "COMPAS Short: ${{ needs.test-playground-compas-short.result }}"
          echo "Justice & Equity Challenge: ${{ needs.test-playground-justice-equity-challenge.result }}"
          echo "Region-Aware Naming: ${{ needs.test-region-aware-naming.result }}"
