From 78a5ebc4c15ced17ad14efb2cd5a24be21702373 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Mon, 10 Feb 2025 19:32:22 +0300 Subject: [PATCH] fix: ram units (#3730) * fix: ram units * chore: adding changelog file 3730.fixed.md [dependabot-skip] --------- Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> --- doc/changelog.d/3730.fixed.md | 1 + src/ansys/mapdl/core/launcher.py | 6 +++--- tests/test_launcher.py | 12 ++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 doc/changelog.d/3730.fixed.md diff --git a/doc/changelog.d/3730.fixed.md b/doc/changelog.d/3730.fixed.md new file mode 100644 index 0000000000..c73767bc51 --- /dev/null +++ b/doc/changelog.d/3730.fixed.md @@ -0,0 +1 @@ +fix: ram units \ No newline at end of file diff --git a/src/ansys/mapdl/core/launcher.py b/src/ansys/mapdl/core/launcher.py index 23dc24633c..e03cd6496c 100644 --- a/src/ansys/mapdl/core/launcher.py +++ b/src/ansys/mapdl/core/launcher.py @@ -383,8 +383,8 @@ def generate_mapdl_launch_command( cpu_sw = "-np %d" % nproc if ram: - ram_sw = "-m %d" % int(1024 * ram) - LOG.debug(f"Setting RAM: {ram_sw}") + ram_sw = "-m %d" % int(ram) + LOG.debug(f"Setting RAM: {ram_sw} MB") else: ram_sw = "" @@ -1990,7 +1990,7 @@ def get_value( ram = SLURM_MEM_PER_NODE if not units: - args["ram"] = int(ram) + args["ram"] = int(ram) # Assuming in MB elif units == "T": # tera args["ram"] = int(ram) * (2**10) ** 2 elif units == "G": # giga diff --git a/tests/test_launcher.py b/tests/test_launcher.py index c1de62b542..7786601ee3 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -1002,7 +1002,7 @@ def test_generate_mapdl_launch_command_windows(): jobname = "myjob" nproc = 10 port = 1000 - ram = 2 + ram = 2024 additional_switches = "-my_add=switch" cmd = generate_mapdl_launch_command( @@ -1022,7 +1022,7 @@ def test_generate_mapdl_launch_command_windows(): assert "-port" in cmd assert f"{port}" in cmd assert "-m" in cmd - assert f"{ram*1024}" in cmd + assert f"{ram}" in cmd assert "-np" in cmd assert f"{nproc}" in cmd assert "-grpc" in cmd @@ -1037,7 +1037,7 @@ def test_generate_mapdl_launch_command_windows(): assert f"{exec_file}" in cmd assert f" -j {jobname} " in cmd assert f" -port {port} " in cmd - assert f" -m {ram*1024} " in cmd + assert f" -m {ram} " in cmd assert f" -np {nproc} " in cmd assert " -grpc" in cmd assert f" {additional_switches} " in cmd @@ -1053,7 +1053,7 @@ def test_generate_mapdl_launch_command_linux(): jobname = "myjob" nproc = 10 port = 1000 - ram = 2 + ram = 2024 additional_switches = "-my_add=switch" cmd = generate_mapdl_launch_command( @@ -1075,7 +1075,7 @@ def test_generate_mapdl_launch_command_linux(): assert "-port" in cmd assert f"{port}" in cmd assert "-m" in cmd - assert f"{ram*1024}" in cmd + assert f"{ram}" in cmd assert "-np" in cmd assert f"{nproc}" in cmd assert "-grpc" in cmd @@ -1091,7 +1091,7 @@ def test_generate_mapdl_launch_command_linux(): assert f"{exec_file} " in cmd assert f" -j {jobname} " in cmd assert f" -port {port} " in cmd - assert f" -m {ram*1024} " in cmd + assert f" -m {ram} " in cmd assert f" -np {nproc} " in cmd assert " -grpc" in cmd assert f" {additional_switches} " in cmd