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..273ca6fd3dc 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -53,8 +53,9 @@ 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 }} + name: ${{ matrix.os }} Java ${{ matrix.java }} ${{ matrix.javadist }} Python ${{ matrix.python-version }}/ ${{ matrix.test_mode}} steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -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..7ecc325c73b --- /dev/null +++ b/.github/workflows/pythonFormatting.yml @@ -0,0 +1,56 @@ +#------------------------------------------------------------- +# +# 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: Setup Python + uses: actions/setup-python@v5 + with: + 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 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: