diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 81afb69b51..739a29436b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,6 +78,6 @@ repos: # this validates our github workflow files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.29.4 + rev: 0.30.0 hooks: - id: check-github-workflows diff --git a/doc/changelog.d/3589.fixed.md b/doc/changelog.d/3589.fixed.md new file mode 100644 index 0000000000..bc7f39a54b --- /dev/null +++ b/doc/changelog.d/3589.fixed.md @@ -0,0 +1 @@ +fix: linkchecker and cheatsheet links \ No newline at end of file diff --git a/doc/changelog.d/3590.miscellaneous.md b/doc/changelog.d/3590.miscellaneous.md new file mode 100644 index 0000000000..913c469727 --- /dev/null +++ b/doc/changelog.d/3590.miscellaneous.md @@ -0,0 +1 @@ +feat: improving load_array to reduce format line length \ No newline at end of file diff --git a/doc/changelog.d/3593.dependencies.md b/doc/changelog.d/3593.dependencies.md new file mode 100644 index 0000000000..89ae38f55a --- /dev/null +++ b/doc/changelog.d/3593.dependencies.md @@ -0,0 +1 @@ +build: bump imageio from 2.36.0 to 2.36.1 in the documentation group \ No newline at end of file diff --git a/doc/changelog.d/3596.miscellaneous.md b/doc/changelog.d/3596.miscellaneous.md deleted file mode 100644 index c39f8cea4f..0000000000 --- a/doc/changelog.d/3596.miscellaneous.md +++ /dev/null @@ -1 +0,0 @@ -feat: redirect MAPDL console output to a file \ No newline at end of file diff --git a/doc/changelog.d/3599.maintenance.md b/doc/changelog.d/3599.maintenance.md new file mode 100644 index 0000000000..23264207b9 --- /dev/null +++ b/doc/changelog.d/3599.maintenance.md @@ -0,0 +1 @@ +ci: pre-commit autoupdate \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 235c3db45b..d6b87ea018 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -205,7 +205,7 @@ with open("links.rst") as f: rst_epilog += f.read() -rst_epilog = rst_epilog.replace("%%VERSION%%", "v231") +rst_epilog = rst_epilog.replace("%%VERSION%%", "v242") rst_epilog = rst_epilog.replace("%%PYMAPDLVERSION%%", release) @@ -219,8 +219,10 @@ linkcheck_ignore = [ "https://github.com/ansys/pymapdl/*", "https://mapdl.docs.pyansys.com/*", - "https://ansysaccount.b2clogin.com/*", # behind payfirewall - "https://ansyshelp.ansys.com/*", # behind payfirewall + "https://www.ansys.com/*", # behind firewall + "https://download.ansys.com/*", # behind firewall + "https://ansysaccount.b2clogin.com/*", # behind authentication + "https://ansyshelp.ansys.com/*", # behind authentication "https://forum.ansys.com/forums/*", # It is detected as broken "https://courses.ansys.com/*", # It is detected as broken ] @@ -239,7 +241,7 @@ f"https://github.com/ansys/pymapdl/releases/tag/v{__version__}" ) -user_agent = """curl https://www.ansys.com -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.3""" +user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.2420.81" # noqa: E501 # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" diff --git a/doc/source/getting_started/learning.rst b/doc/source/getting_started/learning.rst index 5ab22e88b3..4e11737715 100644 --- a/doc/source/getting_started/learning.rst +++ b/doc/source/getting_started/learning.rst @@ -40,7 +40,7 @@ Downloads .. jinja:: cheat_sheet - - View and download :download:`PyMAPDL cheatsheet ` + - View and download :download:`PyMAPDL cheatsheet ` to help you to learn PyMAPDL. - Visit :ref:`ref_examples` to learn how PyMAPDL can be used to solve different real problems. diff --git a/doc/source/getting_started/project.rst b/doc/source/getting_started/project.rst index 9bf7d7d202..e0d7a29554 100644 --- a/doc/source/getting_started/project.rst +++ b/doc/source/getting_started/project.rst @@ -174,8 +174,9 @@ In the upper right corner of the documentation's title bar, there is an option f viewing the documentation for the latest stable release to viewing the documentation for the development version or previously released versions. -You can also `download `_ the PyMAPDL cheat sheet. This one-page reference provides -syntax rules and commands for using PyMAPDL. +You can also download the +:download:`PyMAPDL cheat sheet `. +This one-page reference provides syntax rules and commands for using PyMAPDL. On the `PyMAPDL Issues `_ page, you can create issues to report bugs and request new features. On the `PyMAPDL Discussions diff --git a/pyproject.toml b/pyproject.toml index 981ba88736..adb4399bc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ doc = [ "ansys-tools-visualization-interface==0.5.0", "grpcio==1.68.0", "imageio-ffmpeg==0.5.1", - "imageio==2.36.0", + "imageio==2.36.1", "jupyter_sphinx==0.5.3", "jupyter==1.1.1", "jupyterlab>=3.2.8", diff --git a/src/ansys/mapdl/core/launcher.py b/src/ansys/mapdl/core/launcher.py index 83b4dc9ce9..650ba4a252 100644 --- a/src/ansys/mapdl/core/launcher.py +++ b/src/ansys/mapdl/core/launcher.py @@ -35,7 +35,7 @@ import subprocess # nosec B404 import threading import time -from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union +from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union import warnings import psutil @@ -115,7 +115,6 @@ def version_from_path(*args, **kwargs): "license_type", "log_apdl", "loglevel", - "mapdl_output", "mode", "nproc", "override", @@ -438,7 +437,6 @@ def launch_grpc( run_location: str = None, env_vars: Optional[Dict[str, str]] = None, launch_on_hpc: bool = False, - mapdl_output: Optional[str] = None, ) -> subprocess.Popen: """Start MAPDL locally in gRPC mode. @@ -458,9 +456,6 @@ def launch_grpc( If running on an HPC, this needs to be :class:`True` to avoid the temporary file creation on Windows. - mapdl_output : str, optional - Whether redirect MAPDL console output (stdout and stderr) to a file. - Returns ------- subprocess.Popen @@ -492,13 +487,6 @@ def launch_grpc( "\n============" ) - if mapdl_output: - stdout = open(str(mapdl_output), "wb", 0) - stderr = subprocess.STDOUT - else: - stdout = subprocess.PIPE - stderr = subprocess.PIPE - if os.name == "nt": # getting tmp file name if not launch_on_hpc: @@ -517,8 +505,8 @@ def launch_grpc( shell=shell, # sbatch does not work without shell. cwd=run_location, stdin=subprocess.DEVNULL, - stdout=stdout, - stderr=stderr, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, env_vars=env_vars, ) @@ -566,7 +554,7 @@ def check_mapdl_launch( if os.name == "posix" and not ON_WSL: LOG.debug("Checking if gRPC server is alive.") - _check_server_is_alive(stdout_queue, timeout) + _check_server_is_alive(stdout_queue, run_location, timeout) except MapdlDidNotStart as e: # pragma: no cover msg = ( @@ -608,11 +596,7 @@ def _check_file_error_created(run_location, timeout): raise MapdlDidNotStart(msg) -def _check_server_is_alive(stdout_queue, timeout): - if not stdout_queue: - LOG.debug("No STDOUT queue. Not checking MAPDL this way.") - return - +def _check_server_is_alive(stdout_queue, run_location, timeout): t0 = time.time() empty_attemps = 3 empty_i = 0 @@ -645,9 +629,6 @@ def _check_server_is_alive(stdout_queue, timeout): def _get_std_output(std_queue, timeout=1): - if not std_queue: - return [None] - lines = [] reach_empty = False t0 = time.time() @@ -661,15 +642,10 @@ def _get_std_output(std_queue, timeout=1): return lines -def _create_queue_for_std( - std: subprocess.PIPE, -) -> Tuple[Optional[Queue[str]], Optional[threading.Thread]]: +def _create_queue_for_std(std): """Create a queue and thread objects for a given PIPE std""" - if not std: - LOG.debug("No STDOUT. Not checking MAPDL this way.") - return None, None - def enqueue_output(out: subprocess.PIPE, queue: Queue[str]) -> None: + def enqueue_output(out, queue): try: for line in iter(out.readline, b""): queue.put(line) @@ -679,8 +655,8 @@ def enqueue_output(out: subprocess.PIPE, queue: Queue[str]) -> None: # ValueError: PyMemoryView_FromBuffer(): info -> buf must not be NULL pass - q: Queue[str] = Queue() - t: threading.Thread = threading.Thread(target=enqueue_output, args=(std, q)) + q = Queue() + t = threading.Thread(target=enqueue_output, args=(std, q)) t.daemon = True # thread dies with the program t.start() @@ -688,7 +664,7 @@ def enqueue_output(out: subprocess.PIPE, queue: Queue[str]) -> None: def launch_remote_mapdl( - version: Optional[str] = None, + version: str = None, cleanup_on_exit: bool = True, ) -> MapdlGrpc: """Start MAPDL remotely using the product instance management API. @@ -1044,7 +1020,6 @@ def launch_mapdl( version: Optional[Union[int, str]] = None, running_on_hpc: bool = True, launch_on_hpc: bool = False, - mapdl_output: Optional[str] = None, **kwargs: Dict[str, Any], ) -> Union[MapdlGrpc, "MapdlConsole"]: """Start MAPDL locally. @@ -1230,9 +1205,6 @@ def launch_mapdl( to specify the scheduler arguments as a string or as a dictionary. For more information, see :ref:`ref_hpc_slurm`. - mapdl_output : str, optional - Redirect the MAPDL console output to a given file. - kwargs : dict, Optional These keyword arguments are interface-specific or for development purposes. For more information, see Notes. @@ -1603,7 +1575,6 @@ def launch_mapdl( run_location=args["run_location"], env_vars=env_vars, launch_on_hpc=args.get("launch_on_hpc"), - mapdl_output=args.get("mapdl_output"), ) if args["launch_on_hpc"]: diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 94f2808fd4..a12ba23392 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -2314,7 +2314,7 @@ def load_array(self, name, array): np.savetxt( filename, array, - delimiter=",", + delimiter="", header="File generated by PyMAPDL:load_array", fmt="%24.18e", ) @@ -2329,7 +2329,7 @@ def load_array(self, name, array): n2 = imax n3 = kmax self.vread(name, filename, n1=n1, n2=n2, n3=n3, label=label, nskip=1) - fmt = "(" + ",',',".join(["E24.18" for i in range(jmax)]) + ")" + fmt = f"({jmax}E24.18)" logger.info("Using *VREAD with format %s in %s", fmt, filename) self.run(fmt) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index a3fe1caa54..a15982ce12 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -650,7 +650,7 @@ def _read_stds(self): _get_std_output, # Avoid circular import error ) - if self._mapdl_process is None or not self._mapdl_process.stdout: + if self._mapdl_process is None: return self._log.debug("Reading stdout") @@ -2691,7 +2691,7 @@ def _download_as_raw(self, target_name: str) -> str: @property def is_alive(self) -> bool: """True when there is an active connect to the gRPC server""" - if self.channel_state not in ["IDLE", "READY", None]: + if self.channel_state not in ["IDLE", "READY"]: self._log.debug( "MAPDL instance is not alive because the channel is not 'IDLE' o 'READY'." ) diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 764d838250..806676eb7c 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -1977,4 +1977,4 @@ def submitter(**kwargs): assert "### START GRPC SERVER ###" in content assert " Server listening on" in content - mapdl.exit() + mapdl.exit(force=True) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index fa6cda4de6..417c6389cd 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -134,11 +134,20 @@ def test__get_parameter_array(mapdl, cleared, number): assert np.allclose(array, mapdl.parameters._get_parameter_array(name, shape)) # High number - with pytest.raises(MapdlRuntimeError): - shape = (100, 100) - array = np.ones(shape) * number - mapdl.load_array(name=name, array=array) - mapdl.parameters._get_parameter_array(name, shape) + shape = (100, 100) + array = np.ones(shape) * number + mapdl.load_array(name=name, array=array) + assert np.allclose(array, mapdl.parameters._get_parameter_array(name, shape)) + + # Random number + array = np.random.rand(*shape) + mapdl.load_array(name=name, array=array) + assert np.allclose(array, mapdl.parameters._get_parameter_array(name, shape)) + + # Random big number + array = np.random.rand(*shape) * number + mapdl.load_array(name=name, array=array) + assert np.allclose(array, mapdl.parameters._get_parameter_array(name, shape)) def parameters_name(mapdl, func, par_name):