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

CHORE: Helper python file no longer needed #1052

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Merge branch 'main' of https://github.com/ansys/pymechanical into mai…
…nt/update-remote-list-files
dipinknair committed Jan 31, 2025
commit a3dfef39d9a1dfae9309b2d4c9f0213f7af8a3d0
2 changes: 1 addition & 1 deletion src/ansys/mechanical/core/mechanical.py
Original file line number Diff line number Diff line change
@@ -460,8 +460,8 @@ def __init__(

# connect and validate to the channel
self._multi_connect(timeout=timeout)

self.log_info("Mechanical is ready to accept grpc calls.")
self._rpc_type = "grpc"

def __del__(self): # pragma: no cover
"""Clean up on exit."""

Unchanged files with check annotations Beta

.. _ref_embedding_user_guide_addin_configuration:
Addin configuration

Check warning on line 3 in doc/source/user_guide_embedding/configuration.rst

GitHub Actions / vale

[vale] doc/source/user_guide_embedding/configuration.rst#L3

[Google.Headings] 'Addin configuration' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'Addin configuration' should use sentence-style capitalization.", "location": {"path": "doc/source/user_guide_embedding/configuration.rst", "range": {"start": {"line": 3, "column": 1}}}, "severity": "WARNING"}
===================
There are some configuration options that are respected when loading an embedded instance
Known issues and limitations
----------------------------
We suggest to use latest stable version of PyMechanical.

Check warning on line 9 in doc/source/kil/pymechanical.rst

GitHub Actions / vale

[vale] doc/source/kil/pymechanical.rst#L9

[Google.We] Try to avoid using first-person plural like 'We'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "doc/source/kil/pymechanical.rst", "range": {"start": {"line": 9, "column": 1}}}, "severity": "WARNING"}
Any issues and limitations for previous versions are not currently documented.
If you find any other, please create an issue `here <pymechanical_issue_>`_
v0.11.x

Check warning on line 13 in doc/source/kil/pymechanical.rst

GitHub Actions / vale

[vale] doc/source/kil/pymechanical.rst#L13

[Google.Headings] 'v0.11.x' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'v0.11.x' should use sentence-style capitalization.", "location": {"path": "doc/source/kil/pymechanical.rst", "range": {"start": {"line": 13, "column": 1}}}, "severity": "WARNING"}
^^^^^^^^
- ``App.plot()`` visualization feature is available only for geometry. You cannot plot mesh or results
Known issues and limitations
----------------------------
24R2

Check warning on line 15 in doc/source/kil/mechanical.rst

GitHub Actions / vale

[vale] doc/source/kil/mechanical.rst#L15

[Google.Headings] '24R2' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] '24R2' should use sentence-style capitalization.", "location": {"path": "doc/source/kil/mechanical.rst", "range": {"start": {"line": 15, "column": 1}}}, "severity": "WARNING"}
^^^^
- In Read Only mode, the application does not display error messages when the geometry is imported in batch mode.
- A fatal error currently exists when you are shutting down Mechanical on the
Linux platform using Embedding (`#85 <https://github.com/ansys/pymechanical/issues/85>`_).
24R1

Check warning on line 26 in doc/source/kil/mechanical.rst

GitHub Actions / vale

[vale] doc/source/kil/mechanical.rst#L26

[Google.Headings] '24R1' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] '24R1' should use sentence-style capitalization.", "location": {"path": "doc/source/kil/mechanical.rst", "range": {"start": {"line": 26, "column": 1}}}, "severity": "WARNING"}
^^^^
- `Python libraries <https://mechanical.docs.pyansys.com/version/stable/user_guide_embedding/libraries.html>`_
=======
If you encounter any issues or limitations with PyMechanical that hinder your work, please create
an issue or discussion so our team can address them promptly:

Check warning on line 40 in doc/source/kil/index.rst

GitHub Actions / vale

[vale] doc/source/kil/index.rst#L40

[Google.We] Try to avoid using first-person plural like 'our'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "doc/source/kil/index.rst", "range": {"start": {"line": 40, "column": 27}}}, "severity": "WARNING"}
* `PyMechanical Issues <https://github.com/ansys/pymechanical/issues>`_: Report bugs and request new features.
* `PyMechanical Discussions <https://github.com/ansys/pymechanical/discussions>`_: Post questions, share ideas, and get community feedback.
print("files available: ")
for file in files:
print(file)
assert number_of_files > 0

