From f80c2e014bf73055cf6ea18870df16140d87662a Mon Sep 17 00:00:00 2001 From: Ivo Steinbrecher Date: Fri, 15 Nov 2024 14:40:05 +0100 Subject: [PATCH 1/4] Add pre-commit hooks --- .pre-commit-config.yaml | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2be9c15 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black + language_version: python3.12 diff --git a/pyproject.toml b/pyproject.toml index 9b45fed..8c54a8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ description = "CubitPy: Utility functions for the cubit python interface" readme = "README.md" license = {file = "LICENSE"} dependencies = [ - "black", + "black==22.12.0", "execnet==1.9.0", "netCDF4", "numpy" From ca7be69b836580a1f812bd74782bad5b01cdcf9e Mon Sep 17 00:00:00 2001 From: Ivo Steinbrecher Date: Fri, 15 Nov 2024 14:44:46 +0100 Subject: [PATCH 2/4] Add contributing guidelines to the README --- README.md | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4693b5d..7d09ae1 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,31 @@ [![build-test](https://github.com/imcs-compsim/cubitpy/actions/workflows/.github/workflows/build-test.yml/badge.svg)](https://github.com/imcs-compsim/cubitpy/actions/workflows/.github/workflows/build-test.yml) -# Cubitpy +# CubitPy -Cubit features and utilities functions, especially for the creation of input files for 4C. -It is tested with Cubit15.2. +Utility functions and 4C related functionality for the Cubit and Coreform python interface, +Especially for the creation of input files for 4C. ## Usage A tutorial can be found in the `/tutorial` directory. -## Code formating +## Contributing -CubitPy uses the python code formatter [black](https://github.com/psf/black). -The testsuite checks if all files are formatted accordingly. +If you are interested in contributing to CubitPy, we welcome your collaboration. +For general questions, feature request and bug reports please open an [issue](https://github.com/imcs-compsim/cubitpy/issues). + +If you contribute actual code, fork the repository and make the changes in a feature branch. +Depending on the topic and amount of changes you also might want to open an [issue](https://github.com/imcs-compsim/cubitpy/issues). +To merge your changes into the CubitPy repository, create a pull request to the `main` branch. +A few things to keep in mind: +- It is highly encouraged to add tests covering the functionality of your changes, see the test suite in `tests/`. +- CubitPy uses `black` to format python code. + Make sure to apply `black` to the changed source files. +- Feel free to add yourself to the [CONTRIBUTORS](CONTRIBUTORS) file. ## Installation -Cubitpy is developed with `python3.8`. +CubitPy is developed with `python3.12`. Other versions of Python might lead to issues. It is recommended to use virtual environments with `python`. On Debian systems the following packages have to be installed @@ -34,7 +43,7 @@ The created virtual environment can be loaded with source cubitpy-env/bin/activate ``` -From now on we assume that the virtual enviroment is loaded. +From now on we assume that the virtual environment is loaded. To install `cubitpy` go to the repository root directory ```bash cd path_to_cubitpy @@ -58,5 +67,10 @@ export CUBIT_ROOT=path_to_cubit_root_directory To check if everything worked as expected, run the tests from within the `tests` directory ```bash cd path_to_cubitpy/tests -pytest -q testing.py +pytest -q testing.py +``` + +If you intend to actively develop CubitPy, please make sure to install the `pre-commit` hook within the python environment to follow our style guides: +```bash +pre-commit install ``` From 0cf4a5ef6e37e8a119d37c6d9b278010cdc8dd7e Mon Sep 17 00:00:00 2001 From: Ivo Steinbrecher Date: Fri, 15 Nov 2024 14:51:28 +0100 Subject: [PATCH 3/4] Update LICENSE text --- LICENSE | 3 ++- cubitpy/__init__.py | 3 ++- cubitpy/conf.py | 3 ++- cubitpy/cubit_group.py | 3 ++- cubitpy/cubit_utility.py | 3 ++- cubitpy/cubit_wrapper/__init__.py | 3 ++- cubitpy/cubit_wrapper/cubit_wrapper_client.py | 3 ++- cubitpy/cubit_wrapper/cubit_wrapper_host.py | 3 ++- cubitpy/cubit_wrapper/cubit_wrapper_utility.py | 3 ++- cubitpy/cubitpy.py | 3 ++- cubitpy/cubitpy_to_dat.py | 3 ++- cubitpy/cubitpy_types.py | 3 ++- cubitpy/geometry_creation_functions.py | 3 ++- cubitpy/mesh_creation_functions.py | 3 ++- pyproject.toml | 2 +- tests/test_delete.py | 3 ++- tests/testing.py | 3 ++- tests/testing_header.py | 3 ++- tests/testing_tutorial.py | 3 ++- tutorial/__init__.py | 3 ++- tutorial/tutorial.py | 3 ++- 21 files changed, 41 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index 797f1d6..19b9234 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -CubitPy: Cubit utility functions and a cubit wrapper for python3 +CubitPy: Utility functions and 4C related functionality for the Cubit and + Coreform python interface MIT License diff --git a/cubitpy/__init__.py b/cubitpy/__init__.py index fd5e0e1..c5afa30 100644 --- a/cubitpy/__init__.py +++ b/cubitpy/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/conf.py b/cubitpy/conf.py index a51d387..2470652 100644 --- a/cubitpy/conf.py +++ b/cubitpy/conf.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubit_group.py b/cubitpy/cubit_group.py index 7329c1d..6cc12af 100644 --- a/cubitpy/cubit_group.py +++ b/cubitpy/cubit_group.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubit_utility.py b/cubitpy/cubit_utility.py index 62c9700..7a0c4a9 100644 --- a/cubitpy/cubit_utility.py +++ b/cubitpy/cubit_utility.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubit_wrapper/__init__.py b/cubitpy/cubit_wrapper/__init__.py index df48b2f..f48ec23 100644 --- a/cubitpy/cubit_wrapper/__init__.py +++ b/cubitpy/cubit_wrapper/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubit_wrapper/cubit_wrapper_client.py b/cubitpy/cubit_wrapper/cubit_wrapper_client.py index 3a46847..a1b2dbf 100644 --- a/cubitpy/cubit_wrapper/cubit_wrapper_client.py +++ b/cubitpy/cubit_wrapper/cubit_wrapper_client.py @@ -1,5 +1,6 @@ # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubit_wrapper/cubit_wrapper_host.py b/cubitpy/cubit_wrapper/cubit_wrapper_host.py index 631012d..e0f8717 100644 --- a/cubitpy/cubit_wrapper/cubit_wrapper_host.py +++ b/cubitpy/cubit_wrapper/cubit_wrapper_host.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubit_wrapper/cubit_wrapper_utility.py b/cubitpy/cubit_wrapper/cubit_wrapper_utility.py index 2bd8d99..25913f6 100644 --- a/cubitpy/cubit_wrapper/cubit_wrapper_utility.py +++ b/cubitpy/cubit_wrapper/cubit_wrapper_utility.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubitpy.py b/cubitpy/cubitpy.py index e28b336..ca9ac55 100644 --- a/cubitpy/cubitpy.py +++ b/cubitpy/cubitpy.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubitpy_to_dat.py b/cubitpy/cubitpy_to_dat.py index ddbedbf..d4bae1d 100644 --- a/cubitpy/cubitpy_to_dat.py +++ b/cubitpy/cubitpy_to_dat.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/cubitpy_types.py b/cubitpy/cubitpy_types.py index 69b7faf..722a8f1 100644 --- a/cubitpy/cubitpy_types.py +++ b/cubitpy/cubitpy_types.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/geometry_creation_functions.py b/cubitpy/geometry_creation_functions.py index 6582208..e6e599b 100644 --- a/cubitpy/geometry_creation_functions.py +++ b/cubitpy/geometry_creation_functions.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/cubitpy/mesh_creation_functions.py b/cubitpy/mesh_creation_functions.py index a10f8c4..f3d44c7 100644 --- a/cubitpy/mesh_creation_functions.py +++ b/cubitpy/mesh_creation_functions.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/pyproject.toml b/pyproject.toml index 8c54a8c..60aaef9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ name = "CubitPy" authors = [ {name = "Ivo Steinbrecher", email = "ivo.steinbrecher@unibw.de"}, ] -description = "CubitPy: Utility functions for the cubit python interface" +description = "CubitPy: Utility functions and 4C related functionality for the Cubit and Coreform python interface" readme = "README.md" license = {file = "LICENSE"} dependencies = [ diff --git a/tests/test_delete.py b/tests/test_delete.py index b970234..6434358 100644 --- a/tests/test_delete.py +++ b/tests/test_delete.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/tests/testing.py b/tests/testing.py index 4fe2d9a..12f9d64 100644 --- a/tests/testing.py +++ b/tests/testing.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/tests/testing_header.py b/tests/testing_header.py index f0692f8..324391e 100644 --- a/tests/testing_header.py +++ b/tests/testing_header.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/tests/testing_tutorial.py b/tests/testing_tutorial.py index 0b5f7bc..c5d4639 100644 --- a/tests/testing_tutorial.py +++ b/tests/testing_tutorial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/tutorial/__init__.py b/tutorial/__init__.py index 8e4ccca..7766467 100644 --- a/tutorial/__init__.py +++ b/tutorial/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # diff --git a/tutorial/tutorial.py b/tutorial/tutorial.py index ccd8579..4bfad9b 100644 --- a/tutorial/tutorial.py +++ b/tutorial/tutorial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- -# CubitPy: Cubit utility functions and a cubit wrapper for python3 +# CubitPy: Utility functions and 4C related functionality for the Cubit and +# Coreform python interface # # MIT License # From ee2af8f6daba90acfadc3c3aa6a4dd81c4168835 Mon Sep 17 00:00:00 2001 From: Ivo Steinbrecher Date: Fri, 15 Nov 2024 14:54:44 +0100 Subject: [PATCH 4/4] Update mentions of python3 --- .github/workflows/build-test.yml | 2 +- README.md | 2 +- cubitpy/cubit_wrapper/cubit_wrapper_client.py | 4 ++-- tests/test_configurations.sh | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 961503f..ddc0c2b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -32,7 +32,7 @@ jobs: . ${SPACK_ACTIVATION_SCRIPT} spack load python@3.12.1 # Create the virtual environment - python3 -m venv $PYTHON_VENV + python -m venv $PYTHON_VENV source $PYTHON_VENV/bin/activate # Update pip pip install --upgrade pip diff --git a/README.md b/README.md index 7d09ae1..89fe813 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ sudo apt-get install python3-venv python3-dev Now a virtual environment can be created (chose an appropriate directory for this, e.g., `/home/user/opt`) ```bash -python3 -m venv cubitpy-env +python -m venv cubitpy-env ``` The created virtual environment can be loaded with diff --git a/cubitpy/cubit_wrapper/cubit_wrapper_client.py b/cubitpy/cubit_wrapper/cubit_wrapper_client.py index a1b2dbf..30b6545 100644 --- a/cubitpy/cubit_wrapper/cubit_wrapper_client.py +++ b/cubitpy/cubit_wrapper/cubit_wrapper_client.py @@ -122,7 +122,7 @@ def is_cubit_type(obj): # Now start an endless loop (until None is sent) and perform the cubit functions while 1: - # Get input from python3. + # Get input from the python host. receive = channel.receive() # If None is sent, break the connection and exit @@ -250,7 +250,7 @@ def deserialize_item(item): "The id {} is not in the cubit_objects dictionary".format(cubit_id) ) - # Return to python3 + # Return to python host channel.send(None) else: diff --git a/tests/test_configurations.sh b/tests/test_configurations.sh index 5758598..9ba0ffa 100755 --- a/tests/test_configurations.sh +++ b/tests/test_configurations.sh @@ -2,10 +2,10 @@ # Test the deletion of objects. # Save stderr in variable. -python3 test_delete.py +python test_delete.py # Exit status to fail gitlab pipeline. -ERRORSTRING=$(python3 test_delete.py 2>&1) +ERRORSTRING=$(python test_delete.py 2>&1) if [[ -z "$ERRORSTRING" ]]; then # if std error was empy, test was ok echo "Deletion test OK!"