Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecating verbose #2669

Merged
merged 7 commits into from
Jan 19, 2024
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
37 changes: 17 additions & 20 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ def launch_grpc(
``False``.
.. deprecated:: v0.65.0
The ``verbose`` argument is deprecated and will be removed in a future release.
The ``verbose`` argument is deprecated and will be completely
removed in a future release.
Use a logger instead. See :ref:`api_logging` for more details.
kwargs : dict
Expand Down Expand Up @@ -474,14 +475,11 @@ def launch_grpc(
# disable all MAPDL pop-up errors:
os.environ["ANS_CMD_NODIAG"] = "TRUE"

if verbose is not None:
warnings.warn(
"The ``verbose`` argument is deprecated and will be removed in a future release. "
"Use a logger instead. See :ref:`api_logging` for more details.",
DeprecationWarning,
if verbose:
raise DeprecationError(
"The ``verbose`` argument is deprecated and will be completely removed in a future release. Use a logger instead. "
"See https://mapdl.docs.pyansys.com/version/stable/api/logging.html for more details."
)
elif verbose is None:
verbose = False

# use temporary directory if run_location is unspecified
if run_location is None:
Expand Down Expand Up @@ -600,9 +598,6 @@ def launch_grpc(

LOG.info(f"Running in {ip}:{port} the following command: '{command}'")

if verbose:
print(command)

LOG.debug("MAPDL starting in background.")
process = subprocess.Popen(
command,
Expand All @@ -629,8 +624,12 @@ def launch_grpc(
LOG.debug("Checking if gRPC server is alive.")
_check_server_is_alive(stdout_queue, run_location, timeout)

except MapdlDidNotStart as e:
msg = str(e) + f"\nRun location: {run_location}" + f"\nCommand line used: {cmd}"
except MapdlDidNotStart as e: # pragma: no cover
msg = (
str(e)
+ f"\nRun location: {run_location}"
+ f"\nCommand line used: {command}\n\n"
)

terminal_output = "\n".join(_get_std_output(std_queue=stdout_queue)).strip()
if terminal_output.strip():
Expand Down Expand Up @@ -1198,7 +1197,8 @@ def launch_mapdl(
be tracked within pymapdl. Default ``False``.
.. deprecated:: v0.65.0
The ``verbose_mapdl`` argument is deprecated and will be removed in a future release.
The ``verbose_mapdl`` argument is deprecated and will be completely
removed in a future release.
Use a logger instead. See :ref:`api_logging` for more details.
license_server_check : bool, optional
Expand Down Expand Up @@ -1428,12 +1428,10 @@ def launch_mapdl(
remove_temp_files = None

if verbose_mapdl is not None:
warnings.warn(
"The ``verbose_mapdl`` argument is deprecated and will be removed in a future release. "
"Use a logger instead. See :ref:`api_logging` for more details.",
DeprecationWarning,
raise DeprecationError(
"The ``verbose_mapdl`` argument is deprecated and will be completely removed in a future release. Use a logger instead. "
"See https://mapdl.docs.pyansys.com/version/stable/api/logging.html for more details."
)
verbose_mapdl = False

# These parameters are partially used for unit testing
set_no_abort = kwargs.pop("set_no_abort", True)
Expand Down Expand Up @@ -1729,7 +1727,6 @@ def launch_mapdl(
ip=ip,
add_env_vars=add_env_vars,
replace_env_vars=replace_env_vars,
verbose=verbose_mapdl,
**start_parm,
)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from ansys.mapdl import core as pymapdl
from ansys.mapdl.core.errors import (
DeprecationError,
LicenseServerConnectionError,
MapdlDidNotStart,
NotEnoughResources,
Expand All @@ -43,6 +44,7 @@
_parse_ip_route,
_validate_MPI,
_verify_version,
launch_grpc,
launch_mapdl,
update_env_vars,
)
Expand Down Expand Up @@ -538,3 +540,14 @@ def test_fail_channel_port():
def test_fail_channel_ip():
with pytest.raises(ValueError):
launch_mapdl(channel="something", ip="something")


def test_deprecate_verbose():
with pytest.raises(DeprecationError):
launch_mapdl(verbose_mapdl=True)

with pytest.raises(ValueError):
launch_mapdl(verbose=True)

with pytest.raises(DeprecationError):
launch_grpc(verbose=True)
Loading