Check failure on line 227 in tests/test_mechanical.py

GitHub Actions / Remote Connect Test Report 3.13

test_mechanical.test_upload_attach_mesh_solve_use_api_non_distributed_solve

assert 0 > 0
Raw output
mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_upload_attach_mesh_solve_0')

    @pytest.mark.remote_session_connect
    # @pytest.mark.wip
    # @pytest.mark.skip(reason="avoid long running")
    def test_upload_attach_mesh_solve_use_api_non_distributed_solve(mechanical, tmpdir):
        # default is distributed solve
        # let's disable the distributed solve and then solve
        # enable the distributed solve back
    
        # this test could run under a container with 1 cpu
        # let us disable distributed solve
        disable_distributed_solve(mechanical)
    
        result = solve_and_return_results(mechanical)
    
        # revert back to distributed solve
        enable_distributed_solve(mechanical)
    
        dict_result = json.loads(result)
    
        min_value = float(dict_result["Minimum"].split(" ")[0])
        max_value = float(dict_result["Maximum"].split(" ")[0])
        avg_value = float(dict_result["Average"].split(" ")[0])
    
        print(f"min_value = {min_value} max_value = {max_value} avg_value = {avg_value}")
    
        result = mechanical.run_python_script("ExtAPI.DataModel.Project.Model.Analyses[0].ObjectState")
        # TODO: Investigate why the result is different for grpc
        if mechanical._rpc_type == "grpc":
            assert "5" == result
        else:
            assert "Solved" == str(result)
    
>       verify_project_download(mechanical, tmpdir)

tests/test_mechanical.py:305: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_upload_attach_mesh_solve_0')

    def verify_project_download(mechanical, tmpdir):
        files = mechanical.list_files()
        number_of_files = len(files)
    
        print("files available: ")
        for file in files:
            print(file)
>       assert number_of_files > 0
E       assert 0 > 0

tests/test_mechanical.py:227: AssertionError

Check failure on line 227 in tests/test_mechanical.py

GitHub Actions / Remote Connect Test Report 3.13

test_mechanical.test_upload_attach_mesh_solve_use_api_distributed_solve

assert 0 > 0
Raw output
mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_upload_attach_mesh_solve_1')

    @pytest.mark.remote_session_connect
    def test_upload_attach_mesh_solve_use_api_distributed_solve(mechanical, tmpdir):
        result = solve_and_return_results(mechanical)
    
        dict_result = json.loads(result)
    
        min_value = float(dict_result["Minimum"].split(" ")[0])
        max_value = float(dict_result["Maximum"].split(" ")[0])
        avg_value = float(dict_result["Average"].split(" ")[0])
    
        print(f"min_value = {min_value} max_value = {max_value} avg_value = {avg_value}")
    
        result = mechanical.run_python_script("ExtAPI.DataModel.Project.Model.Analyses[0].ObjectState")
        if mechanical._rpc_type == "grpc":
            assert "5" == result
        else:
            assert "Solved" == str(result)
    
>       verify_project_download(mechanical, tmpdir)

tests/test_mechanical.py:326: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_upload_attach_mesh_solve_1')

    def verify_project_download(mechanical, tmpdir):
        files = mechanical.list_files()
        number_of_files = len(files)
    
        print("files available: ")
        for file in files:
            print(file)
>       assert number_of_files > 0
E       assert 0 > 0

