Skip to content

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Apr 18, 2022

Fixing #965 I realized that when inspecting the mapdl object, some of their attributes raise an error:

image

  • mapdl.chain_commands: Chained commands are not permitted in distributed ansys.
    'Traceback (most recent call last):\n  File "c:\\Users\\gayuso\\.vscode\\extensions\\ms-python.python-2022.4.1\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_resolver.py", line 192, in _get_py_dictionary\n    attr = getattr(var, name)\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\mapdl.py", line 416, in chain_commands\n    
    raise RuntimeError(\nRuntimeError: Chained commands are not permitted in distributed ansys.\n'
  • mapdl.db: ImportError: cannot import name mapdl_db_pb2_grpc from ansys.api.mapdl.v0 .
     'Traceback (most recent call last):\n  File "c:\\Users\\gayuso\\.vscode\\extensions\\ms-python.python-2022.4.1\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_resolver.py", line 192, in _get_py_dictionary\n    attr = getattr(var, name)\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\check_version.py", line 169, in wrapper\n    return func(self, *args, **kwargs)\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\mapdl_grpc.py", line 1948, in db\n    from ansys.mapdl.core.database import MapdlDb\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\database\\__init__.py", line 3, in <module>\n    from .database import DBDef, MapdlDb  # noqa: F401\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\database\\database.py", line 8, in <module>\n    from ansys.api.mapdl.v0 import mapdl_db_pb2_grpc\n
     ImportError: cannot import name \'mapdl_db_pb2_grpc\' from \'ansys.api.mapdl.v0\' (C:\\ProgramData\\Miniconda3\\envs\\pymapdl_0\\lib\\site-packages\\ansys\\api\\mapdl\\v0\\__init__.py)\n'
  • mapdl.result: No result file(s)
    'Traceback (most recent call last):\n  File "c:\\Users\\gayuso\\.vscode\\extensions\\ms-python.python-2022.4.1\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_resolver.py", line 192, in _get_py_dictionary\n    attr = getattr(var, name)\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\mapdl_grpc.py", line 2205, in result\n    
    raise FileNotFoundError("No result file(s) at %s" % self.directory)\nFileNotFoundError: No result file(s) at C:/ansys_jobs/tmp\n'
  • mapdl.thermal_result: No result file(s). Related to the previous one.
    'Traceback (most recent call last):\n  File "c:\\Users\\gayuso\\.vscode\\extensions\\ms-python.python-2022.4.1\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_resolver.py", line 192, in _get_py_dictionary\n    attr = getattr(var, name)\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\mapdl_grpc.py", line 2117, in thermal_result\n    
    result = self.result\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\mapdl_grpc.py", line 2182, in result\n    if self._distributed_result_file and self._result_file:\n  File "C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\src\\ansys\\mapdl\\core\\mapdl_grpc.py", line 2070, in _distributed_result_file\n    
    raise FileNotFoundError("Thermal Result not available")\nFileNotFoundError: Thermal Result not available\n'

Todo's

  • Fix the 'a','b','c' strange output.
  • Analyze and fix
    • db- This is because ansys.api.mapdl is outdated. I just expanded the error message to inform about the new api version.
      - [ ] result - Not applicable anymore.
      - [ ] thermal_result - Not applicable anymore.
      - [ ] chain_commands - Not applicable anymore.

Notes

Closes #965

@codecov
Copy link

codecov bot commented Apr 18, 2022

Codecov Report

Merging #1044 (a740eb2) into main (4a48968) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1044   +/-   ##
=======================================
  Coverage   71.32%   71.32%           
=======================================
  Files          43       43           
  Lines        6086     6086           
=======================================
  Hits         4341     4341           
  Misses       1745     1745           

@germa89 germa89 self-assigned this Apr 18, 2022
@germa89 germa89 added the BUG label Apr 18, 2022
@germa89 germa89 added this to the v0.61.3 milestone Apr 18, 2022
@germa89
Copy link
Collaborator Author

germa89 commented Apr 18, 2022

Regarding the chained_command

I believe the current behavior is fine. Since it only raises the warning when we are in distributed mode.

Regarding results, and thermal_result

I believe we should not see errors when we have not solved the model yet. However I see difficult to discriminate the following situations:

  • MAPDL just started, hence there is no results files -> FileNotFoundError
  • MAPDL failed to solve, hence there is no results files -> FileNotFoundError

We could just implement a private method mapdl._initialized_result which starts as False. While this is none, we do not evaluate mapdl.results. Then when we execute mapdl.solve we change, mapdl._initialized_result to True, and then we do evaluate mapdl.results. This is not bulletproof though, because if someone just want to read the datafiles, then he won't be able to, unless he/she changes the mapdl._initialized_result value to True.

Unless we do something like:

@property 
def result(self):
   def result_files_exist():
        # code
        return True/False

    if not self._initialized_result and not result_files_exist():
       return None    

I'm not sure it is worth the trouble just to avoid an exception in the debugger.

Because of this, I am not doing any change on this, until there is consensus.

@akaszynski
Copy link
Collaborator

I'm not sure it is worth the trouble just to avoid an exception in the debugger.

It's not. Someone could load a database that's already initialized.

Because of this, I am not doing any change on this, until there is consensus.

Agree with not changing it.

@akaszynski akaszynski merged commit a213b90 into main Apr 20, 2022
@akaszynski akaszynski deleted the fix/remove-undesired-screen-output branch April 20, 2022 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange console output when opening MapdlGrpc in debugger

2 participants