Add checks for empty normalized tensors in LossCalculator and SampleL… #235
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - Continuous Integration | |
| on: | |
| push: | |
| branches: [develop-CLEVER-relations, main] | |
| pull_request: | |
| branches: [develop-CLEVER-relations, main] | |
| workflow_dispatch: | |
| # Prevent multiple runs of the same branch overlapping | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| env: | |
| DEBUG_MODE: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.base_ref == 'main') && 'false' || 'true' }} | |
| jobs: | |
| test-cpu: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: { python-version: "3.13" } | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Resolve & install | |
| run: | | |
| uv sync --extra cpu --extra dev | |
| - name: Verify torch installation | |
| run: | | |
| .venv/bin/python -c "import torch; print(f'PyTorch version: {torch.__version__}')" | |
| .venv/bin/pip show torch | grep -E "Name|Version|Location" | |
| - name: Install spaCy model | |
| run: | | |
| .venv/bin/python -m spacy download en_core_web_sm | |
| .venv/bin/python -m spacy download en_core_web_lg | |
| .venv/bin/python -m spacy validate || true | |
| - name: set USE_SUBPROCESS true | |
| run: | | |
| echo "USE_SUBPROCESS=true" >> $GITHUB_ENV | |
| # --- Quality gate: formatting & types (only in debug mode) --- | |
| - name: Check formatting (black) | |
| if: env.DEBUG_MODE == 'true' | |
| continue-on-error: true | |
| run: uv run --no-sync black --check . | |
| - name: Check imports (isort) | |
| if: env.DEBUG_MODE == 'true' | |
| continue-on-error: true | |
| run: uv run --no-sync isort --profile black --check-only . | |
| - name: Type check (mypy) | |
| if: env.DEBUG_MODE == 'true' | |
| continue-on-error: true | |
| run: | | |
| set +e | |
| uv run --no-sync mypy --install-types --non-interactive . | |
| # --- Run CPU tests --- | |
| - name: Run CPU tests | |
| run: | | |
| TEST_LIST=( | |
| 'InferenceAPI' | |
| 'dummy_datanode' | |
| 'examples/conll04' | |
| 'examples/edges' | |
| 'examples/graph_city' | |
| 'examples/graph_coloring' | |
| 'examples/logical_all' | |
| 'examples/mnist-arithmetic' | |
| 'examples/nested_relations' | |
| 'examples/orbs' | |
| 'examples/test_switch_constraints' | |
| 'examples/equality' | |
| 'graph_errors' | |
| 'sensor/pytorch' | |
| 'simple_regression' | |
| 'solver' | |
| 'namedTree' | |
| 'examples/iota' | |
| 'Clever', | |
| 'vizual' | |
| ) | |
| bash .github/scripts/run_tests.sh "test-cpu" "${TEST_LIST[@]}" | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-cpu | |
| path: | | |
| /tmp/test_results_test-cpu.txt | |
| /tmp/test_failures_test-cpu.txt | |
| retention-days: 1 | |
| test-gpu: | |
| runs-on: [self-hosted, linux, x64, gpu] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: { python-version: "3.13" } | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Resolve & install | |
| run: | | |
| uv sync --extra cpu --extra dev | |
| - name: Install spaCy model | |
| run: | | |
| .venv/bin/python -m spacy download en_core_web_sm | |
| .venv/bin/python -m spacy download en_core_web_lg | |
| .venv/bin/python -m spacy validate || true | |
| - name: set USE_SUBPROCESS true | |
| run: | | |
| echo "USE_SUBPROCESS=true" >> $GITHUB_ENV | |
| # --- Quality gate: formatting & types (only in debug mode) --- | |
| - name: Check formatting (black) | |
| if: env.DEBUG_MODE == 'true' | |
| continue-on-error: true | |
| run: uv run --no-sync black --check . | |
| - name: Check imports (isort) | |
| if: env.DEBUG_MODE == 'true' | |
| continue-on-error: true | |
| run: uv run --no-sync isort --profile black --check-only . | |
| - name: Type check (mypy) | |
| if: env.DEBUG_MODE == 'true' | |
| continue-on-error: true | |
| run: | | |
| set +e | |
| uv run --no-sync mypy --install-types --non-interactive . | |
| # --- Run GPU tests --- | |
| - name: Run GPU tests | |
| run: | | |
| TEST_LIST=( | |
| 'examples/PMDExistL/pmd_counting_tests' | |
| 'examples/PMDExistL/relation_learning_tests' | |
| ) | |
| # Note: ConllQA test is temporarily disabled | |
| bash .github/scripts/run_tests.sh "test-gpu" "${TEST_LIST[@]}" | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-gpu | |
| path: | | |
| /tmp/test_results_test-gpu.txt | |
| /tmp/test_failures_test-gpu.txt | |
| retention-days: 1 | |
| generate-requirements: | |
| runs-on: ubuntu-latest | |
| needs: [test-cpu, test-gpu] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip ci]') | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.BOT_PAT }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Generate requirements.txt (CPU) | |
| run: | | |
| uv export --extra cpu --no-hashes --no-dev -o requirements.txt | |
| - name: Generate requirements-dev.txt (CPU) | |
| run: | | |
| uv export --extra cpu --extra dev --no-hashes -o requirements-dev.txt | |
| - name: Generate requirements-cu128.txt (CUDA 12.8) | |
| run: | | |
| uv export --extra cu128 --no-hashes --no-dev -o requirements-cu128.txt | |
| - name: Generate requirements-cu128-dev.txt (CUDA 12.8) | |
| run: | | |
| uv export --extra cu128 --extra dev --no-hashes -o requirements-cu128-dev.txt | |
| - name: Generate requirements-cu126.txt (CUDA 12.6) | |
| run: | | |
| uv export --extra cu126 --no-hashes --no-dev -o requirements-cu126.txt | |
| - name: Generate requirements-cu126-dev.txt (CUDA 12.6) | |
| run: | | |
| uv export --extra cu126 --extra dev --no-hashes -o requirements-cu126-dev.txt | |
| - name: Commit and push if changed | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add requirements*.txt | |
| if git diff --staged --quiet; then | |
| echo "No changes to requirements files" | |
| else | |
| git commit -m "chore: update requirements files [skip ci]" | |
| git push | |
| fi | |
| report: | |
| runs-on: ubuntu-latest | |
| needs: [test-cpu, test-gpu] | |
| if: always() | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all test results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: test-results | |
| - name: Generate combined report | |
| run: | | |
| bash .github/scripts/generate_report.sh test-results "${{ env.DEBUG_MODE }}" |