From 60c9607381b063cf4abd8cffe2242a34ee17a690 Mon Sep 17 00:00:00 2001 From: German Date: Wed, 22 Feb 2023 20:15:42 +0700 Subject: [PATCH 01/18] first approach --- .flake8 | 2 +- pyproject.toml | 8 +- src/ansys/tools/path/__init__.py | 10 + src/ansys/tools/path/misc.py | 7 + src/ansys/tools/path/path.py | 426 +++++++++++++++++++++++++++++++ tests/test_path.py | 27 ++ 6 files changed, 477 insertions(+), 3 deletions(-) create mode 100644 src/ansys/tools/path/misc.py create mode 100644 src/ansys/tools/path/path.py create mode 100644 tests/test_path.py diff --git a/.flake8 b/.flake8 index 04ddda89..3087c0ec 100644 --- a/.flake8 +++ b/.flake8 @@ -3,5 +3,5 @@ exclude = venv, __init__.py, doc/_build 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 +max-line-length = 120 statistics = True \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index fbdc6596..f831f2bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ classifiers = [ ] dependencies = [ "importlib-metadata >=4.0", + "appdirs>=1.4.0", ] [tool.flit.module] @@ -37,15 +38,18 @@ Homepage = "https://github.com/pyansys/ansys-tools-path" [tool.black] -line-length = 100 +line-length = 120 [tool.isort] profile = "black" force_sort_within_sections = true -line_length = 100 +line_length = 120 default_section = "THIRDPARTY" src_paths = ["doc", "src", "tests"] +[tools.flake8] +max-line-length = 100 + [tool.coverage.run] source = ["ansys.tools"] diff --git a/src/ansys/tools/path/__init__.py b/src/ansys/tools/path/__init__.py index 81848b7d..e8d680cc 100644 --- a/src/ansys/tools/path/__init__.py +++ b/src/ansys/tools/path/__init__.py @@ -10,3 +10,13 @@ import importlib_metadata __version__ = importlib_metadata.version(__name__.replace(".", "-")) + + +from ansys.tools.path import ( + find_ansys, + change_default_ansys_path, + save_ansys_path, + get_ansys_path, + get_available_ansys_installations, + check_valid_ansys, +) diff --git a/src/ansys/tools/path/misc.py b/src/ansys/tools/path/misc.py new file mode 100644 index 00000000..318714e7 --- /dev/null +++ b/src/ansys/tools/path/misc.py @@ -0,0 +1,7 @@ +def is_float(input_string): + """Returns true when a string can be converted to a float""" + try: + float(input_string) + return True + except ValueError: + return False diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py new file mode 100644 index 00000000..39a07ee5 --- /dev/null +++ b/src/ansys/tools/path/path.py @@ -0,0 +1,426 @@ +import logging as LOG # Temporal hack +import os +import re +import warnings +from glob import glob + +import appdirs +from ansys.tools.path.misc import is_float + +LINUX_DEFAULT_DIRS = [["/", "usr", "ansys_inc"], ["/", "ansys_inc"]] +LINUX_DEFAULT_DIRS = [os.path.join(*each) for each in LINUX_DEFAULT_DIRS] + +CONFIG_FILE_NAME = "config.txt" + +# settings directory +SETTINGS_DIR = appdirs.user_data_dir("ansys_tools_path") +if not os.path.isdir(SETTINGS_DIR): + try: + LOG.debug(f"Created settings directory: {SETTINGS_DIR}") + os.makedirs(SETTINGS_DIR) + except: + warnings.warn("Unable to create settings directory.\n" "Will be unable to cache MAPDL executable location") + +CONFIG_FILE = os.path.join(SETTINGS_DIR, CONFIG_FILE_NAME) + + +def _version_from_path(path): + """Extract ansys version from a path. Generally, the version of + ANSYS is contained in the path: + + C:/Program Files/ANSYS Inc/v202/ansys/bin/winx64/ANSYS202.exe + + /usr/ansys_inc/v211/ansys/bin/mapdl + + Note that if the MAPDL executable, you have to rely on the version + in the path. + + Parameters + ---------- + path : str + Path to the MAPDL executable + + Returns + ------- + int + Integer version number (e.g. 211). + + """ + # expect v/ansys + # replace \\ with / to account for possible windows path + matches = re.findall(r"v(\d\d\d).ansys", path.replace("\\", "/"), re.IGNORECASE) + if not matches: + raise RuntimeError(f"Unable to extract Ansys version from {path}") + return int(matches[-1]) + + +def check_valid_ansys(): + """Checks if a valid version of ANSYS is installed and preconfigured""" + ansys_bin = get_ansys_path(allow_input=False) + if ansys_bin is not None: + version = _version_from_path(ansys_bin) + return not (version < 170 and os.name != "posix") + return False + + +def _get_available_base_ansys(supported_versions): + """Return a dictionary of available Ansys versions with their base paths. + + Returns + ------- + dict[int: str] + Return all installed Ansys paths in Windows. + + Notes + ----- + + On Windows, It uses the environment variable ``AWP_ROOTXXX``. + + The student versions are returned at the end of the dict and with + negative value for the version. + + Examples + -------- + + >>> from ansys.mapdl.core import _get_available_base_ansys + >>> _get_available_base_ansys() + {222: 'C:\\Program Files\\ANSYS Inc\\v222', + 212: 'C:\\Program Files\\ANSYS Inc\\v212', + -222: 'C:\\Program Files\\ANSYS Inc\\ANSYS Student\\v222'} + + Return all installed Ansys paths in Linux. + + >>> _get_available_base_ansys() + {194: '/usr/ansys_inc/v194', + 202: '/usr/ansys_inc/v202', + 211: '/usr/ansys_inc/v211'} + """ + base_path = None + if os.name == "nt": # pragma: no cover + # The student version overwrites the AWP_ROOT env var + # (if it is installed later) + # However the priority should be given to the non-student version. + awp_roots = [] + awp_roots_student = [] + + for ver in supported_versions: + path_ = os.environ.get(f"AWP_ROOT{ver}", "") + path_non_student = path_.replace("\\ANSYS Student", "") + + if "student" in path_.lower() and os.path.exists(path_non_student): + # Check if also exist a non-student version + awp_roots.append([ver, path_non_student]) + awp_roots_student.insert(0, [-1 * ver, path_]) + + else: + awp_roots.append([ver, path_]) + + awp_roots.extend(awp_roots_student) + installed_versions = {ver: path for ver, path in awp_roots if path and os.path.isdir(path)} + + if installed_versions: + LOG.debug(f"Found the following installed Ansys versions: {installed_versions}") + return installed_versions + else: # pragma: no cover + LOG.debug("No installed ANSYS found using 'AWP_ROOT' environments. Let's suppose a base path.") + base_path = os.path.join(os.environ["PROGRAMFILES"], "ANSYS INC") + if not os.path.exists(base_path): + LOG.debug(f"The supposed 'base_path'{base_path} does not exist. No available ansys found.") + return {} + elif os.name == "posix": + for path in LINUX_DEFAULT_DIRS: + if os.path.isdir(path): + base_path = path + else: # pragma: no cover + raise OSError(f"Unsupported OS {os.name}") + + if base_path is None: + return {} + + paths = glob(os.path.join(base_path, "v*")) + + # Testing for ANSYS STUDENT version + if not paths: # pragma: no cover + paths = glob(os.path.join(base_path, "ANSYS*")) + + if not paths: + return {} + + ansys_paths = {} + for path in paths: + ver_str = path[-3:] + if is_float(ver_str): + ansys_paths[int(ver_str)] = path + + return ansys_paths + + +def get_available_ansys_installations(supported_versions): + """Return a dictionary of available Ansys versions with their base paths. + + Returns + ------- + dict[int: str] + Return all installed Ansys paths in Windows. + + Notes + ----- + + On Windows, It uses the environment variable ``AWP_ROOTXXX``. + + The student versions are returned at the end of the dict and + with negative value for the version. + + Examples + -------- + + >>> from ansys.mapdl.core import get_available_ansys_installations + >>> get_available_ansys_installations() + {222: 'C:\\Program Files\\ANSYS Inc\\v222', + 212: 'C:\\Program Files\\ANSYS Inc\\v212', + -222: 'C:\\Program Files\\ANSYS Inc\\ANSYS Student\\v222'} + + Return all installed Ansys paths in Linux. + + >>> get_available_ansys_installations() + {194: '/usr/ansys_inc/v194', + 202: '/usr/ansys_inc/v202', + 211: '/usr/ansys_inc/v211'} + """ + return _get_available_base_ansys(supported_versions) + + +def find_ansys(supported_versions, version=None): + """Searches for ansys path within the standard install location + and returns the path of the latest version. + + Parameters + ---------- + version : int, float, optional + Version of ANSYS to search for. + If using ``int``, it should follow the convention ``XXY``, where + ``XX`` is the major version, + and ``Y`` is the minor. + If using ``float``, it should follow the convention ``XX.Y``, where + ``XX`` is the major version, + and ``Y`` is the minor. + If ``None``, use latest available version on the machine. + + Returns + ------- + ansys_path : str + Full path to ANSYS executable. + + version : float + Version float. For example, 21.1 corresponds to 2021R1. + + Examples + -------- + Within Windows + + >>> from ansys.mapdl.core.launcher import find_ansys + >>> find_ansys() + 'C:/Program Files/ANSYS Inc/v211/ANSYS/bin/winx64/ansys211.exe', 21.1 + + Within Linux + + >>> find_ansys() + (/usr/ansys_inc/v211/ansys/bin/ansys211, 21.1) + """ + versions = _get_available_base_ansys(supported_versions) + if not versions: + return "", "" + + if not version: + version = max(versions.keys()) + + elif isinstance(version, float): + # Using floats, converting to int. + version = int(version * 10) + + try: + ans_path = versions[version] + except KeyError as e: + raise ValueError(f"Version {version} not found. Available versions are {list(versions.keys())}") from e + + version = abs(version) + if os.name == "nt": + ansys_bin = os.path.join(ans_path, "ansys", "bin", "winx64", f"ansys{version}.exe") + else: + ansys_bin = os.path.join(ans_path, "ansys", "bin", f"ansys{version}") + return ansys_bin, version / 10 + + +def is_valid_executable_path(exe_loc): # pragma: no cover + return os.path.isfile(exe_loc) and re.search("ansys\d\d\d", os.path.basename(os.path.normpath(exe_loc))) is not None + + +def is_common_executable_path(exe_loc): # pragma: no cover + path = os.path.normpath(exe_loc) + path = path.split(os.sep) + if re.search("v(\d\d\d)", exe_loc) is not None and re.search("ansys(\d\d\d)", exe_loc) is not None: + equal_version = re.search("v(\d\d\d)", exe_loc)[1] == re.search("ansys(\d\d\d)", exe_loc)[1] + else: + equal_version = False + + return ( + is_valid_executable_path(exe_loc) + and re.search("v\d\d\d", exe_loc) + and "ansys" in path + and "bin" in path + and equal_version + ) + + +def change_default_ansys_path(exe_loc): + """Change your default ansys path. + + Parameters + ---------- + exe_loc : str + Ansys executable path. Must be a full path. + + Examples + -------- + Change default Ansys location on Linux + + >>> from ansys.mapdl.core import launcher + >>> launcher.change_default_ansys_path('/ansys_inc/v201/ansys/bin/ansys201') + >>> launcher.get_ansys_path() + '/ansys_inc/v201/ansys/bin/ansys201' + + Change default Ansys location on Windows + + >>> ans_pth = 'C:/Program Files/ANSYS Inc/v193/ansys/bin/winx64/ANSYS193.exe' + >>> launcher.change_default_ansys_path(ans_pth) + >>> launcher.check_valid_ansys() + True + + """ + if os.path.isfile(exe_loc): + with open(CONFIG_FILE, "w") as f: + f.write(exe_loc) + else: + raise FileNotFoundError("File %s is invalid or does not exist" % exe_loc) + + +def save_ansys_path(exe_loc=None): # pragma: no cover + """Find MAPDL's path or query user. + + If no ``exe_loc`` argument is supplied, this function attempt + to obtain the MAPDL executable from (and in order): + + - The default ansys paths (i.e. ``'C:/Program Files/Ansys Inc/vXXX/ansys/bin/ansysXXX'``) + - The configuration file + - User input + + If ``exe_loc`` is supplied, this function does some checks. + If successful, it will write that ``exe_loc`` into the config file. + + Parameters + ---------- + exe_loc : str, optional + Path of the MAPDL executable ('ansysXXX'), by default ``None``. + + Returns + ------- + str + Path of the MAPDL executable. + + Notes + ----- + The configuration file location (``config.txt``) can be found in + ``appdirs.user_data_dir("ansys_mapdl_core")``. For example: + + .. code:: pycon + + >>> import appdirs + >>> import os + >>> print(os.path.join(appdirs.user_data_dir("ansys_mapdl_core"), "config.txt")) + C:/Users/user/AppData/Local/ansys_mapdl_core/ansys_mapdl_core/config.txt + + Examples + -------- + You can change the default ``exe_loc`` either by modifying the mentioned + ``config.txt`` file or by executing: + + >>> from ansys.mapdl.core import save_ansys_path + >>> save_ansys_path('/new/path/to/executable') + + """ + if exe_loc is None: + exe_loc, _ = find_ansys() + + if is_valid_executable_path(exe_loc): # pragma: not cover + if not is_common_executable_path(exe_loc): + warn_uncommon_executable_path(exe_loc) + + change_default_ansys_path(exe_loc) + return exe_loc + + if exe_loc is not None: + if is_valid_executable_path(exe_loc): + return exe_loc # pragma: no cover + + # otherwise, query user for the location + print("Cached ANSYS executable not found") + print( + "You are about to enter manually the path of the ANSYS MAPDL executable(ansysXXX,where XXX is the version\n" + "This file is very likely to contained in path ending in 'vXXX/ansys/bin/ansysXXX', but it is not required.\n" + "\nIf you experience problems with the input path you can overwrite the configuration file by typing:\n" + ">>> from ansys.mapdl.core.launcher import save_ansys_path\n" + ">>> save_ansys_path('/new/path/to/executable/')\n" + ) + need_path = True + while need_path: # pragma: no cover + exe_loc = input("Enter the location of an ANSYS executable (ansysXXX):") + + if is_valid_executable_path(exe_loc): + if not is_common_executable_path(exe_loc): + warn_uncommon_executable_path(exe_loc) + with open(CONFIG_FILE, "w") as f: + f.write(exe_loc) + need_path = False + else: + print("The supplied path is either: not a valid file path, or does not match 'ansysXXX' name.") + + return exe_loc + + +def warn_uncommon_executable_path(exe_loc): # pragma: no cover + warnings.warn( + f"The supplied path ('{exe_loc}') does not match the usual ansys executable path style" + "('directory/vXXX/ansys/bin/ansysXXX'). " + "You might have problems at later use." + ) + + +def get_ansys_path(allow_input=True, version=None): + """Acquires ANSYS Path from a cached file or user input + + Parameters + ---------- + allow_input : bool, optional + Allow user input to find ANSYS path. The default is ``True``. + + version : float, optional + Version of ANSYS to search for. For example ``version=22.2``. + If ``None``, use latest. + + """ + exe_loc = None + if not version and os.path.isfile(CONFIG_FILE): + with open(CONFIG_FILE) as f: + exe_loc = f.read() + # verify + if not os.path.isfile(exe_loc) and allow_input: + exe_loc = save_ansys_path() + elif not version and allow_input: # create configuration file + exe_loc = save_ansys_path() + + if exe_loc is None: + exe_loc = find_ansys(version=version)[0] + if not exe_loc: + exe_loc = None + + return exe_loc diff --git a/tests/test_path.py b/tests/test_path.py new file mode 100644 index 00000000..c1cfc736 --- /dev/null +++ b/tests/test_path.py @@ -0,0 +1,27 @@ +import os + +from ansys.tools.path import _version_from_path +from ansys.tools.path import find_ansys + +# change_default_ansys_path, save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys + + +paths = [ + ("/usr/dir_v2019.1/slv/ansys_inc/v211/ansys/bin/ansys211", 211), + ("C:/Program Files/ANSYS Inc/v202/ansys/bin/win64/ANSYS202.exe", 202), + ("/usr/ansys_inc/v211/ansys/bin/mapdl", 211), +] + + +@pytest.mark.parametrize("path_data", paths) +def test_version_from_path(path_data): + exec_file, version = path_data + assert _version_from_path(exec_file) == version + + +def test_find_ansys_linux(): + # assuming ansys is installed, should be able to find it on linux + # without env var + bin_file, ver = find_ansys() + assert os.path.isfile(bin_file) + assert isinstance(ver, float) From cdb59349c29629c669597b1391fb5a2c4dad74d6 Mon Sep 17 00:00:00 2001 From: German Date: Wed, 22 Feb 2023 20:26:08 +0700 Subject: [PATCH 02/18] Using some versions --- src/ansys/tools/path/__init__.py | 3 ++- src/ansys/tools/path/path.py | 21 ++++++++++++++++++--- tests/test_path.py | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/ansys/tools/path/__init__.py b/src/ansys/tools/path/__init__.py index e8d680cc..e4ce3e89 100644 --- a/src/ansys/tools/path/__init__.py +++ b/src/ansys/tools/path/__init__.py @@ -12,7 +12,8 @@ __version__ = importlib_metadata.version(__name__.replace(".", "-")) -from ansys.tools.path import ( +from ansys.tools.path.path import ( + SUPPORTED_ANSYS_VERSIONS, find_ansys, change_default_ansys_path, save_ansys_path, diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py index 39a07ee5..8a866797 100644 --- a/src/ansys/tools/path/path.py +++ b/src/ansys/tools/path/path.py @@ -12,6 +12,21 @@ CONFIG_FILE_NAME = "config.txt" +SUPPORTED_ANSYS_VERSIONS = { + 231: "2023R1", + 222: "2022R2", + 221: "2022R1", + 212: "2021R2", + 211: "2021R1", + 202: "2020R2", + 201: "2020R1", + 195: "19.5", + 194: "19.4", + 193: "19.3", + 192: "19.2", + 191: "19.1", +} + # settings directory SETTINGS_DIR = appdirs.user_data_dir("ansys_tools_path") if not os.path.isdir(SETTINGS_DIR): @@ -63,7 +78,7 @@ def check_valid_ansys(): return False -def _get_available_base_ansys(supported_versions): +def _get_available_base_ansys(supported_versions=SUPPORTED_ANSYS_VERSIONS): """Return a dictionary of available Ansys versions with their base paths. Returns @@ -155,7 +170,7 @@ def _get_available_base_ansys(supported_versions): return ansys_paths -def get_available_ansys_installations(supported_versions): +def get_available_ansys_installations(supported_versions=SUPPORTED_ANSYS_VERSIONS): """Return a dictionary of available Ansys versions with their base paths. Returns @@ -190,7 +205,7 @@ def get_available_ansys_installations(supported_versions): return _get_available_base_ansys(supported_versions) -def find_ansys(supported_versions, version=None): +def find_ansys(version=None, supported_versions=SUPPORTED_ANSYS_VERSIONS): """Searches for ansys path within the standard install location and returns the path of the latest version. diff --git a/tests/test_path.py b/tests/test_path.py index c1cfc736..0dccba04 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -1,7 +1,8 @@ import os -from ansys.tools.path import _version_from_path +import pytest from ansys.tools.path import find_ansys +from ansys.tools.path.path import _version_from_path # change_default_ansys_path, save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys From c3c748d55644e4b58882c06176699e8ecdb0d4d7 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 08:37:13 +0000 Subject: [PATCH 03/18] Second big iteration. Merged requirements to pyproject.toml Increased coverage --- pyproject.toml | 19 ++++++++++ src/ansys/tools/path/__init__.py | 1 - src/ansys/tools/path/path.py | 37 +++++++----------- tests/test_misc.py | 14 +++++++ tests/test_path.py | 64 ++++++++++++++++++++++++++++++-- 5 files changed, 107 insertions(+), 28 deletions(-) create mode 100644 tests/test_misc.py diff --git a/pyproject.toml b/pyproject.toml index f831f2bf..863f22b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,25 @@ dependencies = [ "appdirs>=1.4.0", ] + +[project.optional-dependencies] +tests = [ + "pytest==7.2.1", + "pytest-cov==4.0.0", +] + +doc = [ + "Sphinx==5.0.2", + "numpydoc==1.4.0", + "ansys-sphinx-theme==0.4.2", + "sphinx-copybutton==0.5", +] + +build = [ + "build==0.8.0", + "twine==4.0.1", +] + [tool.flit.module] name = "ansys.tools.path" diff --git a/src/ansys/tools/path/__init__.py b/src/ansys/tools/path/__init__.py index e4ce3e89..f7ceebfd 100644 --- a/src/ansys/tools/path/__init__.py +++ b/src/ansys/tools/path/__init__.py @@ -19,5 +19,4 @@ save_ansys_path, get_ansys_path, get_available_ansys_installations, - check_valid_ansys, ) diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py index 8a866797..f61bbdd6 100644 --- a/src/ansys/tools/path/path.py +++ b/src/ansys/tools/path/path.py @@ -68,16 +68,6 @@ def _version_from_path(path): raise RuntimeError(f"Unable to extract Ansys version from {path}") return int(matches[-1]) - -def check_valid_ansys(): - """Checks if a valid version of ANSYS is installed and preconfigured""" - ansys_bin = get_ansys_path(allow_input=False) - if ansys_bin is not None: - version = _version_from_path(ansys_bin) - return not (version < 170 and os.name != "posix") - return False - - def _get_available_base_ansys(supported_versions=SUPPORTED_ANSYS_VERSIONS): """Return a dictionary of available Ansys versions with their base paths. @@ -266,21 +256,21 @@ def find_ansys(version=None, supported_versions=SUPPORTED_ANSYS_VERSIONS): return ansys_bin, version / 10 -def is_valid_executable_path(exe_loc): # pragma: no cover - return os.path.isfile(exe_loc) and re.search("ansys\d\d\d", os.path.basename(os.path.normpath(exe_loc))) is not None +def is_valid_executable_path(exe_loc): + return os.path.isfile(exe_loc) and re.search(r"ansys\d\d\d", os.path.basename(os.path.normpath(exe_loc))) is not None -def is_common_executable_path(exe_loc): # pragma: no cover +def is_common_executable_path(exe_loc): path = os.path.normpath(exe_loc) path = path.split(os.sep) - if re.search("v(\d\d\d)", exe_loc) is not None and re.search("ansys(\d\d\d)", exe_loc) is not None: - equal_version = re.search("v(\d\d\d)", exe_loc)[1] == re.search("ansys(\d\d\d)", exe_loc)[1] + if re.search(r"v(\d\d\d)", exe_loc) is not None and re.search(r"ansys(\d\d\d)", exe_loc) is not None: + equal_version = re.search(r"v(\d\d\d)", exe_loc)[1] == re.search(r"ansys(\d\d\d)", exe_loc)[1] else: equal_version = False return ( is_valid_executable_path(exe_loc) - and re.search("v\d\d\d", exe_loc) + and re.search(r"v\d\d\d", exe_loc) and "ansys" in path and "bin" in path and equal_version @@ -308,8 +298,6 @@ def change_default_ansys_path(exe_loc): >>> ans_pth = 'C:/Program Files/ANSYS Inc/v193/ansys/bin/winx64/ANSYS193.exe' >>> launcher.change_default_ansys_path(ans_pth) - >>> launcher.check_valid_ansys() - True """ if os.path.isfile(exe_loc): @@ -319,7 +307,7 @@ def change_default_ansys_path(exe_loc): raise FileNotFoundError("File %s is invalid or does not exist" % exe_loc) -def save_ansys_path(exe_loc=None): # pragma: no cover +def save_ansys_path(exe_loc=None, allow_prompt=True): # pragma: no cover """Find MAPDL's path or query user. If no ``exe_loc`` argument is supplied, this function attempt @@ -366,7 +354,7 @@ def save_ansys_path(exe_loc=None): # pragma: no cover if exe_loc is None: exe_loc, _ = find_ansys() - if is_valid_executable_path(exe_loc): # pragma: not cover + if is_valid_executable_path(exe_loc): if not is_common_executable_path(exe_loc): warn_uncommon_executable_path(exe_loc) @@ -375,9 +363,12 @@ def save_ansys_path(exe_loc=None): # pragma: no cover if exe_loc is not None: if is_valid_executable_path(exe_loc): - return exe_loc # pragma: no cover + return exe_loc + if allow_prompt: + exe_loc = _prompt_ansys_path() + return exe_loc - # otherwise, query user for the location +def _prompt_ansys_path(): # pragma: no cover print("Cached ANSYS executable not found") print( "You are about to enter manually the path of the ANSYS MAPDL executable(ansysXXX,where XXX is the version\n" @@ -398,10 +389,8 @@ def save_ansys_path(exe_loc=None): # pragma: no cover need_path = False else: print("The supplied path is either: not a valid file path, or does not match 'ansysXXX' name.") - return exe_loc - def warn_uncommon_executable_path(exe_loc): # pragma: no cover warnings.warn( f"The supplied path ('{exe_loc}') does not match the usual ansys executable path style" diff --git a/tests/test_misc.py b/tests/test_misc.py new file mode 100644 index 00000000..e9c4aaad --- /dev/null +++ b/tests/test_misc.py @@ -0,0 +1,14 @@ +import pytest + +from ansys.tools.path.misc import is_float + + +values = [ + (11, True), + (11.1, True), + ("asdf", False), + ("1234asdf", False), +] +@pytest.mark.parametrize("values", values) +def test_is_float(values): + assert is_float(values[0]) == values[1] \ No newline at end of file diff --git a/tests/test_path.py b/tests/test_path.py index 0dccba04..121c4f7d 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -1,16 +1,24 @@ import os - import pytest + from ansys.tools.path import find_ansys -from ansys.tools.path.path import _version_from_path +from ansys.tools.path.path import CONFIG_FILE, _version_from_path, get_available_ansys_installations, is_valid_executable_path, change_default_ansys_path, warn_uncommon_executable_path, get_ansys_path, save_ansys_path + +#, save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys -# change_default_ansys_path, save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys +""" +pytest -v --durations=10 \ + --cov=ansys.tools.path \ + --cov-report=html + +""" paths = [ ("/usr/dir_v2019.1/slv/ansys_inc/v211/ansys/bin/ansys211", 211), ("C:/Program Files/ANSYS Inc/v202/ansys/bin/win64/ANSYS202.exe", 202), ("/usr/ansys_inc/v211/ansys/bin/mapdl", 211), + pytest.param(("/usr/ansys_inc/ansys/bin/mapdl", 211), marks=pytest.mark.xfail), ] @@ -20,9 +28,59 @@ def test_version_from_path(path_data): assert _version_from_path(exec_file) == version + def test_find_ansys_linux(): # assuming ansys is installed, should be able to find it on linux # without env var bin_file, ver = find_ansys() assert os.path.isfile(bin_file) assert isinstance(ver, float) + +def test_get_available_base_ansys(): + assert get_available_ansys_installations() + +def test_is_valid_executable_path(): + path = get_available_ansys_installations().values() + path = list(path)[0] + assert not is_valid_executable_path(path) + +def test_is_common_executable_path(): + path = get_available_ansys_installations().values() + path = list(path)[0] + assert not is_valid_executable_path(path) + +def test_change_default_ansys_path(): + + if os.path.isfile(CONFIG_FILE): + with open(CONFIG_FILE, 'r') as fid: + assert "/bin/bash" not in fid.read() + + new_path = "/bin/bash" #Just to check something + change_default_ansys_path(new_path) + + with open(CONFIG_FILE, 'r') as fid: + assert "/bin/bash" in fid.read() + + os.remove(CONFIG_FILE) + + +def test_save_ansys_path(): + if os.path.isfile(CONFIG_FILE): + os.remove(CONFIG_FILE) + + path = get_available_ansys_installations().values() + path = list(path)[0] + + assert save_ansys_path(path, allow_prompt=False) + assert save_ansys_path(None, allow_prompt=False) + + +def test_warn_uncommon_executable_path(): + + with pytest.warns(UserWarning): + warn_uncommon_executable_path("qwer") + + +def test_get_ansys_path(): + assert get_ansys_path() + assert get_ansys_path(version=222) \ No newline at end of file From 60c05f0d0d5584e4ea143e3e7f1a71e57eeab2c1 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 08:37:50 +0000 Subject: [PATCH 04/18] Second big iteration. Merged requirements to pyproject.toml Increased coverage --- requirements/requirements_build.txt | 2 -- requirements/requirements_doc.txt | 4 ---- requirements/requirements_tests.txt | 2 -- 3 files changed, 8 deletions(-) delete mode 100644 requirements/requirements_build.txt delete mode 100644 requirements/requirements_doc.txt delete mode 100644 requirements/requirements_tests.txt diff --git a/requirements/requirements_build.txt b/requirements/requirements_build.txt deleted file mode 100644 index 3666776b..00000000 --- a/requirements/requirements_build.txt +++ /dev/null @@ -1,2 +0,0 @@ -build==0.8.0 -twine==4.0.1 diff --git a/requirements/requirements_doc.txt b/requirements/requirements_doc.txt deleted file mode 100644 index b3392e14..00000000 --- a/requirements/requirements_doc.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sphinx==5.0.2 -numpydoc==1.4.0 -ansys-sphinx-theme==0.4.2 -sphinx-copybutton==0.5 diff --git a/requirements/requirements_tests.txt b/requirements/requirements_tests.txt deleted file mode 100644 index 71b21e3b..00000000 --- a/requirements/requirements_tests.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest==7.1.2 -pytest-cov==3.0.0 From b100b65e03e5e2bc21922cd0be23c69c8068cc50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 08:38:10 +0000 Subject: [PATCH 05/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/ansys/tools/path/path.py | 7 ++++++- tests/test_misc.py | 5 +++-- tests/test_path.py | 32 ++++++++++++++++++++------------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py index f61bbdd6..dc1d9fc3 100644 --- a/src/ansys/tools/path/path.py +++ b/src/ansys/tools/path/path.py @@ -68,6 +68,7 @@ def _version_from_path(path): raise RuntimeError(f"Unable to extract Ansys version from {path}") return int(matches[-1]) + def _get_available_base_ansys(supported_versions=SUPPORTED_ANSYS_VERSIONS): """Return a dictionary of available Ansys versions with their base paths. @@ -257,7 +258,9 @@ def find_ansys(version=None, supported_versions=SUPPORTED_ANSYS_VERSIONS): def is_valid_executable_path(exe_loc): - return os.path.isfile(exe_loc) and re.search(r"ansys\d\d\d", os.path.basename(os.path.normpath(exe_loc))) is not None + return ( + os.path.isfile(exe_loc) and re.search(r"ansys\d\d\d", os.path.basename(os.path.normpath(exe_loc))) is not None + ) def is_common_executable_path(exe_loc): @@ -368,6 +371,7 @@ def save_ansys_path(exe_loc=None, allow_prompt=True): # pragma: no cover exe_loc = _prompt_ansys_path() return exe_loc + def _prompt_ansys_path(): # pragma: no cover print("Cached ANSYS executable not found") print( @@ -391,6 +395,7 @@ def _prompt_ansys_path(): # pragma: no cover print("The supplied path is either: not a valid file path, or does not match 'ansysXXX' name.") return exe_loc + def warn_uncommon_executable_path(exe_loc): # pragma: no cover warnings.warn( f"The supplied path ('{exe_loc}') does not match the usual ansys executable path style" diff --git a/tests/test_misc.py b/tests/test_misc.py index e9c4aaad..b3d88b1b 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,5 +1,4 @@ import pytest - from ansys.tools.path.misc import is_float @@ -9,6 +8,8 @@ ("asdf", False), ("1234asdf", False), ] + + @pytest.mark.parametrize("values", values) def test_is_float(values): - assert is_float(values[0]) == values[1] \ No newline at end of file + assert is_float(values[0]) == values[1] diff --git a/tests/test_path.py b/tests/test_path.py index 121c4f7d..1227c47c 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -1,10 +1,17 @@ import os -import pytest +import pytest from ansys.tools.path import find_ansys -from ansys.tools.path.path import CONFIG_FILE, _version_from_path, get_available_ansys_installations, is_valid_executable_path, change_default_ansys_path, warn_uncommon_executable_path, get_ansys_path, save_ansys_path +from ansys.tools.path.path import _version_from_path +from ansys.tools.path.path import change_default_ansys_path +from ansys.tools.path.path import CONFIG_FILE +from ansys.tools.path.path import get_ansys_path +from ansys.tools.path.path import get_available_ansys_installations +from ansys.tools.path.path import is_valid_executable_path +from ansys.tools.path.path import save_ansys_path +from ansys.tools.path.path import warn_uncommon_executable_path -#, save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys +# , save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys """ @@ -28,7 +35,6 @@ def test_version_from_path(path_data): assert _version_from_path(exec_file) == version - def test_find_ansys_linux(): # assuming ansys is installed, should be able to find it on linux # without env var @@ -36,38 +42,41 @@ def test_find_ansys_linux(): assert os.path.isfile(bin_file) assert isinstance(ver, float) + def test_get_available_base_ansys(): assert get_available_ansys_installations() + def test_is_valid_executable_path(): path = get_available_ansys_installations().values() path = list(path)[0] assert not is_valid_executable_path(path) + def test_is_common_executable_path(): path = get_available_ansys_installations().values() path = list(path)[0] assert not is_valid_executable_path(path) -def test_change_default_ansys_path(): +def test_change_default_ansys_path(): if os.path.isfile(CONFIG_FILE): - with open(CONFIG_FILE, 'r') as fid: + with open(CONFIG_FILE, "r") as fid: assert "/bin/bash" not in fid.read() - new_path = "/bin/bash" #Just to check something + new_path = "/bin/bash" # Just to check something change_default_ansys_path(new_path) - with open(CONFIG_FILE, 'r') as fid: + with open(CONFIG_FILE, "r") as fid: assert "/bin/bash" in fid.read() - + os.remove(CONFIG_FILE) def test_save_ansys_path(): if os.path.isfile(CONFIG_FILE): os.remove(CONFIG_FILE) - + path = get_available_ansys_installations().values() path = list(path)[0] @@ -76,11 +85,10 @@ def test_save_ansys_path(): def test_warn_uncommon_executable_path(): - with pytest.warns(UserWarning): warn_uncommon_executable_path("qwer") def test_get_ansys_path(): assert get_ansys_path() - assert get_ansys_path(version=222) \ No newline at end of file + assert get_ansys_path(version=222) From c1a1c016719a9b4a67b47f9277f62f1d08b383d3 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 08:53:10 +0000 Subject: [PATCH 06/18] fixing precommit --- .github/workflows/ci_cd.yml | 5 ++++- .pre-commit-config.yaml | 30 +++++++++++++++++++++++++++++- src/ansys/tools/path/path.py | 6 +++--- tests/test_path.py | 3 +++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 46fdb516..56ff7809 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -58,7 +58,10 @@ jobs: - name: Unit testing run: | cd tests # so we're testing the install, not local - pytest -vx + pytest -vx --cov=ansys.tools.path --cov-report=html + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 - name: Upload wheel uses: actions/upload-artifact@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e45e0d92..4ecab9ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,21 @@ repos: - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.1.0 # IF VERSION CHANGES --> MODIFY "blacken-docs" MANUALLY AS WELL!! hooks: - id: black + +- repo: https://github.com/adamchainz/blacken-docs + rev: 1.13.0 + hooks: + - id: blacken-docs + additional_dependencies: [black==23.1.0] + - repo: https://github.com/asottile/reorder_python_imports rev: v3.9.0 hooks: - id: reorder-python-imports args: ["--py37-plus"] + - repo: https://github.com/PyCQA/flake8 rev: 6.0.0 hooks: @@ -16,6 +24,26 @@ repos: rev: v2.2.2 hooks: - id: codespell + args: ["--toml", "pyproject.toml"] + additional_dependencies: ["tomli"] + +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-merge-conflict + - id: debug-statements + +# this validates our github workflow files +- repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.21.0 + hooks: + - id: check-github-workflows + # - repo: https://github.com/pycqa/pydocstyle # rev: 6.1.1 # hooks: diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py index f61bbdd6..6ae39e23 100644 --- a/src/ansys/tools/path/path.py +++ b/src/ansys/tools/path/path.py @@ -29,7 +29,7 @@ # settings directory SETTINGS_DIR = appdirs.user_data_dir("ansys_tools_path") -if not os.path.isdir(SETTINGS_DIR): +if not os.path.isdir(SETTINGS_DIR): # pragma: no cover try: LOG.debug(f"Created settings directory: {SETTINGS_DIR}") os.makedirs(SETTINGS_DIR) @@ -307,7 +307,7 @@ def change_default_ansys_path(exe_loc): raise FileNotFoundError("File %s is invalid or does not exist" % exe_loc) -def save_ansys_path(exe_loc=None, allow_prompt=True): # pragma: no cover +def save_ansys_path(exe_loc=None, allow_prompt=True): """Find MAPDL's path or query user. If no ``exe_loc`` argument is supplied, this function attempt @@ -391,7 +391,7 @@ def _prompt_ansys_path(): # pragma: no cover print("The supplied path is either: not a valid file path, or does not match 'ansysXXX' name.") return exe_loc -def warn_uncommon_executable_path(exe_loc): # pragma: no cover +def warn_uncommon_executable_path(exe_loc): warnings.warn( f"The supplied path ('{exe_loc}') does not match the usual ansys executable path style" "('directory/vXXX/ansys/bin/ansysXXX'). " diff --git a/tests/test_path.py b/tests/test_path.py index 121c4f7d..596b8567 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -63,6 +63,9 @@ def test_change_default_ansys_path(): os.remove(CONFIG_FILE) + with pytest.raises(FileNotFoundError): + change_default_ansys_path("asdf") + def test_save_ansys_path(): if os.path.isfile(CONFIG_FILE): From 8705cc681775b2771445fdda594a25f7f89ec16d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 08:56:26 +0000 Subject: [PATCH 07/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/ansys/tools/path/__init__.py | 4 ++-- src/ansys/tools/path/path.py | 4 +++- tests/test_misc.py | 2 +- tests/test_path.py | 19 +++++++++++-------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ansys/tools/path/__init__.py b/src/ansys/tools/path/__init__.py index f7ceebfd..49f26d96 100644 --- a/src/ansys/tools/path/__init__.py +++ b/src/ansys/tools/path/__init__.py @@ -14,9 +14,9 @@ from ansys.tools.path.path import ( SUPPORTED_ANSYS_VERSIONS, - find_ansys, change_default_ansys_path, - save_ansys_path, + find_ansys, get_ansys_path, get_available_ansys_installations, + save_ansys_path, ) diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py index c846780e..5a7e8627 100644 --- a/src/ansys/tools/path/path.py +++ b/src/ansys/tools/path/path.py @@ -1,10 +1,11 @@ +from glob import glob import logging as LOG # Temporal hack import os import re import warnings -from glob import glob import appdirs + from ansys.tools.path.misc import is_float LINUX_DEFAULT_DIRS = [["/", "usr", "ansys_inc"], ["/", "ansys_inc"]] @@ -395,6 +396,7 @@ def _prompt_ansys_path(): # pragma: no cover print("The supplied path is either: not a valid file path, or does not match 'ansysXXX' name.") return exe_loc + def warn_uncommon_executable_path(exe_loc): warnings.warn( f"The supplied path ('{exe_loc}') does not match the usual ansys executable path style" diff --git a/tests/test_misc.py b/tests/test_misc.py index b3d88b1b..9f0daa07 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,6 +1,6 @@ import pytest -from ansys.tools.path.misc import is_float +from ansys.tools.path.misc import is_float values = [ (11, True), diff --git a/tests/test_path.py b/tests/test_path.py index 114e3305..a0435819 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -1,15 +1,18 @@ import os import pytest + from ansys.tools.path import find_ansys -from ansys.tools.path.path import _version_from_path -from ansys.tools.path.path import change_default_ansys_path -from ansys.tools.path.path import CONFIG_FILE -from ansys.tools.path.path import get_ansys_path -from ansys.tools.path.path import get_available_ansys_installations -from ansys.tools.path.path import is_valid_executable_path -from ansys.tools.path.path import save_ansys_path -from ansys.tools.path.path import warn_uncommon_executable_path +from ansys.tools.path.path import ( + CONFIG_FILE, + _version_from_path, + change_default_ansys_path, + get_ansys_path, + get_available_ansys_installations, + is_valid_executable_path, + save_ansys_path, + warn_uncommon_executable_path, +) # , save_ansys_path, get_ansys_path, get_available_ansys_installations, check_valid_ansys From 4e869d8af677b5bfa528379af05db564df71c1d5 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 09:02:26 +0000 Subject: [PATCH 08/18] fixing cicd --- .github/workflows/ci_cd.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 56ff7809..5645948a 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -84,7 +84,7 @@ jobs: - name: Install library, with docs extra run: | pip install poetry - poetry install -E docs + poetry install .[doc] - name: Build HTML run: | diff --git a/pyproject.toml b/pyproject.toml index 863f22b3..7c69d475 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ [project.optional-dependencies] -tests = [ +test = [ "pytest==7.2.1", "pytest-cov==4.0.0", ] From ddb0a073954007aca8952ccd71b2cd93044e2808 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 09:07:34 +0000 Subject: [PATCH 09/18] adf --- .github/workflows/ci_cd.yml | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 5645948a..ca602ad1 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -24,12 +24,11 @@ jobs: - name: Install pre-commit requirements run: | - pip install poetry - poetry install -E pre-commit + pip install pre-commit - name: Run pre-commit run: | - poetry run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) + pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) main: name: Build and Testing @@ -83,32 +82,31 @@ jobs: - name: Install library, with docs extra run: | - pip install poetry - poetry install .[doc] + pip install .[doc] - name: Build HTML run: | - poetry run make -C doc html SPHINXOPTS="-W" + make -C doc html SPHINXOPTS="-W" - name: Build PDF Documentation run: | sudo apt update sudo apt-get install -y texlive-latex-extra latexmk - poetry run make -C doc latexpdf - - - name: Upload HTML Documentation - uses: actions/upload-artifact@v2 - with: - name: Documentation-html - path: doc/build/html - retention-days: 7 - - - name: Upload PDF Documentation - uses: actions/upload-artifact@v2 - with: - name: Documentation-pdf - path: doc/build/latex/*.pdf - retention-days: 7 + make -C doc latexpdf + + # - name: Upload HTML Documentation + # uses: actions/upload-artifact@v2 + # with: + # name: Documentation-html + # path: doc/build/html + # retention-days: 7 + + # - name: Upload PDF Documentation + # uses: actions/upload-artifact@v2 + # with: + # name: Documentation-pdf + # path: doc/build/latex/*.pdf + # retention-days: 7 Release: if: contains(github.ref, 'refs/tags') From f2312a324cf5dd16ad1f3b21f5781fc0a76ed147 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 09:23:24 +0000 Subject: [PATCH 10/18] precommit --- .github/workflows/ci_cd.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index ca602ad1..7c2177a5 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -33,6 +33,16 @@ jobs: main: name: Build and Testing runs-on: ubuntu-latest + timeout-minutes: 20 + container: + image: ghcr.io/pyansys/mapdl:v22.2-ubuntu + options: "-u=0:0 --entrypoint /bin/bash" + credentials: + username: ${{ secrets.BOT_APPLICATION_ID }} + password: ${{ secrets.GITHUB_TOKEN }} + env: + ON_LOCAL: true + ON_UBUNTU: true steps: - uses: actions/checkout@v2 @@ -88,11 +98,11 @@ jobs: run: | make -C doc html SPHINXOPTS="-W" - - name: Build PDF Documentation - run: | - sudo apt update - sudo apt-get install -y texlive-latex-extra latexmk - make -C doc latexpdf + # - name: Build PDF Documentation + # run: | + # sudo apt update + # sudo apt-get install -y texlive-latex-extra latexmk + # make -C doc latexpdf # - name: Upload HTML Documentation # uses: actions/upload-artifact@v2 From 14efb823c39caf5070cbde6732e7d3538b4ce3a3 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 09:25:57 +0000 Subject: [PATCH 11/18] fix precommit --- .pre-commit-config.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ecab9ed..994ad3d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,12 +10,6 @@ repos: - id: blacken-docs additional_dependencies: [black==23.1.0] -- repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 - hooks: - - id: reorder-python-imports - args: ["--py37-plus"] - - repo: https://github.com/PyCQA/flake8 rev: 6.0.0 hooks: From ae88fc0421ef08ace6935c54ea5e106918e856e5 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 09:44:48 +0000 Subject: [PATCH 12/18] using pybot token --- .github/workflows/ci_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 7c2177a5..de9e59dd 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -39,7 +39,7 @@ jobs: options: "-u=0:0 --entrypoint /bin/bash" credentials: username: ${{ secrets.BOT_APPLICATION_ID }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} env: ON_LOCAL: true ON_UBUNTU: true From 8208251ce33070b0bf420cdf7243fb3c880b8961 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 10:00:14 +0000 Subject: [PATCH 13/18] using github tocken --- .github/workflows/ci_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index de9e59dd..7c2177a5 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -39,7 +39,7 @@ jobs: options: "-u=0:0 --entrypoint /bin/bash" credentials: username: ${{ secrets.BOT_APPLICATION_ID }} - password: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} env: ON_LOCAL: true ON_UBUNTU: true From 6e67eaed495eb47f01cf3acc263346bf2d57e199 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 10:07:47 +0000 Subject: [PATCH 14/18] Using gh_username --- .github/workflows/ci_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 7c2177a5..5fad62e1 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -38,7 +38,7 @@ jobs: image: ghcr.io/pyansys/mapdl:v22.2-ubuntu options: "-u=0:0 --entrypoint /bin/bash" credentials: - username: ${{ secrets.BOT_APPLICATION_ID }} + username: ${{ secrets.GH_USERNAME }} password: ${{ secrets.GITHUB_TOKEN }} env: ON_LOCAL: true From 3a4d3e6e54e3f4d6d26777b7ca1388fe108b3747 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 10:11:26 +0000 Subject: [PATCH 15/18] Using my things --- .github/workflows/ci_cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 5fad62e1..dc37e186 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -38,8 +38,8 @@ jobs: image: ghcr.io/pyansys/mapdl:v22.2-ubuntu options: "-u=0:0 --entrypoint /bin/bash" credentials: - username: ${{ secrets.GH_USERNAME }} - password: ${{ secrets.GITHUB_TOKEN }} + username: germa89 + password: ${{ secrets.MY_TOKEN }} env: ON_LOCAL: true ON_UBUNTU: true From 0a9a525246a031595812359cc8595de6ea4c4cd8 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 10:36:17 +0000 Subject: [PATCH 16/18] Using my things... --- .github/workflows/ci_cd.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index dc37e186..bfa7f84b 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -38,36 +38,36 @@ jobs: image: ghcr.io/pyansys/mapdl:v22.2-ubuntu options: "-u=0:0 --entrypoint /bin/bash" credentials: - username: germa89 + username: ${{ secrets.GH_USERNAME }} password: ${{ secrets.MY_TOKEN }} env: ON_LOCAL: true ON_UBUNTU: true steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 - name: Create wheel run: | - pip install build + ptyhon pip install build python -m build --wheel - name: Validate wheel run: | - pip install twine + python pip install twine twine check dist/* - name: Install library, with test extra - run: pip install $(echo dist/*)[test] + run: python pip install $(echo dist/*)[test] - name: Unit testing run: | cd tests # so we're testing the install, not local - pytest -vx --cov=ansys.tools.path --cov-report=html + python pytest -vx --cov=ansys.tools.path --cov-report=html - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 From 1d125f0909ddf09feead81cc02028927a71e4897 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 10:42:05 +0000 Subject: [PATCH 17/18] Using my things... --- .github/workflows/ci_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index bfa7f84b..3a6ccf62 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -53,7 +53,7 @@ jobs: - name: Create wheel run: | - ptyhon pip install build + python pip install build python -m build --wheel - name: Validate wheel From a18b49e1b5b770f943877057278f9f27f3cc30bd Mon Sep 17 00:00:00 2001 From: German Date: Thu, 23 Feb 2023 10:47:07 +0000 Subject: [PATCH 18/18] Using my things... --- .github/workflows/ci_cd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 3a6ccf62..f0b0282b 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -53,21 +53,21 @@ jobs: - name: Create wheel run: | - python pip install build + python -m pip install build python -m build --wheel - name: Validate wheel run: | - python pip install twine - twine check dist/* + python -m pip install twine + python -m twine check dist/* - name: Install library, with test extra - run: python pip install $(echo dist/*)[test] + run: python -m pip install $(echo dist/*)[test] - name: Unit testing run: | cd tests # so we're testing the install, not local - python pytest -vx --cov=ansys.tools.path --cov-report=html + python -m pytest -vx --cov=ansys.tools.path --cov-report=html - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3