Skip to content

Commit cb2b78e

Browse files
committed
fix: codacity suggestions
1 parent f6bb7f8 commit cb2b78e

File tree

9 files changed

+29
-18
lines changed

9 files changed

+29
-18
lines changed

src/ansys/mapdl/core/launcher/console.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from typing import Optional, Union
2424

25+
from ansys.mapdl.core import LOG
26+
from ansys.mapdl.core.launcher.local import processing_local_arguments
2527
from ansys.mapdl.core.launcher.tools import generate_start_parameters
2628
from ansys.mapdl.core.licensing import LicenseChecker
2729
from ansys.mapdl.core.mapdl_console import MapdlConsole

src/ansys/mapdl/core/launcher/grpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from ansys.mapdl.core import LOG
3131
from ansys.mapdl.core.launcher.local import processing_local_arguments
3232
from ansys.mapdl.core.launcher.tools import (
33+
check_mapdl_launch,
34+
generate_mapdl_launch_command,
3335
generate_start_parameters,
3436
get_port,
3537
submitter,
@@ -88,8 +90,6 @@ def launch_mapdl_grpc():
8890
except Exception as exception:
8991
LOG.error("An error occurred when launching MAPDL.")
9092

91-
jobid: int = start_parm.get("jobid", "Not found")
92-
9393
if args["license_server_check"]:
9494
LOG.debug("Checking license server.")
9595
lic_check.check()

src/ansys/mapdl/core/launcher/hpc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@
2222

2323
import os
2424
import socket
25-
import subprocess
25+
import subprocess # nosec B404
2626
import time
2727
from typing import Any, Callable, Dict, List, Optional, Union
2828

2929
from ansys.mapdl.core import LOG
3030
from ansys.mapdl.core.errors import MapdlDidNotStart
3131
from ansys.mapdl.core.launcher.grpc import launch_grpc
32-
from ansys.mapdl.core.launcher.tools import submitter
32+
from ansys.mapdl.core.launcher.local import processing_local_arguments
33+
from ansys.mapdl.core.launcher.tools import (
34+
generate_start_parameters,
35+
get_port,
36+
submitter,
37+
)
38+
from ansys.mapdl.core.licensing import LicenseChecker
3339
from ansys.mapdl.core.mapdl_grpc import MapdlGrpc
3440

3541
LAUNCH_ON_HCP_ERROR_MESSAGE_IP = (
@@ -328,7 +334,7 @@ def launch_mapdl_on_cluster(
328334
)
329335

330336

331-
def launch_mapdl_grpc():
337+
def launch_mapdl_grpc(): # to be fixed
332338
args = processing_local_arguments(locals())
333339
if args.get("mode", "grpc") != "grpc":
334340
raise ValueError("Invalid 'mode'.")

src/ansys/mapdl/core/launcher/local.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# SOFTWARE.
2222

2323
"""Launch MAPDL locally"""
24+
25+
from ansys.mapdl.core import LOG
2426
from ansys.mapdl.core.launcher.tools import (
2527
check_kwargs,
2628
check_lock_file,
@@ -72,9 +74,7 @@ def processing_local_arguments(args):
7274
args["license_type"], args["additional_switches"]
7375
)
7476

75-
env_vars: Dict[str, str] = update_env_vars(
76-
args["add_env_vars"], args["replace_env_vars"]
77-
)
77+
args["env_vars"] = update_env_vars(args["add_env_vars"], args["replace_env_vars"])
7878

7979
get_run_location(args)
8080

@@ -91,7 +91,7 @@ def processing_local_arguments(args):
9191
# ON HPC:
9292
# Assuming that if login node is ubuntu, the computation ones
9393
# are also ubuntu.
94-
env_vars = configure_ubuntu(env_vars)
94+
args["env_vars"] = configure_ubuntu(args["env_vars"])
9595

9696
# Set SMP by default if student version is used.
9797
args["additional_switches"] = force_smp_in_student(
@@ -108,7 +108,7 @@ def processing_local_arguments(args):
108108
LOG.debug(f"Using additional switches {args['additional_switches']}.")
109109

110110
if args["running_on_hpc"] or args["launch_on_hpc"]:
111-
env_vars.setdefault("ANS_MULTIPLE_NODES", "1")
112-
env_vars.setdefault("HYDRA_BOOTSTRAP", "slurm")
111+
args["env_vars"].setdefault("ANS_MULTIPLE_NODES", "1")
112+
args["env_vars"].setdefault("HYDRA_BOOTSTRAP", "slurm")
113113

114114
return args

src/ansys/mapdl/core/launcher/remote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from typing import Any, Dict, Optional, Union
2424

25+
from ansys.mapdl.core import LOG
2526
from ansys.mapdl.core.launcher.tools import (
2627
check_kwargs,
2728
generate_start_parameters,

src/ansys/mapdl/core/launcher/tools.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from queue import Empty, Queue
2626
import re
2727
import socket
28-
import subprocess
28+
import subprocess # nosec B404
2929
import threading
3030
import time
3131
from typing import Any, Dict, List, Optional, Tuple, Union
@@ -450,6 +450,8 @@ def create_gallery_instances(
450450
# launch an instance of pymapdl if it does not already exist and
451451
# we're allowed to start instances
452452
if GALLERY_INSTANCE[0] is None:
453+
from ansys.mapdl.core.launcher import launch_mapdl
454+
453455
LOG.debug("Loading first MAPDL instance for gallery building.")
454456
GALLERY_INSTANCE[0] = "Loading..."
455457
mapdl = launch_mapdl(
@@ -832,7 +834,7 @@ def check_mapdl_launch(
832834
MAPDL did not start.
833835
"""
834836
LOG.debug("Generating queue object for stdout")
835-
stdout_queue, thread = _create_queue_for_std(process.stdout)
837+
stdout_queue, _ = _create_queue_for_std(process.stdout)
836838

837839
# Checking connection
838840
try:

tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"""Shared testing module"""
2424
from collections import namedtuple
2525
import os
26-
import subprocess
26+
import subprocess # nosec B404
2727
import time
2828
from typing import Dict, List
2929

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# SOFTWARE.
2222

2323
import re
24-
import subprocess
24+
import subprocess # nosec B404
2525

2626
import psutil
2727
import pytest

tests/test_launcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"""Test the mapdl launcher"""
2424

2525
import os
26-
import subprocess
26+
import subprocess # nosec B404
2727
import tempfile
2828
from time import sleep
2929
from unittest.mock import patch
@@ -1738,7 +1738,7 @@ def fake_proc(*args, **kwargs):
17381738
time_to_stop,
17391739
)
17401740

1741-
with patch("ansys.mapdl.core.launcher.hpc.send_scontrol", fake_proc) as mck_sc:
1741+
with patch("ansys.mapdl.core.launcher.hpc.send_scontrol", fake_proc):
17421742

17431743
if raises:
17441744
context = pytest.raises(raises)
@@ -2045,7 +2045,7 @@ def submitter(*args, **kwargs):
20452045

20462046
return
20472047

2048-
with patch("ansys.mapdl.core.launcher.tools.submitter", submitter) as mck_sub:
2048+
with patch("ansys.mapdl.core.launcher.tools.submitter", submitter):
20492049
mapdl_output = os.path.join(tmpdir, "apdl.txt")
20502050
args = launch_mapdl(just_launch=True, mapdl_output=mapdl_output)
20512051

0 commit comments

Comments
 (0)