diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..e8a884b02 --- /dev/null +++ b/.flake8 @@ -0,0 +1,7 @@ +[flake8] +exclude = build, doc/source/conf.py +select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, E501, F401, F403 +count = True +max-complexity = 10 +max-line-length = 100 +statistics = True \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..483efa176 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + insecure-external-code-execution: allow + schedule: + interval: "daily" + labels: + - "maintenance" + - "dependencies" diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 8c14067cd..19665ba4d 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -9,6 +9,24 @@ on: - main jobs: + pre-commit: + name: Pre-commit checks + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: Install pre-commit requirements + run: | + pip install pre-commit~=2.16.0 + + - name: Run pre-commit + run: | + pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) + docs_build: runs-on: ubuntu-latest @@ -26,6 +44,16 @@ jobs: make -C doc html SPHINXOPTS="-W" touch doc/build/html/.nojekyll echo "dev.docs.pyansys.com" > doc/build/html/CNAME + + - name: Deploy to gh-pages on main + if: github.ref == 'refs/heads/main' + uses: JamesIves/github-pages-deploy-action@4.1.5 + with: + token: ${{ secrets.github_token }} + branch: gh-pages + folder: docs/build/html + clean: true + single-commit: true - name: Build PDF Documentation run: | @@ -64,17 +92,9 @@ jobs: - name: Display structure of downloaded files run: ls -R - - name: Deploy to gh-pages - uses: JamesIves/github-pages-deploy-action@4.1.5 - with: - token: ${{ secrets.github_token }} - branch: gh-pages - folder: HTML-Documentation - clean: true - single-commit: true - - name: Release uses: softprops/action-gh-release@v1 with: + generate_release_notes: true files: | ./*PDF*/*.pdf diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml deleted file mode 100644 index d47ca3030..000000000 --- a/.github/workflows/style.yml +++ /dev/null @@ -1,21 +0,0 @@ -# check spelling, codestyle -name: Style Check - -on: [push, pull_request, workflow_dispatch] - -jobs: - stylecheck: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - - name: Setup Python - uses: actions/setup-python@v2.2.2 - with: - python-version: 3.8 - - - name: Check Style - run: | - pip install -r requirements_style.txt --disable-pip-version-check - make diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..492d53023 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: +- repo: https://github.com/psf/black + rev: 21.12b0 + hooks: + - id: black + exclude: "^({{cookiecutter.project_slug}}/)" +- repo: https://github.com/asottile/reorder_python_imports + rev: v2.6.0 + hooks: + - id: reorder-python-imports + args: ["--py37-plus"] + exclude: "^({{cookiecutter.project_slug}}/)" +- repo: https://gitlab.com/PyCQA/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + exclude: "^({{cookiecutter.project_slug}}/)" +- repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + args: [--ignore-words=ignore_words.txt, -S \*.pyc\,\*.xml\,\*.txt\,\*.gif\,\*.png\,\*.jpg\,\*.js\,\*.html\,\*.doctree\,\*.ttf\,\*.woff\,\*.woff2\,\*.eot\,\*.mp4\,\*.inv\,\*.pickle\,\*.ipynb\,flycheck\*\,./.git/\*\,./.hypothesis/\*\,\*.yml\,./doc/build/\*\,./doc/images/\*\,./dist/\*\,\*~\,.hypothesis\*\,./doc/source/examples/\*\,\*cover\,\*.dat\,\*.mac] diff --git a/doc/source/conf.py b/doc/source/conf.py index ce660459d..6860460e7 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,30 +1,39 @@ +"""Sphinx documentation configuration file for the pyansys developer's guide.""" from datetime import datetime -from pyansys_sphinx_theme import __version__, pyansys_logo_black +from pyansys_sphinx_theme import __version__ +from pyansys_sphinx_theme import pyansys_logo_black # Project information -project = 'PyAnsys Developers Guide' +project = "PyAnsys Developer's Guide" copyright = f"(c) {datetime.now().year} ANSYS, Inc. All rights reserved" author = "Ansys Inc." -release = version = '0.2.dev0' +release = version = "0.2.dev0" html_logo = pyansys_logo_black -html_theme = 'pyansys_sphinx_theme' +html_theme = "pyansys_sphinx_theme" html_theme_options = { - "github_url": "https://github.com/pyansys/about", - "show_prev_next": False + "github_url": "https://github.com/pyansys/dev-guide", + "show_prev_next": False, + "show_breadcrumbs": True, + "additional_breadcrumbs": [ + ("PyAnsys", "https://docs.pyansys.com/"), + ], } +# necessary for proper breadcrumb title +html_short_title = html_title = project + # Sphinx extensions extensions = [ "sphinx_copybutton", - 'sphinx_toolbox.collapse', - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon', - 'sphinx.ext.todo', + "sphinx_toolbox.collapse", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.todo", ] # Intersphinx mapping @@ -38,10 +47,10 @@ } # The suffix(es) of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" latex_elements = {} @@ -49,11 +58,13 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, - f'pyansys_dev_guide_v{version}.tex', - "PyAnsys Developer's Guide", - author, - 'manual'), + ( + master_doc, + f"pyansys_dev_guide_v{version}.tex", + "PyAnsys Developer's Guide", + author, + "manual", + ), ] diff --git a/doc/source/documentation_style/sample_func.py b/doc/source/documentation_style/sample_func.py index 48412bcc9..735fccdb2 100644 --- a/doc/source/documentation_style/sample_func.py +++ b/doc/source/documentation_style/sample_func.py @@ -1,14 +1,14 @@ def func(arg1, arg2): """Summary line . - Extended description of the function. The extended description, - which can span multiple lines, should provide a general overview + Extended description of the function. The extended description, + which can span multiple lines, should provide a general overview of the function. .. warning:: Use the ``.. warning::`` directive within the docstring for any - warnings that need to be explicitly stated. For example, you - want to include a warning for a method that is to be deprecated + warnings that need to be explicitly stated. For example, you + want to include a warning for a method that is to be deprecated in the next release. Parameters diff --git a/doc/source/guidelines/PyMAPDL_WSL_Guide.rst b/doc/source/guidelines/PyMAPDL_WSL_Guide.rst deleted file mode 100644 index bae5c6071..000000000 --- a/doc/source/guidelines/PyMAPDL_WSL_Guide.rst +++ /dev/null @@ -1,418 +0,0 @@ - .. _ref_guide_wsl: - - -PyAnsys Libraries on a Windows Subsystem for Linux and Docker -############################################################## - -This section shows you how to use a PyAnsys library, more specifically PyMAPDL, in the Windows Subsystem for Linux (WSL). -WSL is a compatibility layer for running Linux binary executables natively on Windows 10, Windows 11, and Windows Server 2019. For more information, see `Wikipedia-WSL `_. - -This section walks you through the installation of WSL on Windows and then shows how to use it together with MAPDL, PyMAPDL, and Docker. - -For more information about WSL, see `What is the Windows Subsystem for Linux? `_. - -.. warning:: **Disclaimer:** This section is currently being drafted. Use it with caution. - - -.. warning:: This guide hasn't been fully tested with a VPN connection. If you experience any problems to connect WSL to internet, try to disconnect from the VPN. - - -Running PyMAPDL on WSL -*********************** - -Install WSL -============ - -See `Install WSL `_ on the Microsoft website. - -Currently there are two versions of WSL. The oldest is WSL1, whereas WSL2 is the latest and include many improvements over WSL1. -It is highly recommended you upgrade and use WSL2 over WSL1. - -Install CentOS7 WSL Distribution -================================= - -We recommend that you use the CentOS7 WSL distribution for working with PyAnsys libraries. - -You can install it using an unofficial WSL distribution from ``_ or -``_ . - -You can use Ubuntu if you want to do so, but it has not been tested yet. - - -Install Ansys Products in WSL CentOS7 -====================================== - -Prerequisites --------------- -If you are using CentOS 7, before installing MAPDL, you need to install some required libraries: - -.. code:: bash - - yum install openssl openssh-clients mesa-libGL mesa-libGLU motif libgfortran - - -If using Ubuntu, follow the instructions in `Running MAPDL: Ubuntu `_ . - - -Install Ansys Products ------------------------ - -To install ANSYS products in WSL Linux: - -1. Download the Ansys Structures image from the customer portal (`Current Release `_). - If you are downloading the image on a Windows machine, you can later copy from it to WSL (recommended). - -2. Decompress the source code file (tar.gz) with: - - .. code:: bash - - tar xvzf STRUCTURES_2021R2_LINX64.tgz - - -3. To install MAPDL, go into the uncompressed folder and type: - - .. code:: bash - - ./INSTALL -silent -install_dir /usr/ansys_inc/ -mechapdl - - where: - - - ``-silent`` : Initiates a silent installation (No GUI). - - - ``-install_dir /path/`` : Specifies the directory to which the product or license - manager is to be installed. - If you want to install to the default location, you can omit the ``-install_dir`` argument. - The default location is ``/ansys_inc`` if the symbolic link is set. Otherwise, it will default to ``/usr/ansys_inc``. - - - ``-`` : Specifies one or more specific products to install. - If you omit the -product_flag argument, all products will be installed. - See the list of valid product_flags in Chapter 6 of the *ANSYS Inc. Installation Guides* PDF. - In this case, only MAPDL (`-mechapdl`) is needed. - -After installing MAPDL directly in ``/ansys_inc`` or in ``/usr/ansys_inc``, create a symbolic link with: - -.. code:: bash - - ln -s /usr/ansys_inc /ansys_inc - -By default, PyMAPDL expects the MAPDL executable to be in ``/usr/ansys_inc``. Whether you install it there or not, we recommend that you link that directory, using a symbolic link, to your ANSYS installation directory (``/*/ansys_inc``). - - -Post-installation Setup -======================== - -Opening Ports --------------- - -**Theory:** -You should open the ports ``1055`` and ``2325`` for the license server communication in *Windows Firewall Advanced*. -You can see the steps in `How to open port in Windows 10 Firewall `_ . - -**Reality:** -This works if you want to run a Docker image using WSL Linux image to host that docker image. -The docker image will successfully communicate with the Windows License Server using these ports if you use the ``'-p'`` flag when running the Docker image and these ports are open. -See `Running MAPDL on a Local Docker Image`_ . - - -If you want to run MAPDL in the CentOS7 image and use the Windows License Server, opening the ports might not work properly because the Windows firewall seems to block all traffic coming from WSL. -For security purposes, we recommend that you still try to open ports ``1055`` and ``2325`` in the firewall and check if your MAPDL installation can communicate with the Windows Hosts. -If you are having problems after setting the firewall rules, you might have to disable Windows Firewall for the WSL ethernet virtual interface. -This might pose some unknown side effects and security risk so use it with caution. -See `Disabling Firewall on WSL Ethernet`_ - - -Setting Up an Environmental Variable in WSL that Points to Windows Host License Server ---------------------------------------------------------------------------------------- - -Windows host IP is given in the WSL file ``/etc/hosts`` before the name ``host.docker.internal``. - - -.. note:: This ``host.docker.internal`` definition might not be available if Docker is not installed. - - -**Example /etc/hosts/ file** - -.. code-block:: bash - :emphasize-lines: 7 - - # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: - # [network] - # generateHosts = false - 127.0.0.1 localhost - 127.0.1.1 AAPDDqVK5WqNLve.win.ansys.com AAPDDqVK5WqNLve - - 192.168.0.12 host.docker.internal - 192.168.0.12 gateway.docker.internal - 127.0.0.1 kubernetes.docker.internal - - # The following lines are desirable for IPv6 capable hosts - ::1 ip6-localhost ip6-loopback - fe00::0 ip6-localnet - ff00::0 ip6-mcastprefix - ff02::1 ip6-allnodes - ff02::2 ip6-allrouters - -You can add the next lines to your WSL ``~/.bashrc`` file to create an environment variable with that IP: - -.. code:: bash - - winhostIP=$(grep -m 1 host.docker.internal /etc/hosts | awk '{print $1}') - export ANSYSLMD_LICENSE_FILE=1055@$winhostIP - - -Running MAPDL on a Local Docker Image -************************************** - -To run a Docker image, you must follow all steps in `Running PyMAPDL on WSL`_ . - -Additionally, you run a Docker image of PyMAPDL with: - -.. code:: pwsh - - docker run -e ANSYSLMD_LICENSE_FILE=1055@host.docker.internal --restart always --name mapdl -p 50053:50052 docker.pkg.github.com/pyansys/pymapdl/mapdl -smp > log.txt - -Successive runs should restart the container or just delete it and rerun it using: - -.. code:: pwsh - - docker stop mapdl - docker container prune - - docker run -e ANSYSLMD_LICENSE_FILE=1055@host.docker.internal --restart always --name mapdl -p 50053:50052 docker.pkg.github.com/pyansys/pymapdl/mapdl -smp > log.txt - - -This will create a log file (``log.txt``) in your current directory location. - - -.. note:: Ensure that your port ``50053`` is open in your firewall. - -We recommended that you use a script (batch ``'.bat'`` or powershell ``'.ps'`` file) to run the above commands all at once. - -Notice that we are mapping the WSL internal gRPC port (``50052``) to a different Windows host port (``50053``) to avoid ports conflicts. - -This image is ready to be connected to from WSL or Windows Host but the port and IP should be specified as: - -.. code:: python - - from ansys.mapdl.core import launch_mapdl - - mapdl = launch_mapdl(ip='127.0.0.1', port=50053, start_instance=False) - -Or: - -.. code:: python - - from ansys.mapdl.core import Mapdl - - mapdl = Mapdl(ip='127.0.0.1', port=50053) - - -You can also specify them using environment variables that are read when launching the MAPDL instance. - -.. code:: bash - - export PYMAPDL_START_INSTANCE=False - export PYMAPDL_PORT=50053 - export PYMAPDL_IP=127.0.0.1 - - -Launch Docker with UPF Capabilities -==================================== - -If you want to specify a custom Python UPF routine, you must have the environment variables ``ANS_USER_PATH`` and ``ANS_USE_UPF`` defined. -The former should be equal to the path where the UPF routines are located, and the latter should be equal to ``TRUE``. - -In WSL, you can do this using: - -.. code:: bash - - export ANS_USER_PATH=/home/user/UPFs # Use your own path to your UPF files. - export ANS_USE_UPF=TRUE - -You can then run the Docker image with: - -.. code:: bash - - docker run -e ANSYSLMD_LICENSE_FILE=1055@host.docker.internal -e ANS_USER_PATH='/ansys_jobs/upf' -e ANS_USE_UPF='TRUE' --restart always --name mapdl -p 50053:50052 docker.pkg.github.com/pyansys/pymapdl/mapdl -smp 1>log.txt - -.. warning:: The use of UPFs with Docker images or PyMAPDL is still in the Alpha state. - - -Notes -====== - -The specified IP (``127.0.0.1``) in `Running MAPDL on a Local Docker Image`_ is the IP of WSL CentOS from the WSL perspective, whereas the Windows host IP is normally ``127.0.1.1``. -Docker builds the PyMAPDL images using the WSL distribution as the base. -Hence, PyMAPDL is running on a Linux WSL distribution, which is running on a Windows host. -Because the Docker image shares resources with WSL, it also shares the internal IP with the WSL distribution. - - -Other Useful Stuff -******************* - - -Other Ansys Installation Flags -=============================== - - -``-licserverinfo`` -------------------- - -You can obtain license server information with one of the following, inspecting the last lines of the ``INSTALL`` file: - -.. code:: bash - - ./INSTALL --help - -Or: - -.. code:: bash - - cat ./INSTALL - - -``-licserverinfo`` ------------------- - -Specifies information to be used by the client for the license server. -Valid only in conjunction with a silent installation (INSTALL). - -The format for a **single license server** is: - -.. code:: bash - - -licserverinfo LI_port_number:FLEXlm_port_number:hostname - -Example: - -.. code:: bash - - ./INSTALL -silent -install_dir /ansys_inc/ -mechapdl -licserverinfo 2325:1055:winhostIP - -The format for **three license servers** is: - -.. code:: bash - - -licserverinfo LI_port_number:FLEXlm_port_number:hostname1,hostname2,hostname3 - -Example: - -.. code:: bash - - ./INSTALL -silent -install_dir /ansys_inc/ -mechapdl -licserverinfo 2325:1055:abc,def,xyz - - -``-lang`` ----------- -Specifies a language to use for the installation of the product. - - -``-productfile`` ------------------ -You can specify an `options` file that lists the products that you want to install. -To do so, you must provide a full path to the file containing the products to install. - - -Regarding IPs in WSL and Windows Host -====================================== - -Theory --------- - -You should be able to access Windows host using IP specified in ``/etc/hosts`` which normally is ``127.0.1.1``. This means that the local WSL IP is ``127.0.0.1``. - -Reality --------- - -It is almost impossible to use ``127.0.1.1`` for connecting to the Windows host. However, it is possible to use ``host.docker.internal`` hostname in the same file (``/etc/hosts``). -This is an IP that is randomly allocated, which is an issue when you define the license server. However, if you update ``.bashrc`` as mentioned before, this issue is solved. - - - -Disabling Firewall on WSL Ethernet -=================================== -This method will show a notification: -.. code:: pwsh - - Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)" - -This method will not show a notification: - -.. code:: pwsh - - powershell.exe -Command "Set-NetFirewallProfile -DisabledInterfaceAliases \"vEthernet (WSL)\"" - - -Link: ``_ - -Windows 10 Port Forwarding -=========================== - - -Link Ports Between WSL and Windows ------------------------------------- - -.. code:: pwsh - - netsh interface portproxy add v4tov4 listenport=1055 listenaddress=0.0.0.0 connectport=1055 connectaddress=XXX.XX.XX.XX - - -PowerShell Command to View all Forwards ----------------------------------------- - -.. code:: pwsh - - netsh interface portproxy show v4tov4 - - -Delete Port Forwarding ------------------------ - -.. code:: pwsh - - netsh interface portproxy delete v4tov4 listenport=1055 listenaddres=0.0.0.0 protocol=tcp - - -Reset Windows Network Adapters -=============================== - -.. code:: pwsh - - netsh int ip reset all - netsh winhttp reset proxy - ipconfig /flushdns - netsh winsock reset - - -Restart WSL service -==================== - -.. code:: pwsh - - Get-Service LxssManager | Restart-Service - -Kill All Processes with a Given Name -==================================== - -.. code:: pwsh - - Get-Process "ANSYS212" | Stop-Process - - -Install xvfb in CentOS7 -======================== - -If you want to replicate the CI/CD behavior, ``xvfb`` is needed. For more information, see ``.ci`` folder. - -.. code:: bash - - yum install xorg-x11-server-Xvfb - - -Notes -****** - -- PyMAPDL only works for shared-memory parallel (SMP) when running on WSL. This is why the flag ``-smp`` should be included. - -- Because there are some incompatibilities between VPN and INTEL MPI, use the flag ``-mpi msmpi`` when calling MAPDL. - diff --git a/doc/source/guidelines/dev_practices.rst b/doc/source/guidelines/dev_practices.rst index 550b6f802..80a3258f6 100644 --- a/doc/source/guidelines/dev_practices.rst +++ b/doc/source/guidelines/dev_practices.rst @@ -3,7 +3,7 @@ Development Practices ===================== This page explains how PyAnsys development is conducted. When -contributing to a PyAnsys repository, use these general +contributing to a PyAnsys repository, use these general coding paradigms: #. Follow the `Zen of Python `__. @@ -35,15 +35,15 @@ To submit new code to a PyAnsys repository: #. `Fork `_ the respective GitHub repository and then clone the forked repository - to your computer. + to your computer. #. In your local repository, create a branch. See :ref:`branch_naming`. - Comprehensive information on our model for branching is availible in + Comprehensive information on our model for branching is available in `Branching Model <#Branching Model>`__. #. Add your new feature and commit it locally. Be sure to commit frequently as the ability to revert to past commits is often helpful, - especially if your change is complex. + especially if your change is complex. #. Test often. See `Testing <#Testing>`__ for automating testing. @@ -104,11 +104,11 @@ any new issues from your changes. .. code:: - pytest -v --cov _unittest + pytest -v --cov Error Messages ~~~~~~~~~~~~~~ -For general information on writting good error messages, see Microsoft's +For general information on writing good error messages, see Microsoft's `Error Message Guidelines `_. For information specific to writing Pythonic error messages, see: @@ -130,7 +130,7 @@ If you are using Linux or Mac OS, run spelling and coding style checks: Misspelled words will be reported. You can add words to be ignored to the ``ignore_words.txt`` file. For example, for PyMAPDL, this file looks -like this: +like this: ... code:: @@ -173,7 +173,7 @@ tasks: Branching Model --------------- The branching model for a PyAnsys project enables rapid development of -features without sacrificing stability. The model closely follows the +features without sacrificing stability. The model closely follows the `Trunk Based Development `_ approach: - The `main` branch is the primary development branch. All features, @@ -216,7 +216,7 @@ Release procedures follow for major and minor releases. #. Locally test and build the documentation with link checking to ensure that no links are outdated. - + #. Run ``make clean`` to ensure that no results are cached. .. code:: @@ -233,10 +233,10 @@ Release procedures follow for major and minor releases. for this release that merges it to ``main``. While effort is focused on the release, development to ``main`` should be limited. -#. Wait for the PyAnsys developers and community to functionally test the - new release. Testors should locally install this branch and use it in - production. Any bugs that they identify should have their hotfixes pushed to - this release branch. +#. Wait for the PyAnsys developers and community to functionally test the new + release. Developers and testers should locally install this branch and use + it in production. Any bugs that they identify should have their hotfixes + pushed to this release branch. When the branch is deemed as stable for public release, the PR is merged to ``main``, which must then be tagged with a ``MAJOR.MINOR.0`` release. @@ -246,7 +246,7 @@ Release procedures follow for major and minor releases. .. code:: - git tag v + git tag v git push origin --tags #. Create a list of all changes for the release. It is often helpful @@ -256,7 +256,7 @@ Release procedures follow for major and minor releases. appropriate if specific contributors are to be thanked for new features. -#. Place your release notes from the previous step in ``Releases`` +#. Place your release notes from the previous step in ``Releases`` in the GitHub repository. See `GitHub Releases`_. .. _GitHub Releases: https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/managing-releases-in-a-repository @@ -272,7 +272,7 @@ should not wait until a minor release. These are the steps for a patch release: This will generally be the latest release branch (for example, ``release/MAJOR.MINOR``). -#. Update the ``__version__.py`` file with the next patch increment +#. Update the ``_version.py`` file with the next patch increment (``MAJOR.MINOR.PATCH``), commit it, and open a PR to merge with the release branch. This gives the PyAnsys developers and community an opportunity to validate and approve the bug fix release. Any diff --git a/doc/source/guidelines/doc_practices.rst b/doc/source/guidelines/doc_practices.rst index bd8f74fd6..3f89e9e25 100644 --- a/doc/source/guidelines/doc_practices.rst +++ b/doc/source/guidelines/doc_practices.rst @@ -2,14 +2,16 @@ Documentation Practices ======================= -PyAnsys documentation must not only be written but also maintained. If you are new -to writing developer documentation, see the `Google Developer Documentation Style -Guide `_. It provides editorial guidelines -for writing clear and consistent developer documentation, allowing this guide to supply -guidance specific to PyAnsys library documentation. +PyAnsys documentation must not only be written but also maintained. If you are +new to writing developer documentation, see the `Google Developer Documentation +Style Guide `_. It provides +editorial guidelines for writing clear and consistent developer documentation, +allowing this guide to supply guidance specific to PyAnsys library +documentation. -When writing developer documentation, the relationship between code and documentation is -key. To keep documentation up to date with rapidly evolving code: +When writing developer documentation, the relationship between code and +documentation is key. To keep documentation up to date with radial evolving +code: - Minimize the content footprint - Write `timeless documentation `_ @@ -18,9 +20,10 @@ key. To keep documentation up to date with rapidly evolving code: Understanding Documentation Sources ------------------------------------ -The generation of PyAnsys documentation uses `Sphinx `__ -and an Ansys-branded theme (`pyansys-sphinx-theme `_) -to assemble content in: +The generation of PyAnsys documentation uses `Sphinx +`__ and an Ansys-branded theme +(`pyansys-sphinx-theme `_) to +assemble content in: - Docstrings - reStructuredText (RST) files @@ -28,8 +31,8 @@ to assemble content in: Docstrings ~~~~~~~~~~ -Docstrings must be formatted so that Sphinx can parse them. You can use either of these -Sphinx extensions: +Docstrings must be formatted so that Sphinx can parse them. You can use either +of these Sphinx extensions: - `numpydoc `_ - `napoleon `_ @@ -41,10 +44,12 @@ and `NumPy `_. If, however, your API is very linear, you might prefer the ``napoleon`` extension because it supports a documentation structure where everything needed to solve a certain problem can be shown on one page. -The ``numpydoc`` extension provides its own `style guide `_ -and a `user guide `_ that explains how to use -the extension with Sphinx. The ``napoleon`` extension, which parses both numpy and Google -style docstrings, refers you to the `Google Python Style Guide `_. +The ``numpydoc`` extension provides its own `style guide +`_ and a `user guide +`_ that explains how to use the +extension with Sphinx. The ``napoleon`` extension, which parses both numpy and +Google style docstrings, refers you to the `Google Python Style Guide +`_. Regardless of the extension that you choose for generating documentation, we recommend the use of numpy-style docstrings so that there is consistency @@ -52,17 +57,18 @@ across PyAnsys libraries. For more information, see :ref:`api_documentation`. RST Files ~~~~~~~~~ -To provide general usage information in your documentation, use your favorite editor to -create RST files that you then place in the repository's ``doc`` directory. The ``index.rst`` -file in the ``doc\source`` directory defines the first level of your documentation hierarchy. -The ``toctree`` directive indicates the maximum number of heading levels that the documentation -is to display. Below this directive are the directory names for your documentation sections. -Each documentation section has its own ``index.rst`` file. - -For example, if you open the ``index.rst`` file in the ``doc\source`` directory in the -``dev-guide`` repository, you will see that the ``toctree`` direction indicates that the -*PyAnsys Developer's Guide* is to display a maximum of three heading levels. You then -see the section structure for this guide: +To provide general usage information in your documentation, use your favorite +editor to create RST files that you then place in the repository's ``doc`` +directory. The ``index.rst`` file in the ``doc\source`` directory defines the +first level of your documentation hierarchy. The ``toctree`` directive +indicates the maximum number of heading levels that the documentation is to +display. Below this directive are the directory names for your documentation +sections. Each documentation section has its own ``index.rst`` file. + +For example, if you open the ``index.rst`` file in the ``doc\source`` directory +in the ``dev-guide`` repository, you will see that the ``toctree`` direction +indicates that the *PyAnsys Developer's Guide* is to display a maximum of three +heading levels. You then see the section structure for this guide: .. code:: @@ -72,23 +78,26 @@ see the section structure for this guide: coding_style/index documentation_style/index -While you do not include the ``.rst`` extension when defining the section structure, the -index file referenced for each section must be named ``index.rst``. If you open ``index.rst`` -in ``doc\source\overview``, you can see that it describes how the PyAnsys project provides -Python libraries that expose Ansys technologies to the Python ecosystem. +While you do not include the ``.rst`` extension when defining the section +structure, the index file referenced for each section must be named +``index.rst``. If you open ``index.rst`` in ``doc\source\overview``, you can +see that it describes how the PyAnsys project provides Python libraries that +expose Ansys technologies to the Python ecosystem. -After you build documentation locally as described in :ref:`doc_building`, the first-level -heading in the ``index.rst`` file for each documentation section is shown as clickable link -in the header of the documentation's generated HTML output. For more information on defining -a documentation structure, see the `Sphinx Getting Started `_ -guide. +After you build documentation locally as described in :ref:`doc_building`, the +first-level heading in the ``index.rst`` file for each documentation section is +shown as clickable link in the header of the documentation's generated HTML +output. For more information on defining a documentation structure, see the +`Sphinx Getting Started +`_ guide. -Within RST files, heading titles are followed by a line having a string of characters that is -the same length as the heading title. If the length of the characters -under the heading title do not match the length of the heading title, Sphinx generates a warning. +Within RST files, heading titles are followed by a line having a string of +characters that is the same length as the heading title. If the length of the +characters under the heading title do not match the length of the heading +title, Sphinx generates a warning. -For consistency within PyAnsys libraries, the use of these special characters is recommended for -headings but are not enforced: +For consistency within PyAnsys libraries, the use of these special characters +is recommended for headings but are not enforced: - For first-level headings, use ====. - For second-level headings, use ---. @@ -97,9 +106,10 @@ headings but are not enforced: For comprehensive syntax information, see the `reStrucutredText Markup Specification `_. -Because you need to be familiar with the content in the *PyAnsys Developer's Guide*, page through -its HTML pages and then explore the RST files in its repository. This will help you to understand -the syntax and see how RST files have been nested to create this guide. +Because you need to be familiar with the content in the *PyAnsys Developer's +Guide*, page through its HTML pages and then explore the RST files in its +repository. This will help you to understand the syntax and see how RST files +have been nested to create this guide. Examples ~~~~~~~~ @@ -108,11 +118,12 @@ Examples come in two formats: - Basic code snippets demonstrating some functionality - Full-fledged standalone examples that are meant to be run as individual downloadable scripts -Basic code snippets should be placed in the ``doc/source`` directory. Full-fledged -standalone examples must be placed in the ``examples`` directory at the root of the -repository. All of these examples, which should be PEP 8-compliant, are compiled dynamically -during the build process. Always ensure that your examples run properly locally because -they will be verified through the CI performed via GitHub Actions. +Basic code snippets should be placed in the ``doc/source`` +directory. Full-fledged standalone examples must be placed in the ``examples`` +directory at the root of the repository. All of these examples, which should be +PEP 8-compliant, are compiled dynamically during the build process. Always +ensure that your examples run properly locally because they will be verified +through the CI performed via GitHub Actions. Adding a new standalone example consists of placing it in an applicable subdirectory in the ``examples`` directory. If none of the existing directories match the category of your example, create @@ -155,7 +166,7 @@ the URL for the latest stable release. For example, consider PyAEDT documentation: - The URL for documentation of the latest stable release is ``_. -- The URL for documentation of the lastest development version is ``_. +- The URL for documentation of the latest development version is ``_. The latest development versions of both the library and its documentation are automatically kept up-to-date via GitHub actions. @@ -197,7 +208,7 @@ To use Windows PowerShell to clone a GitHub repository: #. To the right of the ``HTTPS`` option, click the clipboard icon to copy the path to the repository. -#. Go back to Windows Powershell and type ``git clone`` and then click the right +#. Go back to Windows PowerShell and type ``git clone`` and then click the right mouse button to paste the copied path. #. Press ``Enter`` to copy the files in the repository to your local directory. @@ -205,7 +216,7 @@ To use Windows PowerShell to clone a GitHub repository: #. Type ``ls`` to see a list of the files now in your local directory. .. note:: - In Anaconda Powershell, typing ``dir`` is the equivalent to typing ``ls``. + In PowerShell, typing ``dir`` is the equivalent to typing ``ls``. Using GitBash to Clone a GitHub Repository ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -298,7 +309,7 @@ To use Git Extensions to push your changes to the GitHub repository: description of what you intend to change. #. Make your documentation changes in the directory where you cloned the library's - GitHub reposity. + GitHub repository. #. Test your changes in local documentation builds. For more information, see :ref:`doc_building`. @@ -371,7 +382,7 @@ installing a PyAnsys library in development mode. However, for many other PyAnsy you push changes that you have made in a local branch to the library's GitHub repository, CI checks typically require that the full library is installed. -#. In Anaconda Powershell, navigate to the base directory in the library's cloned repository. +#. In Anaconda PowerShell, navigate to the base directory in the library's cloned repository. #. If your library must be installed in development mode, enter: @@ -412,7 +423,7 @@ How you build HTML documentation depends on your operating system. As Sphinx generates HTML output in the library's ``../doc/_build/html`` directory, - Anaconda Powershell displays any errors and warnings for unexpected indentations, + Anaconda PowerShell displays any errors and warnings for unexpected indentations, bad target locations for links, missing files, and extra files included in the repository but not referenced by any ``index.rst`` file. @@ -447,7 +458,7 @@ On Windows, building a PDF is a manual process that you run locally: #. On the Welcome page, click ``Check for updates`` and install any available updates. -#. Install the latest version of Strawbery Perl, which enables you to build +#. Install the latest version of Strawberry Perl, which enables you to build LaTeX files, accepting the default installation location (``C:\Strawberry\``). #. In the Command Prompt window, type ``perl-v`` to test that your installation is diff --git a/doc/source/guidelines/index.rst b/doc/source/guidelines/index.rst index 0fed0f2c5..8d053d419 100644 --- a/doc/source/guidelines/index.rst +++ b/doc/source/guidelines/index.rst @@ -2,11 +2,10 @@ Guidelines and Best Practices ############################# -This section describes several guidelines and best practices for -creating effective and efficient Python libraries to interface -with Ansys products and services. Topics also demonstrate how -applications and complex services expose functionalities such as -logging, data transfer, and application APIs. +This section describes several guidelines and best practices for creating +effective and efficient Python libraries to interface with Ansys products and +services. Topics also demonstrate how applications and complex services expose +functionalities such as logging, data transfer, and application APIs. .. toctree:: :maxdepth: 3 @@ -18,5 +17,4 @@ logging, data transfer, and application APIs. data_transfer_and_representation logging service_abstraction - PyMAPDL_WSL_Guide test_practices diff --git a/doc/source/guidelines/logging.rst b/doc/source/guidelines/logging.rst index a357d7de4..483db8461 100644 --- a/doc/source/guidelines/logging.rst +++ b/doc/source/guidelines/logging.rst @@ -10,7 +10,7 @@ improvements. Also see external resources for `basic `__ and `advanced -`__ technics. +`__ techniques. Description and Usage @@ -45,7 +45,7 @@ Avoid Printing to the Console ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A common habit while prototyping a new feature is to print a message into the command line executable. Instead of using the common ``Print()`` method, we -recommend using a ``StreamHandler`` and redirecting its content. This will +recommend using a ``Stream-Handler`` and redirecting its content. This will allow messages to be filtered based on their severity level and apply formatting properly. To accomplish this, add a Boolean argument in the initializer of the ``Logger`` class that specifies how to handle the stream. @@ -150,7 +150,7 @@ of the global and instance loggers. :figclass: align-center -You can find the source for this example logger in the collapsable section below +You can find the source for this example logger in the collapsible section below and in the ``dev_guide`` repository at `pyansys_logging.py `_. @@ -277,10 +277,10 @@ Ansys Product Loggers An Ansys product, due to its architecture, can have several loggers. The ``logging`` library features support working with a finite number of loggers. The factory function ``logging.getLogger()`` helps to access each logger by its name. In -addition to name mappings, a hierachy can be established to structure the +addition to name mappings, a hierarchy can be established to structure the loggers' parenting and their connections. -For example, if an Ansys product is using a pre-exsiting custom logger +For example, if an Ansys product is using a pre-existing custom logger encapsulated inside the product itself, the ** will benefit from exposing it through the standard Python tools. We recommend that you use the standard library as much as possible. It will facilitate every contribution diff --git a/doc/source/guidelines/test_practices.rst b/doc/source/guidelines/test_practices.rst index 228d20b28..73a95ec08 100644 --- a/doc/source/guidelines/test_practices.rst +++ b/doc/source/guidelines/test_practices.rst @@ -222,7 +222,7 @@ Integration Testing - Remote Method Invocation Testing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the case of a Remote Method Invocation (RMI)-like method, it is only necessary to test the method with a basic case and potentially with any edge -cases. A RMI-like API might send and receive strings that are excuted on the +cases. A RMI-like API might send and receive strings that are executed on the server using a custom API or language only available within the context of the service. @@ -245,7 +245,7 @@ and a Python wrapping: command : str Command to run on the remote server. -Your exmaple test would be: +Your example test would be: .. code:: python @@ -263,7 +263,7 @@ commands. Functional Testing ~~~~~~~~~~~~~~~~~~ Functional testing should test the Python library using scripts or examples -that are expected to be excuted by the user. Unlike unit or integration +that are expected to be executed by the user. Unlike unit or integration testing, these functional tests are testing the library as a whole by calling several methods to accomplish a task. These tests should only be run after unit and integration testing is complete, and they should be run outside the diff --git a/doc/source/overview/contributing.rst b/doc/source/overview/contributing.rst index fb2126c11..23aa59335 100644 --- a/doc/source/overview/contributing.rst +++ b/doc/source/overview/contributing.rst @@ -2,18 +2,17 @@ Contributing ############ -Ansys welcomes all PyAnsys code contributions and wants you to -understand how to contribute. While we maintain PyAnsys libraries -and thoroughly review all submissions, we want to foster a community -that supports user questions and develops new features to make -our libraries powerful tools for all users. As such, we -encourage you to submit questions, report bugs, request new -features, contribute code, and start discussions. - -This page provides general information about contributing code to a -PyAnsys respository. Contribution information specific to a particular -repository appears on the ``Contributing`` page in the respective -respository's documentation, including: +Ansys welcomes all PyAnsys code contributions and wants you to understand how +to contribute. While we maintain PyAnsys libraries and thoroughly review all +submissions, we want to foster a community that supports user questions and +develops new features to make our libraries powerful tools for all users. As +such, we encourage you to submit questions, report bugs, request new features, +contribute code, and start discussions. + +This page provides general information about contributing code to a PyAnsys +repository. Contribution information specific to a particular repository +appears on the ``Contributing`` page in the respective repository's +documentation, including: - Instructions for cloning the source repository from GitHub - URL to the repository's ``Issues`` page @@ -22,19 +21,20 @@ respository's documentation, including: Creating Issues =============== You create issues to submit questions, report bugs, and request new -features. When you create an issue, ensure that you provide sufficient -context, such as application versions and reproduction steps. Also use -an issue label like "Documentation" to indicate the issue category. +features. When you create an issue, ensure that you provide sufficient context, +such as application versions and reproduction steps. Also use an issue label +like "Documentation" to indicate the issue category. -PyAnsys developers and community members will respond to and hopefully -resolve your issue. Once an issue is resolved, you are encouraged to -close it yourself. Otherwise, after a period of inactivity, the PyAnsys -project support team will use discretion as to whether to close it. +PyAnsys developers and community members will respond to and hopefully resolve +your issue. Once an issue is resolved, you are encouraged to close it +yourself. Otherwise, after a period of inactivity, the PyAnsys project support +team will use discretion as to whether to close it. -Should it turn out that your issue is closed erroneously, perhaps because -a bug fix implemented to resolve your issue did not work, you can re-open -it with a comment that explains why you have done so. If you need to contact the -PyAnsys project support team directly, email `pyansys.support@ansys.com `_. +Should it turn out that your issue is closed erroneously, perhaps because a bug +fix implemented to resolve your issue did not work, you can re-open it with a +comment that explains why you have done so. If you need to contact the PyAnsys +project support team directly, email `pyansys.support@ansys.com +`_. For convenience, here are URLs for ``Issues`` pages for public Ansys repositories: @@ -86,7 +86,7 @@ When you are ready to start contributing code, see: code to adhere to PyAnsys standards -All pull requests are reviwed before they can be merged. +All pull requests are reviewed before they can be merged. Starting Discussions ==================== @@ -100,13 +100,14 @@ page. It is possible for discussions to lead to the creation of issues. Because the ``Discussions`` page is still a GitHub beta feature, usage may change in the future. + Cloning the Source Repository ============================= -As mentioned earlier, specific instructions for cloning a source -repository from GitHub appear on the ``Contributing`` page in the -respective repository's documentation. In the following code for cloning and -installing the latest version of a PyAnsys repository, ```` -is a placeholder for the name of the repository. +As mentioned earlier, specific instructions for cloning a source repository +from GitHub appear on the ``Contributing`` page in the respective repository's +documentation. In the following code for cloning and installing the latest +version of a PyAnsys repository, ```` is a placeholder for +the name of the repository. .. code:: @@ -125,11 +126,12 @@ you would run the following: pip install -e . -If you want to eventually push a contribution to a -PyAnsys repository, consider creating a `fork `_ -of the repository. For information on how to contribute through -GitHub, see :ref:`development_practices`, paying particular attention to :ref:`branch_naming` -when you are ready to create a pull request. +If you want to eventually push a contribution to a PyAnsys repository, consider +creating a `fork`_ of the repository. For information on how to contribute +through GitHub, see :ref:`development_practices`, paying particular attention +to :ref:`branch_naming` when you are ready to create a pull request. + +.. _fork: https://docs.github.com/en/get-started/quickstart/fork-a-repo Licensing ========= diff --git a/doc/source/overview/index.rst b/doc/source/overview/index.rst index 5af2725e0..4acb9bc35 100644 --- a/doc/source/overview/index.rst +++ b/doc/source/overview/index.rst @@ -3,9 +3,9 @@ Overview ######## Through the PyAnsys project, Ansys provides Python libraries that -expose Ansys technologies to the Python ecosystem. These libraries -are more than reusable scripts. They are clear, concise, and -maintainable APIs and interfaces. Their useful functions, classes, +expose Ansys technologies to the Python ecosystem. These libraries +are more than reusable scripts. They are clear, concise, and +maintainable APIs and interfaces. Their useful functions, classes, and plugins eliminate the need to write scripts interfacing with low level APIs, allowing you to now interact with the product or service at a high level in an object-orientated manner. @@ -30,9 +30,10 @@ ecosystem. Examples include: - Machine learning using `TensorFlow `_ .. note:: - If you are new to GitHub, we suggest that you visit `The ReadMe Project `_. - It is a dedicated platform for highlighting the best from the open source software community. - Each monthly newletter provides links to feature articles, developer stories, guides, and podcasts. + If you are new to GitHub, we suggest that you visit `The ReadMe Project + `_. It is a dedicated platform for highlighting + the best from the open source software community. Each monthly newletter + provides links to feature articles, developer stories, guides, and podcasts. .. toctree:: :hidden: @@ -44,3 +45,31 @@ ecosystem. Examples include: .. _PyAEDT: https://github.com/pyansys/PyAEDT .. _PyMAPDL: https://github.com/pyansys/pymapdl + + +Contributing to this Guide +~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you would like to contribute to this development guide, we will gladly review +all pull requests. Please feel free to submit them and follow the +:ref:`doc_practices`. + +This repository uses the `pre-commit `_ library to +automate style checking. To use it, enter your Python environment and install +it with:: + + pip install pre-commit + +You can then run it manually with:: + + pre-commit run --all-files + +This performs various style and spelling checks to ensure your contributions +meet minimum coding style and documentation standards. + +You can make sure that these checks are always run prior to ``git commit`` by +installing a pre-commit as a git hook with:: + + pre-commit install + +Now, each time you run ``git commit``, your commit will only be created if it +passes the minimum style checks that will also be run on the GitHub CI/CD. diff --git a/logging/README.md b/logging/README.md index 4bb356371..a0c9f22b0 100644 --- a/logging/README.md +++ b/logging/README.md @@ -1,5 +1,5 @@ #### Example Logging Modules These modules demonstrate one way of logging at the global and -instance level for a PyAnsys libary that exposes and extends an a +instance level for a PyAnsys library that exposes and extends an a service based application. diff --git a/logging/pyansys_logging.py b/logging/pyansys_logging.py index ff7288726..973beb822 100644 --- a/logging/pyansys_logging.py +++ b/logging/pyansys_logging.py @@ -1,8 +1,12 @@ -from copy import copy -from datetime import datetime import logging -from logging import DEBUG, INFO, WARN, ERROR, CRITICAL import sys +from copy import copy +from datetime import datetime +from logging import CRITICAL +from logging import DEBUG +from logging import ERROR +from logging import INFO +from logging import WARN # Default configuration LOG_LEVEL = logging.DEBUG @@ -185,7 +189,12 @@ class Logger: _instances = {} def __init__( - self, level=logging.DEBUG, to_file=False, to_stdout=True, filename=FILE_NAME, cleanup=True + self, + level=logging.DEBUG, + to_file=False, + to_stdout=True, + filename=FILE_NAME, + cleanup=True, ): """Initialize Logger class.""" @@ -398,8 +407,8 @@ def __del__(self): if self.cleanup: try: for handler in self.logger.handlers: - handler.close() - self.logger.removeHandler(handler) + handler.close() + self.logger.removeHandler(handler) except Exception as e: try: if self.logger is not None: diff --git a/logging/test_pyansys_logging.py b/logging/test_pyansys_logging.py index 44eb377ad..ece1a4c06 100644 --- a/logging/test_pyansys_logging.py +++ b/logging/test_pyansys_logging.py @@ -16,7 +16,10 @@ def test_default_logger(): test_logger = pyansys_logging.Logger() test_logger.info("Test stdout") - assert "INFO - - test_pyansys_logging - test_default_logger - Test stdout" in capture.content + assert ( + "INFO - - test_pyansys_logging - test_default_logger - Test stdout" + in capture.content + ) # File handlers are not activated. assert os.path.exists(os.path.exists(os.path.join(os.getcwd(), "PyProject.log"))) @@ -43,19 +46,42 @@ def test_level_stdout(): test_logger.critical("Critical stdout with level=WARNING") # level=INFO - assert "DEBUG - - test_pyansys_logging - test_level_stdout - Debug stdout with level=INFO" not in capture.content - assert "INFO - - test_pyansys_logging - test_level_stdout - Info stdout with level=INFO" in capture.content - assert "WARNING - - test_pyansys_logging - test_level_stdout - Warning stdout with level=INFO" in capture.content - assert "ERROR - - test_pyansys_logging - test_level_stdout - Error stdout with level=INFO" in capture.content - assert "CRITICAL - - test_pyansys_logging - test_level_stdout - Critical stdout with level=INFO" in capture.content + assert ( + "DEBUG - - test_pyansys_logging - test_level_stdout - Debug stdout with level=INFO" + not in capture.content + ) + assert ( + "INFO - - test_pyansys_logging - test_level_stdout - Info stdout with level=INFO" + in capture.content + ) + assert ( + "WARNING - - test_pyansys_logging - test_level_stdout - Warning stdout with level=INFO" + in capture.content + ) + assert ( + "ERROR - - test_pyansys_logging - test_level_stdout - Error stdout with level=INFO" + in capture.content + ) + assert ( + "CRITICAL - - test_pyansys_logging - test_level_stdout - Critical stdout with level=INFO" + in capture.content + ) # level=WARNING - assert "INFO - - test_pyansys_logging - test_level_stdout - Info stdout with level=WARNING" not in capture.content assert ( - "WARNING - - test_pyansys_logging - test_level_stdout - Warning stdout with level=WARNING" in capture.content + "INFO - - test_pyansys_logging - test_level_stdout - Info stdout with level=WARNING" + not in capture.content + ) + assert ( + "WARNING - - test_pyansys_logging - test_level_stdout - Warning stdout with level=WARNING" + in capture.content + ) + assert ( + "ERROR - - test_pyansys_logging - test_level_stdout - Error stdout with level=WARNING" + in capture.content ) - assert "ERROR - - test_pyansys_logging - test_level_stdout - Error stdout with level=WARNING" in capture.content assert ( - "CRITICAL - - test_pyansys_logging - test_level_stdout - Critical stdout with level=WARNING" in capture.content + "CRITICAL - - test_pyansys_logging - test_level_stdout - Critical stdout with level=WARNING" # noqa: E501 + in capture.content ) # File handlers are not activated. @@ -73,12 +99,20 @@ def test_file_handlers(tmpdir): with open(file_logger, "r") as f: content = f.readlines() - assert os.path.exists(file_logger) # The file handler is not the default PyProject.Log + assert os.path.exists( + file_logger + ) # The file handler is not the default PyProject.Log assert len(content) == 6 assert "NEW SESSION" in content[2] - assert "===============================================================================" in content[3] + assert ( + "===============================================================================" + in content[3] + ) assert "LEVEL - INSTANCE NAME - MODULE - FUNCTION - MESSAGE" in content[4] - assert "INFO - - test_pyansys_logging - test_file_handlers - Test Misc File" in content[5] + assert ( + "INFO - - test_pyansys_logging - test_file_handlers - Test Misc File" + in content[5] + ) # Delete the logger and its file handler. test_logger_ref = weakref.ref(test_logger) diff --git a/requirements_docs.txt b/requirements_docs.txt index 352bef49b..cf71401be 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,4 +1,4 @@ -Sphinx==4.3.2 -pyansys-sphinx-theme==0.2.0 -sphinx-copybutton==0.4.0 -sphinx_toolbox +Sphinx==4.4.0 +pyansys-sphinx-theme==0.2.3 +sphinx-copybutton==0.5.0 +sphinx_toolbox==2.17.0 diff --git a/requirements_style.txt b/requirements_style.txt deleted file mode 100644 index f85124708..000000000 --- a/requirements_style.txt +++ /dev/null @@ -1,3 +0,0 @@ -codespell==2.1.0 - -