Skip to content

Commit

Permalink
Merge branch 'main' into athitten/inference_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
athitten authored Feb 3, 2025
2 parents ad2cbcb + 2f035d3 commit b9b5c61
Show file tree
Hide file tree
Showing 39 changed files with 1,907 additions and 438 deletions.
8 changes: 8 additions & 0 deletions .flake8.other
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
select =
F541, # f-string without any placeholders
F841, # local variable 'x' is assigned to but never used
F401, # 'x' imported but unused
E741, # ambiguous variable name 'l'
F821, # undefined name 'x'
E266, # too many leading '#' for block comment
8 changes: 8 additions & 0 deletions .flake8.speech
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
select =
F541, # f-string without any placeholders
F841, # local variable 'x' is assigned to but never used
F401, # 'x' imported but unused
E741, # ambiguous variable name 'l'
F821, # undefined name 'x'
E266, # too many leading '#' for block comment
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.github/ @pablo-garay @ko3n1g @thomasdhc @chtruong814
Dockerfile.ci @pablo-garay @ko3n1g @thomasdhc @chtruong814
.pylintrc.* @pablo-garay @ko3n1g @thomasdhc @chtruong814
.flake8.* @pablo-garay @ko3n1g @thomasdhc @chtruong814
7 changes: 5 additions & 2 deletions .github/workflows/_test_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ jobs:
echo "coverage_report=$coverage_report" >> "$GITHUB_OUTPUT"
docker exec nemo_container_${{ github.run_id }} bash -c 'ls -al'
docker cp nemo_container_${{ github.run_id }}:/workspace/.coverage .coverage
docker cp nemo_container_${{ github.run_id }}:/workspace/coverage.xml coverage.xml
docker cp nemo_container_${{ github.run_id }}:/workspace/.coverage .coverage
exit $EXIT_CODE
Expand All @@ -117,7 +118,9 @@ jobs:
if: inputs.SAVE_COVERAGE_REPORT == true
with:
name: ${{ steps.main.outputs.coverage_report }}
path: ${{ github.run_id }}/.coverage
path: |
${{ github.run_id }}/coverage.xml
${{ github.run_id }}/.coverage
include-hidden-files: true

- uses: "NVIDIA/NeMo/.github/actions/cancel-workflow@main"
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/build-test-publish-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@ defaults:

jobs:
build-test-publish-wheel:
uses: NVIDIA/NeMo-FW-CI-templates/.github/workflows/_build_test_publish_wheel.yml@v0.7.0
uses: NVIDIA/NeMo-FW-CI-templates/.github/workflows/_build_test_publish_wheel.yml@v0.20.0
with:
image-name: nemo_container
dockerfile: Dockerfile.ci
image-label: nemo-core
build-args: |
IMAGE_LABEL=nemo-core
prune-filter-timerange: 24h
dry-run: true
python-package: nemo
container-workdir: /workspace
python-version: '3.10'
environment: public
secrets:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
Expand Down
562 changes: 335 additions & 227 deletions .github/workflows/cicd-main.yml

Large diffs are not rendered by default.

144 changes: 1 addition & 143 deletions .github/workflows/code-formatting.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Isort and Black Formatting; PyLint Docs check
name: Isort and Black Formatting
# Incrementally reformat only changed files with black, all files with isort
#
# Replaces pre-commit.ci, since it reformats all the files.
Expand Down Expand Up @@ -71,145 +71,3 @@ jobs:
with:
message: Apply isort and black reformatting
commit: --signoff

check_pylint:
name: "check_pylint (strict-mode: ${{ matrix.strict-mode }})"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
THRESHOLD: 1730937600 # On this date (2024/11/07) we decided to add Pylint. It shall only run in strict mode for files added past this date. For files prior to this date, we will only add a PR comment with PyLint's stdout.
strategy:
matrix:
strict-mode: ["true", "false"]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
# setup repository and ref for PRs, see
# https://github.com/EndBug/add-and-commit?tab=readme-ov-file#working-with-prs
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