tests/test_mechanical.py:227: AssertionError
# download the project
project_directory = mechanical.project_directory
local_directory = tmpdir.strpath
# test with different download chunk_size
local_path_list = mechanical.download(

Check failure on line 344 in tests/test_mechanical.py

GitHub Actions / Remote Connect Test Report 3.13

test_mechanical.test_download_file[hsec.x_t]

ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.
Raw output
mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_download_file_hsec_x_t_0')
file_name = 'hsec.x_t'

    @pytest.mark.remote_session_connect
    @pytest.mark.parametrize("file_name", ["hsec.x_t"])
    def test_download_file(mechanical, tmpdir, file_name):
>       verify_download(mechanical, tmpdir, file_name, 1024 * 1024)

tests/test_mechanical.py:356: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_mechanical.py:344: in verify_download
    local_path_list = mechanical.download(
.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1419: in download
    list_files = self._get_files(files, recursive=recursive)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

files = '/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t'
recursive = False

    def _get_files(self, files, recursive=False):
        self_files = self.list_files()  # to avoid calling it too much
    
        if isinstance(files, str):
            if self._local:  # pragma: no cover
                # in local mode
                if os.path.exists(files):
                    if not os.path.isabs(files):
                        list_files = [os.path.join(os.getcwd(), files)]
                    else:
                        # file exist
                        list_files = [files]
                elif "*" in files:
                    # using filter
                    list_files = glob.glob(files, recursive=recursive)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the local client."
                        )
                else:
                    raise ValueError(
                        f"The files parameter ('{files}') does not match any file or pattern."
                    )
            else:  # Remote or looking into Mechanical working directory
                if files in self_files:
                    list_files = [files]
                elif "*" in files:
                    # try filter on the list_files
                    if recursive:
                        self.log_warning(
                            "Because the 'recursive' keyword argument does not work with "
                            "remote instances, it is ignored."
                        )
                    list_files = fnmatch.filter(self_files, files)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the remote server."
                        )
                else:
>                   raise ValueError(
                        f"The `'files'` parameter ('{files}') does not match any file or pattern."
                    )
E                   ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.

.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1322: ValueError

Check failure on line 344 in tests/test_mechanical.py

GitHub Actions / Remote Connect Test Report 3.13

test_mechanical.test_download_file_different_chunk_size1[10]

ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.
Raw output
mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_download_file_different_c0')
chunk_size = 10

    @pytest.mark.remote_session_connect
    # we are using only a small test file
    # change the chunk_size for that
    # ideally this will be 64*1024, 1024*1024, etc.
    @pytest.mark.parametrize("chunk_size", [10, 50, 100])
    def test_download_file_different_chunk_size1(mechanical, tmpdir, chunk_size):
        file_name = "hsec.x_t"
    
>       verify_download(mechanical, tmpdir, file_name, chunk_size)

tests/test_mechanical.py:367: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_mechanical.py:344: in verify_download
    local_path_list = mechanical.download(
.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1419: in download
    list_files = self._get_files(files, recursive=recursive)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

files = '/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t'
recursive = False

    def _get_files(self, files, recursive=False):
        self_files = self.list_files()  # to avoid calling it too much
    
        if isinstance(files, str):
            if self._local:  # pragma: no cover
                # in local mode
                if os.path.exists(files):
                    if not os.path.isabs(files):
                        list_files = [os.path.join(os.getcwd(), files)]
                    else:
                        # file exist
                        list_files = [files]
                elif "*" in files:
                    # using filter
                    list_files = glob.glob(files, recursive=recursive)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the local client."
                        )
                else:
                    raise ValueError(
                        f"The files parameter ('{files}') does not match any file or pattern."
                    )
            else:  # Remote or looking into Mechanical working directory
                if files in self_files:
                    list_files = [files]
                elif "*" in files:
                    # try filter on the list_files
                    if recursive:
                        self.log_warning(
                            "Because the 'recursive' keyword argument does not work with "
                            "remote instances, it is ignored."
                        )
                    list_files = fnmatch.filter(self_files, files)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the remote server."
                        )
                else:
>                   raise ValueError(
                        f"The `'files'` parameter ('{files}') does not match any file or pattern."
                    )
E                   ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.

.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1322: ValueError

Check failure on line 344 in tests/test_mechanical.py

GitHub Actions / Remote Connect Test Report 3.13

test_mechanical.test_download_file_different_chunk_size1[50]

ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.
Raw output
mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_download_file_different_c1')
chunk_size = 50

    @pytest.mark.remote_session_connect
    # we are using only a small test file
    # change the chunk_size for that
    # ideally this will be 64*1024, 1024*1024, etc.
    @pytest.mark.parametrize("chunk_size", [10, 50, 100])
    def test_download_file_different_chunk_size1(mechanical, tmpdir, chunk_size):
        file_name = "hsec.x_t"
    
