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 (
    SHERLOCK_LAUNCH_AND_CONNECT_TIMEOUT,
    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,
    timeout=SHERLOCK_LAUNCH_AND_CONNECT_TIMEOUT,
    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 61, in <module>
    sherlock, ansys_install_path = launcher.launch_and_connect(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        port=9092,
        ^^^^^^^^^^
    ...<2 lines>...
        sherlock_command_args="-noGUI",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 247, 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 326, in connect
    raise e
  File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 308, 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 397, 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: (0 minutes 10.232 seconds)