User guide#

Anyone who wants to use PyTwin can import its Python modules and develop Python code to integrate and deploy twin runtimes, as explained in API reference and demonstrated in Examples.

Global settings#

By default, logging is enabled in PyTwin at a level of INFO. Simulation output files are generated in the %temp%/pytwin folder. You can change these global settings at anytime using these functions:

# Modify working directory
from pytwin import modify_pytwin_working_dir

modify_pytwin_working_dir("path_to_new_working_dir", erase=False)

# Redirect logging to a file in the working directory
from pytwin import modify_pytwin_logging, get_pytwin_log_file
from pytwin import PYTWIN_LOGGING_OPT_FILE, PYTWIN_LOG_DEBUG

modify_pytwin_logging(new_option=PYTWIN_LOGGING_OPT_FILE, new_level=PYTWIN_LOG_DEBUG)
print(get_pytwin_log_file())

# Redirect PyTwin logging to the console
from pytwin import modify_pytwin_logging, PYTWIN_LOGGING_OPT_CONSOLE

modify_pytwin_logging(PYTWIN_LOGGING_OPT_CONSOLE)

# Disable PyTwin logging:
from pytwin import modify_pytwin_logging, PYTWIN_LOGGING_OPT_NOLOGGING

modify_pytwin_logging(PYTWIN_LOGGING_OPT_NOLOGGING)

For information on all APIs, see Global settings.