Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
repos:

- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.2
hooks:
- id: black
exclude: ^(src/ansys/hps/client/rms/models.py)

- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
# exclude: ^(src/ansys/hps/client/jms/resource/|src/ansys/hps/client/auth/resource/)

- repo: https://github.com/PyCQA/flake8
rev: 7.1.2
hooks:
- id: flake8
exclude: ^(src/ansys/hps/client/jms/resource/|src/ansys/hps/client/auth/resource/)
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PyHPS
=====
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black| |pre-commit|
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |ruff| |pre-commit|

.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
:target: https://docs.pyansys.com/
Expand All @@ -26,9 +26,9 @@ PyHPS
:target: https://opensource.org/licenses/MIT
:alt: MIT

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
:target: https://github.com/psf/black
:alt: Black
.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff

.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/ansys/pyhps/main.svg
:target: https://results.pre-commit.ci/latest/github/ansys/pyhps/main
Expand Down
24 changes: 11 additions & 13 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Sphinx documentation configuration file
from datetime import datetime
"""Sphinx documentation configuration file."""

import os
from pathlib import Path
import shutil
import sys
from datetime import datetime
from pathlib import Path
from zipfile import ZipFile

from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black
import sphinx
from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black

from ansys.hps.client import __version__

Expand Down Expand Up @@ -140,12 +141,12 @@


def prepare_jinja_env(jinja_env) -> None:
"""
Customize the jinja env.
"""Customize the jinja env.

Notes
-----
See https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment

"""
jinja_env.globals["project_name"] = project

Expand Down Expand Up @@ -228,7 +229,7 @@ def prepare_jinja_env(jinja_env) -> None:
"navigation_depth": 5,
"check_switcher": False,
"switcher": {
"json_url": f"https://{cname}/versions.json", # noqa: E231
"json_url": f"https://{cname}/versions.json",
"version_match": get_version_match(__version__),
},
"navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
Expand Down Expand Up @@ -390,16 +391,14 @@ def prepare_jinja_env(jinja_env) -> None:


def archive_examples(app: sphinx.application.Sphinx) -> None:
"""
Create a zip archive for each listed example included in the examples folder.
"""Create a zip archive for each listed example included in the examples folder.

Parameters
----------
app : sphinx.application.Sphinx
Sphinx application instance containing the all the doc build configuration.

"""

source_dir = Path(app.srcdir)
root_path = source_dir.parent.parent

Expand All @@ -425,13 +424,12 @@ def archive_examples(app: sphinx.application.Sphinx) -> None:


def setup(app: sphinx.application.Sphinx) -> None:
"""
Run hook function(s) during the documentation build.
"""Run hook function(s) during the documentation build.

Parameters
----------
app : sphinx.application.Sphinx
Sphinx application instance containing the all the doc build configuration.
"""

"""
app.connect("builder-inited", archive_examples)
11 changes: 4 additions & 7 deletions doc/source/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Raw testing
^^^^^^^^^^^

If required, from the command line, you can call style commands like
`Black`_, `isort`_, and `Flake8`_. You can also call unit testing commands like `pytest`_.
`ruff`_. You can also call unit testing commands like `pytest`_.
However, running these commands do not guarantee that your project is being tested
in an isolated environment, which is the reason why tools like ``tox`` exist.

Expand All @@ -107,9 +107,8 @@ This way, it's not possible for you to push code that fails the style checks::

$ pre-commit install
$ git commit -am "added my cool feature"
black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
ruff.....................................................................Passed
ruff-format..............................................................Passed
codespell................................................................Passed
Add License Headers......................................................Passed

Expand Down Expand Up @@ -182,9 +181,7 @@ you can post questions, share ideas, and get community feedback.
To reach the project support team, email `pyansys.core@ansys.com <pyansys.core@ansys.com>`_.

.. LINKS AND REFERENCES
.. _Black: https://github.com/psf/black
.. _isort: https://github.com/PyCQA/isort
.. _Flake8: https://flake8.pycqa.org/en/latest/
.. _ruff: https://github.com/astral-sh/ruff
.. _pytest: https://docs.pytest.org/en/stable/
.. _pip: https://pypi.org/project/pip/
.. _pre-commit: https://pre-commit.com/
Expand Down
13 changes: 8 additions & 5 deletions examples/cfx_static_mixer/exec_cfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@
"""
Copyright (C) 2021 ANSYS, Inc. and its subsidiaries. All Rights Reserved.
"""

