Skip to content

Commit

Permalink
replace pyfluent.EXAMPLES_PATH with os.getcwd()
Browse files Browse the repository at this point in the history
  • Loading branch information
hpohekar committed May 29, 2024
1 parent 7cb469c commit b54363f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
5 changes: 2 additions & 3 deletions src/ansys/fluent/core/systemcoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import List
import xml.etree.ElementTree as XmlET

import ansys.fluent.core as pyfluent
from ansys.fluent.core.utils.fluent_version import FluentVersion


Expand Down Expand Up @@ -97,9 +96,9 @@ def get_scp_string() -> str:
elif self._solver.connection_properties.inside_container:
# Right now, the way that PyFluent containers and tests are set up,
# the local Fluent container working directory will correspond to
# pyfluent.EXAMPLES_PATH in the host, so that is where the SCP file
# os.getcwd() in the host, so that is where the SCP file
# will be written.
examples_path_scp = os.path.join(pyfluent.EXAMPLES_PATH, scp_file_name)
examples_path_scp = os.path.join(os.getcwd(), scp_file_name)
if os.path.exists(examples_path_scp):
scp_file_name = examples_path_scp

Expand Down
3 changes: 1 addition & 2 deletions src/ansys/fluent/core/utils/data_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pathlib import Path, PurePosixPath
from typing import Optional

import ansys.fluent.core as pyfluent
from ansys.fluent.core.launcher.fluent_container import DEFAULT_CONTAINER_MOUNT_PATH
from ansys.fluent.core.utils.execution import asynchronous

Expand Down Expand Up @@ -93,7 +92,7 @@ def transfer_case(
"""
inside_container = source_instance.connection_properties.inside_container
if not workdir:
workdir = Path(pyfluent.EXAMPLES_PATH)
workdir = Path(os.getcwd())
else:
workdir = Path(workdir)
if inside_container:
Expand Down
4 changes: 2 additions & 2 deletions tests/parametric/test_parametric_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def pytest_approx(expected):
@pytest.mark.fluent_version("latest")
def test_parametric_workflow():
# parent path needs to exist for mkdtemp
Path(pyfluent.EXAMPLES_PATH).mkdir(parents=True, exist_ok=True)
tmp_save_path = tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH)
Path(os.getcwd()).mkdir(parents=True, exist_ok=True)
tmp_save_path = tempfile.mkdtemp(dir=os.getcwd())
if pyfluent.USE_FILE_TRANSFER_SERVICE:
file_transfer_service = RemoteFileTransferStrategy(
host_mount_path=tmp_save_path
Expand Down
4 changes: 2 additions & 2 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def test_journal_creation(file_format, new_mesh_session):
fd, file_name = tempfile.mkstemp(
suffix=f"-{os.getpid()}.{file_format}",
prefix="pyfluent-",
dir=str(pyfluent.EXAMPLES_PATH),
dir=str(os.getcwd()),
)
os.close(fd)

Expand Down Expand Up @@ -321,7 +321,7 @@ def test_start_transcript_file_write(new_mesh_session):
fd, file_name = tempfile.mkstemp(
suffix=f"-{os.getpid()}.trn",
prefix="pyfluent-",
dir=str(pyfluent.EXAMPLES_PATH),
dir=str(os.getcwd()),
)
os.close(fd)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_solvermode/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

import pytest

import ansys.fluent.core as pyfluent


@pytest.mark.settings_only
@pytest.mark.fluent_version("latest")
def test_solver_import_mixingelbow(load_mixing_elbow_settings_only):
solver_session = load_mixing_elbow_settings_only
assert solver_session.settings.is_active()
assert solver_session.health_check.is_serving
file_name = Path(pyfluent.EXAMPLES_PATH) / "jou_test_general.py"
file_name = Path(os.getcwd()) / "jou_test_general.py"
solver_session.journal.start(file_name.as_posix())
###
assert solver_session.setup.models.energy.enabled()
Expand Down
12 changes: 6 additions & 6 deletions tests/test_topy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
def test_single_jou():
file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou")
file_name = os.path.join(os.getcwd(), "jou1.jou")

with open(file_name, "w") as journal:
journal.write('(display "from jou1.jou")')
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_single_jou():

@pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
def test_single_scm():
file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm")
file_name = os.path.join(os.getcwd(), "jou1.scm")

with open(file_name, "w") as journal:
journal.write('(display "from jou1.scm")')
Expand Down Expand Up @@ -77,8 +77,8 @@ def test_single_scm():

@pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
def test_2_jou():
file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou")
file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.jou")
file_name_1 = os.path.join(os.getcwd(), "jou1.jou")
file_name_2 = os.path.join(os.getcwd(), "jou2.jou")

with open(file_name_1, "w") as journal:
journal.write('(display "from jou1.jou")')
Expand Down Expand Up @@ -129,8 +129,8 @@ def test_2_jou():

@pytest.mark.skip(reason="Unable to read generated python journal from fluent.")
def test_2_scm():
file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm")
file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.scm")
file_name_1 = os.path.join(os.getcwd(), "jou1.scm")
file_name_2 = os.path.join(os.getcwd(), "jou2.scm")

with open(file_name_1, "w") as journal:
journal.write('(display "from jou1.scm")')
Expand Down

0 comments on commit b54363f

Please sign in to comment.