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

Fixing race condition on mesh #1448

Merged
merged 15 commits into from
Sep 7, 2022
Merged

Fixing race condition on mesh #1448

merged 15 commits into from
Sep 7, 2022

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Sep 5, 2022

Close #1447 by not using threads on the self._elem attribute.

@germa89 germa89 added the BUG Issue, problem or error in PyMAPDL label Sep 5, 2022
@germa89 germa89 added this to the v0.63.3 milestone Sep 5, 2022
@germa89 germa89 self-assigned this Sep 5, 2022
@github-actions github-actions bot added CI/CD Related with CICD, Github Actions, etc Maintenance General maintenance of the repo (libraries, cicd, etc) Enhancement Improve any current implemented feature New Feature Request or proposal for a new feature labels Sep 5, 2022
@germa89
Copy link
Collaborator Author

germa89 commented Sep 5, 2022

Many reverts because I didnt' realize I create the branch from another WIP branch.

@codecov
Copy link

codecov bot commented Sep 5, 2022

Codecov Report

Merging #1448 (f5ad2bf) into main (0a64c81) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head f5ad2bf differs from pull request most recent head f974b7c. Consider uploading reports for the commit f974b7c to get more accurate results

@@            Coverage Diff             @@
##             main    #1448      +/-   ##
==========================================
- Coverage   79.74%   79.74%   -0.01%     
==========================================
  Files          43       43              
  Lines        6799     6798       -1     
==========================================
- Hits         5422     5421       -1     
  Misses       1377     1377              

@akaszynski akaszynski enabled auto-merge (squash) September 7, 2022 14:27
@akaszynski akaszynski merged commit 8b22505 into main Sep 7, 2022
@akaszynski akaszynski deleted the feat/improving-unit-tests branch September 7, 2022 17:00
@germa89
Copy link
Collaborator Author

germa89 commented Sep 12, 2022

Interestingly I got the following failed test in this branch:

========================= PyMAPDL Pytest short summary =========================
[FAILED] test_empty_mesh[False] - E           RuntimeError: Empty Record
= 1 failed, 827 passed, 246 skipped, 108 xfailed, 2 xpassed in 203.70s (0:03:23) =
Error: Process completed with exit code 1.

The error traceback:


=================================== FAILURES ===================================
____________________________ test_empty_mesh[False] ____________________________

mapdl = <ansys.mapdl.core.mapdl_grpc.MapdlGrpc object at 0x7f2859275100>
cleared = None

    def test_empty_mesh(mapdl, cleared):
        assert mapdl.mesh.n_node == 0
        assert mapdl.mesh.n_elem == 0
        assert mapdl.mesh.nnum_all.size == 0
        assert mapdl.mesh.enum_all.size == 0
        assert mapdl.mesh.nnum.size == 0
        assert mapdl.mesh.enum.size == 0
        assert mapdl.mesh.nodes.size == 0
        # assert mapdl.mesh.node_angles.size == 0 Not implemented
    
        # elem is a list
        assert len(mapdl.mesh.elem) == 0
    
        # Using size because it should be empty arrays
        assert mapdl.mesh.ekey.size == 0
        assert mapdl.mesh.et_id.size == 0
        assert mapdl.mesh.tshape.size == 0
        assert mapdl.mesh.material_type.size == 0
        assert mapdl.mesh.etype.size == 0
        assert mapdl.mesh.section.size == 0
        assert mapdl.mesh.element_coord_system.size == 0
        assert mapdl.mesh.elem_real_constant.size == 0
        assert mapdl.mesh.ekey.size == 0
    
        # should be empty dicts
        assert not mapdl.mesh.key_option
        assert not mapdl.mesh.tshape_key
        assert not mapdl.mesh.element_components
        assert not mapdl.mesh.node_components
    
        # bools
>       assert not mapdl.mesh._has_elements

tests/test_mesh_grpc.py:90: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/ansys/mapdl/core/mesh_grpc.py:89: in _has_elements
    return self._elem.size != 0
/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/ansys/mapdl/core/mesh_grpc.py:556: in _elem
    self._update_cache_elem()
/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/ansys/mapdl/core/mesh_grpc.py:546: in _update_cache_elem
    self._cache_elem, self._cache_elem_off = self._load_elements_offset()
/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/ansys/mapdl/core/mesh_grpc.py:611: in _load_elements_offset
    elem_raw = parse_chunks(chunks, np.int32)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

chunks = <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.OK
	details = ""
