WorkbenchClient
#
- class ansys.workbench.core.workbench_client.WorkbenchClient(local_workdir, server_host, server_port)#
Functions of a PyWorkbench client.
Overview#
Set the log filter level for the client console. |
|
Set a local log file for the Workbench server log. |
|
No longer use the current log file for the Workbench server log. |
|
Run a script as given in the input string on the server. |
|
Run a script file on the server. |
|
Upload one or more files from the client to the server. |
|
Upload a file from the Ansys |
|
Download one or more files from the server. |
|
Start the PyMechanical server for the given system in the Workbench project. |
|
Start the PyFluent server for the given system in the Workbench project. |
|
Start the PySherlock server for the given system in the Workbench project. |
Import detail#
from ansys.workbench.core.workbench_client import WorkbenchClient
Method detail#
- WorkbenchClient.__enter__()#
Connect to the server when entering a context.
- WorkbenchClient.__exit__(exc_type, exc_value, traceback)#
Disconnect from the server when exiting a context.
- WorkbenchClient.set_console_log_level(log_level)#
Set the log filter level for the client console.
- Parameters:
- log_level
str
, default: “error” Level of logging. Options are “critical” “debug”, “error”, “info”, and “warning”.
- log_level
- WorkbenchClient.set_log_file(log_file)#
Set a local log file for the Workbench server log.
Create a local log file if one does not exist and append it to the existing log file.
- Parameters:
- log_file
str
Path to a local file to use for logging.
- log_file
- WorkbenchClient.reset_log_file()#
No longer use the current log file for the Workbench server log.
- WorkbenchClient.run_script_string(script_string, log_level='error')#
Run a script as given in the input string on the server.
- Parameters:
- Returns:
str
Output defined in the script.
Examples
Run a Workbench script, given in a string, that returns the name of a newly created system.
>>> wb.run_script_string(r'''import json wb_script_result=json.dumps(GetTemplate(TemplateName="FLUENT").CreateSystem().Name) ''')
- WorkbenchClient.run_script_file(script_file_name, log_level='error')#
Run a script file on the server.
- WorkbenchClient.upload_file(*file_list, show_progress=True)#
Upload one or more files from the client to the server.
- WorkbenchClient.upload_file_from_example_repo(relative_file_path, show_progress=True)#
Upload a file from the Ansys
example-data
repository to the server.
- WorkbenchClient.download_file(file_name, show_progress=True, target_dir=None)#
Download one or more files from the server.
- Parameters:
- file_name
str
Name of the file. File must be located in the server’s working directory. The wildcard characters “?” and “*” are supported. A ZIP file is automatically generated and downloaded when multiple files are specified.
- show_progressbool, default:
True
Whether to show a progress bar during the download.
- target_dir
str
, default:None
Path to a local directory to download the files to. The default is
None
, in which case the client working directory is used.
- file_name
- Returns:
str
Name of the downloaded file.
- WorkbenchClient.start_mechanical_server(system_name)#
Start the PyMechanical server for the given system in the Workbench project.
- Parameters:
- system_name
str
Name of the system in the Workbench project.
- system_name
- Returns:
int
Port of the PyMechanical server to use to start the PyMechanical client.
Examples
Start a PyMechanical session for the given system name.
>>> from ansys.mechanical.core import launch_mechanical >>> server_port=wb.start_mechanical_server(system_name=mech_system_name) >>> mechanical = launch_mechanical(start_instance=False, port=server_port)
- WorkbenchClient.start_fluent_server(system_name)#
Start the PyFluent server for the given system in the Workbench project.
- Parameters:
- system_name
str
Name of the system in the Workbench project.
- system_name
- Returns:
str
Path to the local file containing the PyFluent server information that can be used to start a PyFluent client.
Examples
Start a PyFluent session for the given system name.
>>> import ansys.fluent.core as pyfluent >>> server_info_file=wb.start_fluent_server(system_name=fluent_sys_name) >>> fluent=pyfluent.connect_to_fluent(server_info_file_name=server_info_file)
- WorkbenchClient.start_sherlock_server(system_name)#
Start the PySherlock server for the given system in the Workbench project.
- Parameters:
- system_name
str
Name of the system in the Workbench project.
- system_name
- Returns:
int
Port of the PySherlock server to use to start a PySherlock client.
Examples
Start a PySherlock session for the given system name.
>>> from ansys.sherlock.core import pysherlock >>> server_port=wb.start_sherlock_server(system_name=sherlock_system_name) >>> sherlock = pysherlock.connect_grpc_channel(port=server_port) >>> sherlock.common.check()