Skip to content

Commit

Permalink
Merge pull request #328 from arjunsuresh/patch-7
Browse files Browse the repository at this point in the history
Removed a misleading warning in server.py and added a github action for automatic black formatting
  • Loading branch information
araghun authored Dec 17, 2024
2 parents d1deb7b + a0dcb24 commit c7bdb2f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Automatic code formatting
name: "Code formatting"
on:
push:
branches:
- "**"

env:
python_version: "3.9"

jobs:
format-code:
runs-on: ubuntu-latest
if: ${{ github.repository_owner != 'mlcommons' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v3
with:
python-version: ${{ env.python_version }}

- name: Format modified python files
run: |
python3 -m pip install black
for FILE in $(git diff --name-only ${{ github.event.before }} | grep -E '.*\.py$')
do
black $FILE
git add $FILE
done
- name: Commit and Push
run: |
HAS_CHANGES=$(git diff --staged --name-only)
if [ -n "$HAS_CHANGES" ]; then
git config --global user.name mlcommons-bot
git config --global user.email "[email protected]"
# Commit changes
git commit -m '[Automated Commit] Format Codebase'
git push
# Push changes to a new branch
#BRANCH_NAME="auto/code-format"
#git branch $BRANCH_NAME
#git push origin $BRANCH_NAME --force

# Create a pull request to the "code-format" branch
#gh pr create --base code-format --head $BRANCH_NAME --title "[Automated PR] Format Codebase" --body "This pull request contains automated code formatting changes."
fi
# env:
# GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
7 changes: 6 additions & 1 deletion ptd_client_server/lib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,12 @@ def get(
f"{', '.join(unused_options)}"
)

unused_sections = set(conf.sections()) - {"server", "ptd"}
unused_sections = (
set(conf.sections())
- {"server", "ptd"}
- set([i for i in conf.sections() if i.startswith("analyzer")])
)

if len(unused_sections) != 0:
logging.warning(
f"{filename}: ignoring unknown sections: {', '.join(unused_sections)}"
Expand Down

0 comments on commit c7bdb2f

Please sign in to comment.