# ruff: noqa

import _thread
import json
import logging
import os
from os import path
import platform
import re
import shlex
import subprocess
import time
import traceback
from os import path

from ansys.rep.common.logging import log
from ansys.rep.evaluator.task_manager import ApplicationExecution
Expand Down Expand Up @@ -137,7 +140,7 @@ def execute(self):
for i in ["definitionFile", "mdefFile", "contFile", "iniFile", "mcontFile"]:
k = "cfx_" + i
if not inputs[k] == None:
probname = re.sub("(_\d{3})?\.[^\.]+$", "", inputs[k])
probname = re.sub(r"(_\d{3})?\.[^\.]+$", "", inputs[k])
self.set_putative_run_name(probname)
break

Expand All @@ -150,7 +153,7 @@ def execute(self):
and not inputs["cfx_additionalArgs"] == None
):
for opt in ["-eg", "-example", "-name"]:
m = re.search(opt + "\s+([^\s-]+)", inputs["cfx_additionalArgs"])
m = re.search(opt + r"\s+([^\s-]+)", inputs["cfx_additionalArgs"])
if m:
self.set_putative_run_name(m.group(1))

Expand Down Expand Up @@ -244,7 +247,7 @@ def set_putative_run_name(self, probname):
return
imax = 0
for dI in os.listdir(os.getcwd()):
m = re.match("^" + probname + "_(\d+)(\.(ansys|dir|out|res|mres|trn|cfx))?$", dI)
m = re.match("^" + probname + r"_(\d+)(\.(ansys|dir|out|res|mres|trn|cfx))?$", dI)
if m:
i = int(m.group(1))
if i > imax:
Expand Down Expand Up @@ -293,7 +296,7 @@ def process_error(self, proc):
try:
log.info("Loading sample CFX context...")

with open("cfx_context.json", "r") as f:
with open("cfx_context.json") as f:
context = json.load(f)
print(context)

Expand Down
9 changes: 3 additions & 6 deletions examples/cfx_static_mixer/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""
Example script to set up a simple CFX project in PyHPS.
"""
"""Example script to set up a simple CFX project in PyHPS."""

import argparse
import logging
import os
Expand All @@ -46,9 +45,7 @@


def create_project(client, name, num_jobs=20, version=__ansys_apps_version__):
"""
Create an HPS project consisting of an ANSYS CFX model.
"""
"""Create an HPS project consisting of an ANSYS CFX model."""
jms_api = JmsApi(client)
log.debug("=== Project")
proj = Project(name=name, priority=1, active=True)
Expand Down
6 changes: 2 additions & 4 deletions examples/fluent_2d_heat_exchanger/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""
This example shows how to submit a simple Fluent 2D job to HPS.
"""
"""Example showing how to submit a simple Fluent 2D job to HPS."""

import argparse
import logging
Expand Down Expand Up @@ -134,7 +132,7 @@ def create_project(

log.info("=== Submit Job")
job = project_api.create_jobs(
[Job(name=f"Job", eval_status="pending", job_definition_id=job_def.id)]
[Job(name="Job", eval_status="pending", job_definition_id=job_def.id)]
)[0]

log.info(f"Created project '{proj.name}', ID='{proj.id}'")
Expand Down
9 changes: 3 additions & 6 deletions examples/fluent_nozzle/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""
Example script to set up a simple Fluent project in PyHPS.
"""
"""Example script to set up a simple Fluent project in PyHPS."""

import argparse
import logging
import os
Expand All @@ -45,9 +44,7 @@


def create_project(client, name, num_jobs=20, version=__ansys_apps_version__):
"""
Create an HPS project consisting of an Ansys Fluent model.
"""
"""Create an HPS project consisting of an Ansys Fluent model."""
jms_api = JmsApi(client)
log.debug("=== Project")
proj = Project(name=name, priority=1, active=True)
Expand Down
Loading
Loading