diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8260d13d454f..af2e4b2112e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,11 @@ env: PACKAGE_NAME: 'ansys-fluent-core' PACKAGE_NAMESPACE: 'ansys.fluent.core' ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - PYFLUENT_TIMEOUT_FORCE_EXIT: 5 + PYFLUENT_TIMEOUT_FORCE_EXIT: 30 PYFLUENT_LAUNCH_CONTAINER: 1 + PYFLUENT_LOGGING: 'DEBUG' + PYFLUENT_WATCHDOG_DEBUG: 'OFF' + PYFLUENT_HIDE_LOG_SECRETS: 1 jobs: diff --git a/.github/workflows/nightly-dev-doc-build.yml b/.github/workflows/nightly-dev-doc-build.yml index 9658c690ac65..64147a1d5243 100644 --- a/.github/workflows/nightly-dev-doc-build.yml +++ b/.github/workflows/nightly-dev-doc-build.yml @@ -9,8 +9,11 @@ env: DOCUMENTATION_CNAME: 'fluent.docs.pyansys.com' DOC_DEPLOYMENT_IMAGE_TAG: v23.2.0 ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - PYFLUENT_TIMEOUT_FORCE_EXIT: 5 + PYFLUENT_TIMEOUT_FORCE_EXIT: 30 PYFLUENT_LAUNCH_CONTAINER: 1 + PYFLUENT_LOGGING: 'DEBUG' + PYFLUENT_WATCHDOG_DEBUG: 'OFF' + PYFLUENT_HIDE_LOG_SECRETS: 1 jobs: nightly_docs_build: diff --git a/.github/workflows/nightly-test-run.yml b/.github/workflows/nightly-test-run.yml index eac8e5d3b230..badaa2ffa5cb 100644 --- a/.github/workflows/nightly-test-run.yml +++ b/.github/workflows/nightly-test-run.yml @@ -7,8 +7,11 @@ on: env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - PYFLUENT_TIMEOUT_FORCE_EXIT: 5 + PYFLUENT_TIMEOUT_FORCE_EXIT: 30 PYFLUENT_LAUNCH_CONTAINER: 1 + PYFLUENT_LOGGING: 'DEBUG' + PYFLUENT_WATCHDOG_DEBUG: 'OFF' + PYFLUENT_HIDE_LOG_SECRETS: 1 jobs: test: diff --git a/.github/workflows/release-doc-build.yml b/.github/workflows/release-doc-build.yml index 0e373c04b626..cd3c792c3e1f 100644 --- a/.github/workflows/release-doc-build.yml +++ b/.github/workflows/release-doc-build.yml @@ -11,8 +11,11 @@ env: DOCUMENTATION_CNAME: 'fluent.docs.pyansys.com' DOC_DEPLOYMENT_IMAGE_TAG: v23.2.0 ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - PYFLUENT_TIMEOUT_FORCE_EXIT: 5 + PYFLUENT_TIMEOUT_FORCE_EXIT: 30 PYFLUENT_LAUNCH_CONTAINER: 1 + PYFLUENT_LOGGING: 'DEBUG' + PYFLUENT_WATCHDOG_DEBUG: 'OFF' + PYFLUENT_HIDE_LOG_SECRETS: 1 jobs: nightly_docs_build: diff --git a/.github/workflows/run-custom-tests.yml b/.github/workflows/run-custom-tests.yml index b48ef0b1f8f9..d21b043ef2da 100644 --- a/.github/workflows/run-custom-tests.yml +++ b/.github/workflows/run-custom-tests.yml @@ -11,8 +11,11 @@ concurrency: env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - PYFLUENT_TIMEOUT_FORCE_EXIT: 5 + PYFLUENT_TIMEOUT_FORCE_EXIT: 30 PYFLUENT_LAUNCH_CONTAINER: 1 + PYFLUENT_LOGGING: 'DEBUG' + PYFLUENT_WATCHDOG_DEBUG: 'OFF' + PYFLUENT_HIDE_LOG_SECRETS: 1 jobs: diff --git a/.github/workflows/test-run-wo-codegen.yml b/.github/workflows/test-run-wo-codegen.yml index 510741e3d0ca..1249ee4c68fc 100644 --- a/.github/workflows/test-run-wo-codegen.yml +++ b/.github/workflows/test-run-wo-codegen.yml @@ -7,8 +7,11 @@ on: env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - PYFLUENT_TIMEOUT_FORCE_EXIT: 5 + PYFLUENT_TIMEOUT_FORCE_EXIT: 30 PYFLUENT_LAUNCH_CONTAINER: 1 + PYFLUENT_LOGGING: 'DEBUG' + PYFLUENT_WATCHDOG_DEBUG: 'OFF' + PYFLUENT_HIDE_LOG_SECRETS: 1 jobs: test: diff --git a/codegen/tuigen.py b/codegen/tuigen.py index 05f6039eae3b..7d73f74aa263 100644 --- a/codegen/tuigen.py +++ b/codegen/tuigen.py @@ -349,12 +349,13 @@ def generate(): _populate_xml_helpstrings() TUIGenerator("meshing", version).generate() TUIGenerator("solver", version).generate() - logger.info( - "XML help is available but not picked for the following %i paths:", - len(_XML_HELPSTRINGS), - ) - for k, _ in _XML_HELPSTRINGS.items(): - logger.info(k) + if os.getenv("PYFLUENT_HIDE_LOG_SECRETS") != "1": + logger.info( + "XML help is available but not picked for the following %i paths: ", + len(_XML_HELPSTRINGS), + ) + for k in _XML_HELPSTRINGS: + logger.info(k) if __name__ == "__main__": diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index 63e4ea66ecd8..3566115dcd38 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -124,7 +124,17 @@ def configure_container_dict( ``container_dict``, see `Docker run documentation`_. """ - logger.debug(f"container_dict before processing: {container_dict}") + if ( + container_dict + and "environment" in container_dict + and os.getenv("PYFLUENT_HIDE_LOG_SECRETS") == "1" + ): + container_dict_h = container_dict.copy() + container_dict_h.pop("environment") + logger.debug(f"container_dict before processing: {container_dict_h}") + del container_dict_h + else: + logger.debug(f"container_dict before processing: {container_dict}") if not host_mount_path: host_mount_path = pyfluent.EXAMPLES_PATH @@ -302,8 +312,6 @@ def start_fluent_container(args: List[str], container_dict: dict = None) -> (int container_vars = configure_container_dict(args, **container_dict) - logger.debug(f"container_vars:{container_vars}") - ( config_dict, timeout, @@ -312,6 +320,21 @@ def start_fluent_container(args: List[str], container_dict: dict = None) -> (int remove_server_info_file, ) = container_vars + if os.getenv("PYFLUENT_HIDE_LOG_SECRETS") != "1": + logger.debug(f"container_vars: {container_vars}") + else: + config_dict_h = config_dict.copy() + config_dict_h.pop("environment") + container_vars_tmp = ( + config_dict_h, + timeout, + port, + host_server_info_file, + remove_server_info_file, + ) + logger.debug(f"container_vars: {container_vars_tmp}") + del container_vars_tmp + try: if not host_server_info_file.exists(): host_server_info_file.parents[0].mkdir(exist_ok=True) diff --git a/src/ansys/fluent/core/launcher/launcher.py b/src/ansys/fluent/core/launcher/launcher.py index bbb733eda4e1..2375656b803e 100644 --- a/src/ansys/fluent/core/launcher/launcher.py +++ b/src/ansys/fluent/core/launcher/launcher.py @@ -760,7 +760,13 @@ def launch_fluent( print("\nDocker container run configuration:\n") print("config_dict = ") - pprint(config_dict) + if os.getenv("PYFLUENT_HIDE_LOG_SECRETS") != "1": + pprint(config_dict) + else: + config_dict_h = config_dict.copy() + config_dict_h.pop("environment") + pprint(config_dict_h) + del config_dict_h return config_dict port, password = start_fluent_container(args, container_dict) diff --git a/src/ansys/fluent/core/services/interceptors.py b/src/ansys/fluent/core/services/interceptors.py index 3227346f9e1f..ba6ad8f83e7f 100644 --- a/src/ansys/fluent/core/services/interceptors.py +++ b/src/ansys/fluent/core/services/interceptors.py @@ -11,6 +11,20 @@ network_logger = logging.getLogger("pyfluent.networking") log_bytes_limit = int(os.getenv("PYFLUENT_GRPC_LOG_BYTES_LIMIT", 1000)) +truncate_len = log_bytes_limit // 5 + + +def _truncate_grpc_str(message): + message_bytes = message.ByteSize() + message_str = str(MessageToDict(message)) + if not log_bytes_limit or message_bytes < log_bytes_limit: + return message_str + else: + network_logger.debug( + f"GRPC_TRACE: message partially hidden, {message_bytes} bytes > " + f"{log_bytes_limit} bytes limit. To see the full message, set PYFLUENT_GRPC_LOG_BYTES_LIMIT to 0." + ) + return f"{message_str[:truncate_len]} < ... > {message_str[-truncate_len:]}" class TracingInterceptor(grpc.UnaryUnaryClientInterceptor): @@ -27,20 +41,14 @@ def _intercept_call( request: Any, ): network_logger.debug( - f"GRPC_TRACE: rpc = {client_call_details.method}, request = {MessageToDict(request)}" + f"GRPC_TRACE: rpc = {client_call_details.method}, request = {_truncate_grpc_str(request)}" ) response = continuation(client_call_details, request) if not response.exception(): - response_bytes = response.result().ByteSize() - if not log_bytes_limit or response_bytes < log_bytes_limit: - network_logger.debug( - f"GRPC_TRACE: response = {MessageToDict(response.result())}" - ) - else: - network_logger.debug( - f"GRPC_TRACE: response hidden, {response_bytes} bytes > " - f"{log_bytes_limit} bytes limit. To see the response, set PYFLUENT_GRPC_LOG_BYTES_LIMIT to 0." - ) + # call _truncate_grpc_str early to get the size warning even when hiding secrets + response_str = _truncate_grpc_str(response.result()) + if os.getenv("PYFLUENT_HIDE_LOG_SECRETS") != "1": + network_logger.debug(f"GRPC_TRACE: response = {response_str}") return response def intercept_unary_unary(