>       verify_download(mechanical, tmpdir, file_name, chunk_size)

tests/test_mechanical.py:367: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_mechanical.py:344: in verify_download
    local_path_list = mechanical.download(
.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1419: in download
    list_files = self._get_files(files, recursive=recursive)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

files = '/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t'
recursive = False

    def _get_files(self, files, recursive=False):
        self_files = self.list_files()  # to avoid calling it too much
    
        if isinstance(files, str):
            if self._local:  # pragma: no cover
                # in local mode
                if os.path.exists(files):
                    if not os.path.isabs(files):
                        list_files = [os.path.join(os.getcwd(), files)]
                    else:
                        # file exist
                        list_files = [files]
                elif "*" in files:
                    # using filter
                    list_files = glob.glob(files, recursive=recursive)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the local client."
                        )
                else:
                    raise ValueError(
                        f"The files parameter ('{files}') does not match any file or pattern."
                    )
            else:  # Remote or looking into Mechanical working directory
                if files in self_files:
                    list_files = [files]
                elif "*" in files:
                    # try filter on the list_files
                    if recursive:
                        self.log_warning(
                            "Because the 'recursive' keyword argument does not work with "
                            "remote instances, it is ignored."
                        )
                    list_files = fnmatch.filter(self_files, files)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the remote server."
                        )
                else:
>                   raise ValueError(
                        f"The `'files'` parameter ('{files}') does not match any file or pattern."
                    )
E                   ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.

.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1322: ValueError

Check failure on line 344 in tests/test_mechanical.py

GitHub Actions / Remote Connect Test Report 3.13

test_mechanical.test_download_file_different_chunk_size1[100]

ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.
Raw output
mechanical = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_download_file_different_c2')
chunk_size = 100

    @pytest.mark.remote_session_connect
    # we are using only a small test file
    # change the chunk_size for that
    # ideally this will be 64*1024, 1024*1024, etc.
    @pytest.mark.parametrize("chunk_size", [10, 50, 100])
    def test_download_file_different_chunk_size1(mechanical, tmpdir, chunk_size):
        file_name = "hsec.x_t"
    
>       verify_download(mechanical, tmpdir, file_name, chunk_size)

tests/test_mechanical.py:367: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_mechanical.py:344: in verify_download
    local_path_list = mechanical.download(
.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1419: in download
    list_files = self._get_files(files, recursive=recursive)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

files = '/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t'
recursive = False

    def _get_files(self, files, recursive=False):
        self_files = self.list_files()  # to avoid calling it too much
    
        if isinstance(files, str):
            if self._local:  # pragma: no cover
                # in local mode
                if os.path.exists(files):
                    if not os.path.isabs(files):
                        list_files = [os.path.join(os.getcwd(), files)]
                    else:
                        # file exist
                        list_files = [files]
                elif "*" in files:
                    # using filter
                    list_files = glob.glob(files, recursive=recursive)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the local client."
                        )
                else:
                    raise ValueError(
                        f"The files parameter ('{files}') does not match any file or pattern."
                    )
            else:  # Remote or looking into Mechanical working directory
                if files in self_files:
                    list_files = [files]
                elif "*" in files:
                    # try filter on the list_files
                    if recursive:
                        self.log_warning(
                            "Because the 'recursive' keyword argument does not work with "
                            "remote instances, it is ignored."
                        )
                    list_files = fnmatch.filter(self_files, files)
                    if not list_files:
                        raise ValueError(
                            f"The `'files'` parameter ({files}) didn't match any file using "
                            f"glob expressions in the remote server."
                        )
                else:
>                   raise ValueError(
                        f"The `'files'` parameter ('{files}') does not match any file or pattern."
                    )
E                   ValueError: The `'files'` parameter ('/tmp/ANSYS.root.1/AnsysMech6134/Project_Mech_Files/hsec.x_t') does not match any file or pattern.

.venv/lib/python3.13/site-packages/ansys/mechanical/core/mechanical.py:1322: ValueError
files=file_path, target_dir=local_directory, chunk_size=chunk_size
)
print("downloaded files:")
You are viewing a condensed version of this merge commit. You can view the full changes here.