Setup#

This prepares the environment for running the examples.

Description#

Perform the following steps to set up the environment: - Launch Sherlock. - Store the Sherlock tutorial path.

import os
import sys

# Add the 'examples' directory to the Python path to allow importing files in that directory.
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.getcwd()))))

from examples.examples_globals import store_sherlock_tutorial_path

from ansys.sherlock.core import launcher

Launch Sherlock#

Launch Sherlock on Windows in headless mode using Windows Named User Authentication for the gRPC transport mode. See the API reference for how to launch Sherlock on Linux or Windows using other options.

sherlock, ansys_install_path = launcher.launch_and_connect(
    port=9092,
    transport_mode="wnua",
    sherlock_command_args="-noGUI",
)

store_sherlock_tutorial_path(ansys_install_path)
Traceback (most recent call last):
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\examples\00-setup\setup.py", line 58, in <module>
    sherlock, ansys_install_path = launcher.launch_and_connect(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        port=9092,
        ^^^^^^^^^^
        transport_mode="wnua",
        ^^^^^^^^^^^^^^^^^^^^^^
        sherlock_command_args="-noGUI",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 246, in launch_and_connect
    sherlock = connect(
        port=port,
    ...<3 lines>...
        uds_id=uds_id,
    )
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 324, in connect
    raise e
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 306, in connect
    _wait_for_sherlock_grpc_ready(channel, timeout)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 395, in _wait_for_sherlock_grpc_ready
    raise SherlockConnectionError(message="Error starting gRPC service")
ansys.sherlock.core.errors.SherlockConnectionError: gRPC connection error: Error starting gRPC service

Total running time of the script: (2 minutes 0.251 seconds)