>
dtype = <class 'numpy.int32'>

    def parse_chunks(chunks, dtype=None):
        """Deserialize gRPC chunks into a numpy array
    
        Parameters
        ----------
        chunks : generator
            generator from grpc.  Each chunk contains a bytes payload
    
        dtype : np.dtype
            Numpy data type to interpert chunks as.
    
        Returns
        -------
        array : np.ndarray
            Deserialized numpy array.
    
        """
        if not chunks.is_active():
>           raise RuntimeError("Empty Record")
E           RuntimeError: Empty Record

/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/ansys/mapdl/core/common_grpc.py:160: RuntimeError
---------------------------- Captured stderr setup -----------------------------
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
------------------------------ Captured log setup ------------------------------
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
----------------------------- Captured stderr call -----------------------------
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
INFO - GRPC_127.0.0.1:21000 -  mapdl - run - *GET  __FLOATPARAMETER__  FROM  NODE  ITEM=COUN       VALUE=  0.00000000
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
INFO - GRPC_127.0.0.1:21000 -  mapdl - run - *GET  __FLOATPARAMETER__  FROM  ELEM  ITEM=COUN           VALUE=  0.00000000
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _update_cache_nnum - Updating nodes cache
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _reset_cache - Resetting cache
INFO - GRPC_127.0.0.1:21000 -  mapdl - run - *GET  __FLOATPARAMETER__  FROM  ELEM  ITEM=COUN           VALUE=  0.00000000
DEBUG - GRPC_127.0.0.1:21000 -  mesh_grpc - _update_cache_element_desc - Updating elements (desc) cache
------------------------------ Captured log call -------------------------------
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
INFO     GRPC_127.0.0.1:21000:mapdl.py:2718 *GET  __FLOATPARAMETER__  FROM  NODE  ITEM=COUN       VALUE=  0.00000000
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
INFO     GRPC_127.0.0.1:21000:mapdl.py:2718 *GET  __FLOATPARAMETER__  FROM  ELEM  ITEM=COUN           VALUE=  0.00000000
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:169 Updating nodes cache
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:98 Resetting cache
INFO     GRPC_127.0.0.1:21000:mapdl.py:2718 *GET  __FLOATPARAMETER__  FROM  ELEM  ITEM=COUN           VALUE=  0.00000000
DEBUG    GRPC_127.0.0.1:21000:mesh_grpc.py:189 Updating elements (desc) cache

It is interesting....

germa89 added a commit that referenced this pull request Oct 11, 2022
* Implementation in unit tests

* Missing run

* Fixing TTY error

* Removing it flag

* Update .github/workflows/ci.yml

* Update .github/workflows/ci.yml

* Detaching.

* Fixing race condition on mesh_grpc

* Revert "Update .github/workflows/ci.yml"

This reverts commit a1abace.

* Revert "Update .github/workflows/ci.yml"

This reverts commit 581dfbf.

* Revert "Removing it flag"

This reverts commit 4a6323f.

* Revert "Fixing TTY error"

This reverts commit feed8e0.

* Revert "Missing run"

This reverts commit 1828409.

* Revert "Implementation in unit tests"

This reverts commit 7b56469.

* Update src/ansys/mapdl/core/mesh_grpc.py

Co-authored-by: Alex Kaszynski <akascap@gmail.com>
germa89 added a commit that referenced this pull request Oct 11, 2022
germa89 added a commit that referenced this pull request Oct 11, 2022
* Implementation in unit tests

* Missing run

* Fixing TTY error

* Removing it flag

* Update .github/workflows/ci.yml

* Update .github/workflows/ci.yml

* Detaching.

* Fixing race condition on mesh_grpc

* Revert "Update .github/workflows/ci.yml"

This reverts commit a1abace.

* Revert "Update .github/workflows/ci.yml"

This reverts commit 581dfbf.

* Revert "Removing it flag"

This reverts commit 4a6323f.

* Revert "Fixing TTY error"

This reverts commit feed8e0.

* Revert "Missing run"

This reverts commit 1828409.

* Revert "Implementation in unit tests"

This reverts commit 7b56469.

* Update src/ansys/mapdl/core/mesh_grpc.py

Co-authored-by: Alex Kaszynski <akascap@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Issue, problem or error in PyMAPDL CI/CD Related with CICD, Github Actions, etc Enhancement Improve any current implemented feature Maintenance General maintenance of the repo (libraries, cicd, etc) New Feature Request or proposal for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mesh object not updating fast enough (Race condition)
2 participants