From 5aa4204ccd5854823c8825d85f16a78e081a7207 Mon Sep 17 00:00:00 2001 From: e-strauss Date: Wed, 30 Jul 2025 15:01:24 +0200 Subject: [PATCH 1/3] new Python CI test setup --- .github/workflows/javaTests.yml | 2 ++ .github/workflows/python.yml | 21 ++++-------- .github/workflows/pythonFormatting.yml | 47 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/pythonFormatting.yml diff --git a/.github/workflows/javaTests.yml b/.github/workflows/javaTests.yml index c11f00ed4fa..ba7da60c8e4 100644 --- a/.github/workflows/javaTests.yml +++ b/.github/workflows/javaTests.yml @@ -29,6 +29,7 @@ on: - '*.html' - 'src/main/python/**' - 'dev/**' + - '.github/workflows/python.yml' branches: - main pull_request: @@ -38,6 +39,7 @@ on: - '*.html' - 'src/main/python/**' - 'dev/**' + - '.github/workflows/python.yml' branches: - main diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 465df222ae6..8ef9df025b5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -53,6 +53,7 @@ jobs: os: [ubuntu-24.04] java: ['17'] javadist: ['adopt'] + test_mode: [env, noenv, federated] name: ${{ matrix.os }} Java ${{ matrix.java }} ${{ matrix.javadist }} Python ${{ matrix.python-version }} steps: @@ -116,7 +117,6 @@ jobs: librosa \ h5py \ gensim \ - black \ opt-einsum \ nltk @@ -125,7 +125,8 @@ jobs: cd src/main/python python create_python_dist.py - - name: Run all python tests + - name: Run tests with env + if: ${{ matrix.test_mode == 'env' }} run: | export SYSTEMDS_ROOT=$(pwd) export PATH=$SYSTEMDS_ROOT/bin:$PATH @@ -133,30 +134,20 @@ jobs: export LOG4JPROP=$SYSTEMDS_ROOT/src/test/resources/log4j.properties cd src/main/python unittest-parallel -t . -s tests -v - # python -m unittest discover -s tests -p 'test_*.py' - echo "Exit Status: " $? - - name: Run all python tests no environment + - name: Run tests no env + if: ${{ matrix.test_mode == 'noenv' }} run: | export LOG4JPROP=$(pwd)/src/test/resources/log4j.properties cd src/main/python unittest-parallel -t . -s tests -v - # python -m unittest discover -s tests -p 'test_*.py' - echo "Exit Status: " $? - name: Run Federated Python Tests + if: ${{ matrix.test_mode == 'federated' }} run: | export SYSTEMDS_ROOT=$(pwd) export PATH=$SYSTEMDS_ROOT/bin:$PATH cd src/main/python ./tests/federated/runFedTest.sh - - name: Check formatting according to Black (src/main/python/systemds) - run: | - black --check --exclude operator/algorithm src/main/python/systemds - - - name: Check formatting according to Black (src/main/python/tests) - run: | - black --check src/main/python/tests - diff --git a/.github/workflows/pythonFormatting.yml b/.github/workflows/pythonFormatting.yml new file mode 100644 index 00000000000..eb04a6cf3ea --- /dev/null +++ b/.github/workflows/pythonFormatting.yml @@ -0,0 +1,47 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + +name: Python Black Format Check + +on: + push: + paths: + - 'src/main/python/**' + branches: + - main + pull_request: + paths: + - 'src/main/python/**' + branches: + - main + +jobs: + black: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Black Code Formatter + uses: psf/black@stable + with: + options: "--check --exclude operator/algorithm" + src: "src/main/python/systemds src/main/python/tests" \ No newline at end of file From 165e9aa7d58acabb61210bd8e9f300fbf0747621 Mon Sep 17 00:00:00 2001 From: e-strauss Date: Wed, 30 Jul 2025 15:35:10 +0200 Subject: [PATCH 2/3] formatting test with minor change in python file (in a comment) --- .github/workflows/python.yml | 2 +- src/main/python/systemds/context/systemds_context.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8ef9df025b5..273ca6fd3dc 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -55,7 +55,7 @@ jobs: javadist: ['adopt'] test_mode: [env, noenv, federated] - name: ${{ matrix.os }} Java ${{ matrix.java }} ${{ matrix.javadist }} Python ${{ matrix.python-version }} + name: ${{ matrix.os }} Java ${{ matrix.java }} ${{ matrix.javadist }} Python ${{ matrix.python-version }}/ ${{ matrix.test_mode}} steps: - name: Checkout Repository uses: actions/checkout@v4 diff --git a/src/main/python/systemds/context/systemds_context.py b/src/main/python/systemds/context/systemds_context.py index a559850c333..08fda3732a0 100644 --- a/src/main/python/systemds/context/systemds_context.py +++ b/src/main/python/systemds/context/systemds_context.py @@ -820,7 +820,7 @@ class DynamicStderrHandler(logging.StreamHandler): def __init__(self, level=logging.NOTSET, formatter=None): # Avoid setting stream directly to sys.stderr, we will do that dynamically # For more info see test case: tests/basics/test_context_creation/test_random_port_debug3 - # where we redirect the err channel in between different contexts + # where we redirect the err channel between different contexts super().__init__(stream=None) self.setLevel(level) if formatter: From 53f71e9f1d5920d21602d48f7e3a15d02fb57577 Mon Sep 17 00:00:00 2001 From: e-strauss Date: Wed, 30 Jul 2025 15:39:47 +0200 Subject: [PATCH 3/3] avoid using the 3rd party workflow plugin --- .github/workflows/pythonFormatting.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonFormatting.yml b/.github/workflows/pythonFormatting.yml index eb04a6cf3ea..7ecc325c73b 100644 --- a/.github/workflows/pythonFormatting.yml +++ b/.github/workflows/pythonFormatting.yml @@ -40,8 +40,17 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Black Code Formatter - uses: psf/black@stable + - name: Setup Python + uses: actions/setup-python@v5 with: - options: "--check --exclude operator/algorithm" - src: "src/main/python/systemds src/main/python/tests" \ No newline at end of file + python-version: '3.x' + + - name: Install Black + run: | + pip install --upgrade pip + pip install black + + - name: Run Black Check + run: | + black --check --exclude operator/algorithm \ + src/main/python/systemds src/main/python/tests \ No newline at end of file