# https://github.com/tj-actions/changed-files
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**.py
- name: Setup Python env
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: pylint
if: ${{ steps.changed-files.outputs.any_changed == 'true' && !contains( github.event.pull_request.labels.*.name, 'skip-docs') }}
id: pylint
env:
# only *.py files included
STRICT_MODE: ${{ matrix.strict-mode }}
CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}"
run: |
pip install pylint
FILTERED=()
for file in $CHANGED_FILES; do
DATE=$(git log --format=%ad --date=unix "$file" | tail -1)
if [[ "$STRICT_MODE" == "true" ]]; then
if [[ "$DATE" -gt "$THRESHOLD" ]]; then
FILTERED+=("$file")
fi
else
if [[ "$DATE" -le "$THRESHOLD" ]]; then
FILTERED+=("$file")
fi
fi
done
if [ ${#FILTERED[@]} -eq 0 ]; then
echo "No files to check."
exit 0
fi
echo "Will run on these files:
${FILTERED[@]}"
set +e
LOG=$(pylint ${FILTERED[@]})
EXIT_CODE=$?
set -e
set +x
echo "OUTPUT<<EOF" >> $GITHUB_ENV
echo "$LOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "log=$LOG"
set -x
echo "exit-code=$EXIT_CODE" | tee -a "$GITHUB_OUTPUT"
if [[ "${{ matrix.strict-mode }}" == "true" ]]; then
HEADER="🚨 The following files must be fixed before merge!"
else
HEADER="🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base."
fi
echo "header=$HEADER" | tee -a "$GITHUB_OUTPUT"
exit $([[ "$EXIT_CODE" -ne 0 && "$STRICT_MODE" == "true" ]] && echo $EXIT_CODE || echo 0)
- name: Find Comment
if: ${{ always() }}
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: <!-- pylint-output-strict-mode-${{ matrix.strict-mode }} -->

- name: Delete comment
if: ${{ always() && steps.fc.outputs.comment-id != '' }}
env:
GH_TOKEN: ${{ secrets.github_token }}
REPOSITORY: ${{ github.repository }}
COMMENT_ID: ${{ steps.fc.outputs.comment-id }}
run: |
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPOSITORY/issues/comments/$COMMENT_ID
- name: Add PR comment for PyLint
if: ${{ always() && steps.pylint.outputs.exit-code != '0' }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.number }}
body: |
<!-- pylint-output-strict-mode-${{ matrix.strict-mode }} -->
beep boop 🤖: ${{ steps.pylint.outputs.header }}
---
Your code was analyzed with PyLint. The following annotations have been identified:
```
${{ env.OUTPUT }}
```
---
Mitigation guide:
* Add sensible and useful docstrings to functions and methods
* For trivial methods like getter/setters, consider adding `# pylint: disable=C0116` inside the function itself
* To disable multiple functions/methods at once, put a `# pylint: disable=C0116` before the first and a `# pylint: enable=C0116` after the last.
By applying these rules, we reduce the occurance of this message in future.
Thank you for improving NeMo's documentation!
137 changes: 137 additions & 0 deletions .github/workflows/code-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: PyLint and flake8 linting

on:
pull_request:
paths:
- '**.py'
types: [ opened, synchronize, reopened, labeled, unlabeled ]

jobs:
linting:
name: 'Domain: ${{ matrix.domain }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
domain: [speech, other]
env:
DOMAIN: ${{ matrix.domain }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Select filter
id: filter
run: |
if [[ "$DOMAIN" == "speech" ]]; then
FILTER=$(jq -crn '[
"nemo/collections/asr/**",
"nemo/collections/tts/**",
"nemo/collections/audio/**",
"nemo/collections/multimodal/speech_llm/**",
"nemo/collections/speechlm/**"
] | join(",")')
else
FILTER=$(jq -crn '[
"nemo/**",
"!nemo/collections/asr/**",
"!nemo/collections/tts/**",
"!nemo/collections/audio/**",
"!nemo/collections/multimodal/speech_llm/**",
"!nemo/collections/speechlm/**"
] | join(",")')
fi
echo "main=$FILTER" | tee -a "$GITHUB_OUTPUT"
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: ${{ steps.filter.outputs.main }}
files_separator: ","
separator: " "

- name: Run PyLint
id: pylint
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
if [[ -z "$CHANGED_FILES" ]]; then
echo Nothing to lint.
echo "exit-code=0" | tee -a "$GITHUB_OUTPUT"
exit 0
fi
pip install pylint
set +e
pylint --output "pylintrc.$DOMAIN.txt" --rcfile ".pylintrc.$DOMAIN" ${CHANGED_FILES[@]}
echo "exit-code=$?" | tee -a "$GITHUB_OUTPUT"
- name: Run flake8
id: flake8
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
if [[ -z "$CHANGED_FILES" ]]; then
echo Nothing to lint.
echo "exit-code=0" | tee -a "$GITHUB_OUTPUT"
exit 0
fi
pip install flake8
set +e
flake8 --output "flake8.$DOMAIN.txt" --config ".flake8.$DOMAIN" ${CHANGED_FILES[@]}
echo "exit-code=$?" | tee -a "$GITHUB_OUTPUT"
- name: Summary
env:
PYLINT: ${{ steps.pylint.outputs.exit-code == 0 }}
FLAKE8: ${{ steps.flake8.outputs.exit-code == 0 }}
run: |
if [[ "$PYLINT" != "true" ]]; then
echo "Pylint output:" | tee -a $GITHUB_STEP_SUMMARY
echo '```' | tee -a $GITHUB_STEP_SUMMARY
cat pylintrc.$DOMAIN.txt | tee -a $GITHUB_STEP_SUMMARY
echo '```' | tee -a $GITHUB_STEP_SUMMARY
fi
if [[ "$FLAKE8" != "true" ]]; then
echo "Flake8 output:" | tee -a $GITHUB_STEP_SUMMARY
echo '```' | tee -a $GITHUB_STEP_SUMMARY
cat flake8.$DOMAIN.txt | tee -a $GITHUB_STEP_SUMMARY
echo '```' | tee -a $GITHUB_STEP_SUMMARY
fi
if [[ "$PYLINT" != "true" || "$FLAKE8" != "true" ]]; then
echo "The following directories got scanned:" | tee -a $GITHUB_STEP_SUMMARY
echo '```' | tee -a $GITHUB_STEP_SUMMARY
echo ${{ steps.filter.outputs.main }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' | tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
Nemo_Linting_Test:
needs: linting
runs-on: ubuntu-latest
if: always()
steps:
- name: Main
env:
RESULTS: ${{ toJson(needs.linting) }}
run: |
RESULT=$(echo "$RESULTS" | jq -r '.result')
if [[ "$RESULT" == "success" ]]; then
echo "All passed."
exit 0
else
echo "Some linting domains failed."
exit 1
fi
9 changes: 5 additions & 4 deletions .github/workflows/monitor-vms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ on:
schedule:
- cron: 0/15 * * * *
workflow_dispatch:

jobs:
pre-flight:
runs-on: ubuntu-latest
if: github.repository_owner == 'NVIDIA'
outputs:
list-of-vms: ${{ steps.main.outputs.main }}
environment: main
Expand All @@ -25,13 +26,13 @@ jobs:
MATRIX=$(echo $RUNNERS \
| jq -c '[
.runners[]
.runners[]
| select(.status == "online")
| select(.name | contains("cpu") | not)
| {
"vm": .name,
"vm": .name,
"n_gpus": [
.labels[]
.labels[]
| select(.name | endswith("gpu")) | .name
][0][:1]
}
Expand Down
Loading

0 comments on commit b9b5c61

Please sign in to comment.