From 6ddb573a7d2f95f13df58e53bc984e06722c7547 Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Thu, 11 Apr 2024 16:54:31 +0800 Subject: [PATCH 1/7] run pfs foreground in debug mode and print log to terminal --- .../promptflow/_cli/_pf/_service.py | 74 ++++++++++--------- .../promptflow/_sdk/_service/app.py | 13 ++++ 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py index abd576dd21e..95783552718 100644 --- a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py +++ b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py @@ -157,42 +157,35 @@ def start_service(args): port = args.port if args.debug: os.environ[PF_SERVICE_DEBUG] = "true" - - if is_run_from_built_binary(): - # For msi installer/executable, use sdk api to start pfs since it's not supported to invoke waitress by cli - # directly after packaged by Pyinstaller. - parent_dir = os.path.dirname(sys.executable) - output_path = os.path.join(parent_dir, "output.txt") - with redirect_stdout_to_file(output_path): - port = validate_port(port, args.force) - global app - if app is None: - app, _ = create_app() - if os.environ.get(PF_SERVICE_DEBUG) == "true": - app.logger.setLevel(logging.DEBUG) - else: - app.logger.setLevel(logging.INFO) - message = f"Starting Prompt Flow Service on {port}, version: {get_pfs_version()}." - app.logger.info(message) - print(message) - sys.stdout.flush() + if not is_run_from_built_binary(): + add_executable_script_to_env_path() + port = _prepare_app_for_foreground_service(port, args.force) waitress.serve(app, host="127.0.0.1", port=port, threads=PF_SERVICE_WORKER_NUM) else: - port = validate_port(port, args.force) - add_executable_script_to_env_path() - # Start a pfs process using detach mode. It will start a new process and create a new app. So we use environment - # variable to pass the debug mode, since it will inherit parent process environment variable. - if platform.system() == "Windows": - _start_background_service_on_windows(port) - else: - _start_background_service_on_unix(port) - is_healthy = check_pfs_service_status(port) - if is_healthy: - message = f"Start Promptflow Service on port {port}, version: {get_pfs_version()}." - print(message) - logger.info(message) + if is_run_from_built_binary(): + # For msi installer/executable, use sdk api to start pfs since it's not supported to invoke waitress by cli + # directly after packaged by Pyinstaller. + parent_dir = os.path.dirname(sys.executable) + output_path = os.path.join(parent_dir, "output.txt") + with redirect_stdout_to_file(output_path): + port = _prepare_app_for_foreground_service(port, args.force) + waitress.serve(app, host="127.0.0.1", port=port, threads=PF_SERVICE_WORKER_NUM) else: - logger.warning(f"Promptflow service start failed in {port}. {hint_stop_before_upgrade}") + port = validate_port(port, args.force) + add_executable_script_to_env_path() + # Start a pfs process using detach mode. It will start a new process and create a new app. So we use + # environment variable to pass the debug mode, since it will inherit parent process environment variable. + if platform.system() == "Windows": + _start_background_service_on_windows(port) + else: + _start_background_service_on_unix(port) + is_healthy = check_pfs_service_status(port) + if is_healthy: + message = f"Start Promptflow Service on port {port}, version: {get_pfs_version()}." + print(message) + logger.info(message) + else: + logger.warning(f"Promptflow service start failed in {port}. {hint_stop_before_upgrade}") def validate_port(port, force_start): @@ -238,6 +231,21 @@ def redirect_stdout_to_file(path): sys.stderr = old_stderr +def _prepare_app_for_foreground_service(port, force_start): + port = validate_port(port, force_start) + global app + if app is None: + app, _ = create_app() + if os.environ.get(PF_SERVICE_DEBUG) == "true": + app.logger.setLevel(logging.DEBUG) + else: + app.logger.setLevel(logging.INFO) + message = f"Starting Prompt Flow Service on {port}, version: {get_pfs_version()}." + app.logger.info(message) + print(message) + return port + + def _start_background_service_on_windows(port): try: import win32api diff --git a/src/promptflow-devkit/promptflow/_sdk/_service/app.py b/src/promptflow-devkit/promptflow/_sdk/_service/app.py index bf59e5cd815..d9ccbcc0078 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_service/app.py +++ b/src/promptflow-devkit/promptflow/_sdk/_service/app.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import logging +import os import threading import time from datetime import datetime, timedelta @@ -14,6 +15,7 @@ from promptflow._sdk._constants import ( HOME_PROMPT_FLOW_DIR, + PF_SERVICE_DEBUG, PF_SERVICE_HOUR_TIMEOUT, PF_SERVICE_LOG_FILE, PF_SERVICE_MONITOR_SECOND, @@ -98,8 +100,19 @@ def create_app(): handler = RotatingFileHandler(filename=log_file, maxBytes=1_000_000, backupCount=1) formatter = logging.Formatter("[%(asctime)s][%(name)s][%(levelname)s] - %(message)s") handler.setFormatter(formatter) + + # Create a stream handler to output logs to the terminal + stream_handler = logging.StreamHandler() + stream_handler.setFormatter(formatter) + # Set app logger to the only one RotatingFileHandler to avoid duplicate logs app.logger.handlers = [handler] + if os.environ.get(PF_SERVICE_DEBUG) == "true": + # Set app logger to use both the rotating file handler and the stream handler in debug mode + app.logger.handlers.append(stream_handler) + + # Prevent logs from being handled by the root logger + app.logger.propagate = False # Basic error handler @api.errorhandler(Exception) From bb266d4b3af18e24ed2abace1cd7b87aa259ad1d Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Thu, 11 Apr 2024 17:50:54 +0800 Subject: [PATCH 2/7] update test and message --- .../promptflow/_cli/_pf/_service.py | 12 ++++++++++-- .../unittests/executor/test_tool_resolver.py | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py index 95783552718..0bfa0f64a66 100644 --- a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py +++ b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py @@ -12,7 +12,7 @@ import waitress -from promptflow._cli._params import base_params +from promptflow._cli._params import add_param_ua, add_param_verbose, base_params from promptflow._cli._utils import activate_action from promptflow._constants import PF_NO_INTERACTIVE_LOGIN from promptflow._sdk._constants import ( @@ -98,6 +98,13 @@ def add_parser_start_service(subparsers): action="store_true", help="If the port is used, the existing service will be terminated and restart a new service.", ) + add_param_debug = lambda parser: parser.add_argument( # noqa: E731 + "-d", + "--debug", + action="store_true", + help="The debug mode flag for the promptflow service activates foreground operation, displaying debug level " + "logs directly in the terminal.", + ) activate_action( name="start", description="Start prompt flow service.", @@ -105,8 +112,9 @@ def add_parser_start_service(subparsers): add_params=[ add_param_port, add_param_force, + add_param_debug, ] - + base_params, + + [add_param_ua, add_param_verbose], subparsers=subparsers, help_message="Start prompt flow service.", action_param_name="sub_action", diff --git a/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py b/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py index 13705a54da2..bfd2b01287d 100644 --- a/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py +++ b/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py @@ -622,7 +622,7 @@ def test_tool_with_connection_resolve(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -650,7 +650,7 @@ def test_tool_with_connection_resolve(self, path): @pytest.mark.parametrize("path", ["assistant_definition_without_functions.yaml"]) def test_code_interpreter_and_retrieval_tool_resolve(self, path): - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections={}) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider={}) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -679,7 +679,7 @@ def test_description_resolve(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -716,7 +716,7 @@ def test_types_resolve(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -773,7 +773,7 @@ def test_invalid_assistant_definition_path(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) with pytest.raises(InvalidSource) as e: tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" From 4ccf394d82a16f3628557b350c55bf7ef0e8f32d Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Thu, 11 Apr 2024 18:25:48 +0800 Subject: [PATCH 3/7] revert --- .../executor/unittests/executor/test_tool_resolver.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py b/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py index bfd2b01287d..13705a54da2 100644 --- a/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py +++ b/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py @@ -622,7 +622,7 @@ def test_tool_with_connection_resolve(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -650,7 +650,7 @@ def test_tool_with_connection_resolve(self, path): @pytest.mark.parametrize("path", ["assistant_definition_without_functions.yaml"]) def test_code_interpreter_and_retrieval_tool_resolve(self, path): - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider={}) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections={}) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -679,7 +679,7 @@ def test_description_resolve(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -716,7 +716,7 @@ def test_types_resolve(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) assistant_definition = tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" ) @@ -773,7 +773,7 @@ def test_invalid_assistant_definition_path(self, path): "value": {"api_key": "mock", "api_base": "mock"}, } } - tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connection_provider=connections) + tool_resolver = ToolResolver(working_dir=Path(ASSISTANT_DEFINITION_ROOT), connections=connections) with pytest.raises(InvalidSource) as e: tool_resolver._convert_to_assistant_definition( assistant_definition_path=path, input_name="input_name", node_name="dummy_node" From 9c39a41cedead2f69baef673f08762aaaf2a7a08 Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Thu, 11 Apr 2024 18:56:16 +0800 Subject: [PATCH 4/7] update message --- src/promptflow-devkit/promptflow/_cli/_pf/_service.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py index 0bfa0f64a66..ba79baed02f 100644 --- a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py +++ b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py @@ -102,8 +102,7 @@ def add_parser_start_service(subparsers): "-d", "--debug", action="store_true", - help="The debug mode flag for the promptflow service activates foreground operation, displaying debug level " - "logs directly in the terminal.", + help="Start the promptflow service in foreground, displaying debug level logs directly in the terminal.", ) activate_action( name="start", From 6d473040130a78ebbc1291d02ea1271e04b0e00c Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Thu, 11 Apr 2024 19:40:52 +0800 Subject: [PATCH 5/7] change from show-status to status --- src/promptflow-devkit/promptflow/_cli/_pf/_service.py | 6 +++--- src/promptflow/tests/sdk_pfs_test/e2etests/test_cli.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py index ba79baed02f..99516e3db30 100644 --- a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py +++ b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py @@ -74,7 +74,7 @@ def dispatch_service_commands(args: argparse.Namespace): start_service(args) elif args.sub_action == "stop": stop_service() - elif args.sub_action == "show-status": + elif args.sub_action == "status": show_service() @@ -145,10 +145,10 @@ def add_parser_show_service(subparsers): Examples: # Display the started prompt flow service info.: - pf service show-status + pf service status """ # noqa: E501 activate_action( - name="show-status", + name="status", description="Show the started prompt flow service status.", epilog=epilog, add_params=base_params, diff --git a/src/promptflow/tests/sdk_pfs_test/e2etests/test_cli.py b/src/promptflow/tests/sdk_pfs_test/e2etests/test_cli.py index 5e9a92ce4ba..1d5d7558bd0 100644 --- a/src/promptflow/tests/sdk_pfs_test/e2etests/test_cli.py +++ b/src/promptflow/tests/sdk_pfs_test/e2etests/test_cli.py @@ -67,12 +67,12 @@ def test_start_service(self): def test_show_service_status(self, capsys): with pytest.raises(SystemExit): - self._run_pfs_command("show-status") + self._run_pfs_command("status") start_pfs = subprocess.Popen("pf service start", shell=True) # Wait for service to be started start_pfs.wait() assert self._is_service_healthy() - self._run_pfs_command("show-status") + self._run_pfs_command("status") output, _ = capsys.readouterr() assert str(get_port_from_config()) in output self._run_pfs_command("stop") From d4eb724e2e3001742909dc3ed60cba3a618b7016 Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Thu, 11 Apr 2024 19:50:50 +0800 Subject: [PATCH 6/7] format message --- .../promptflow/_cli/_pf/_service.py | 26 +++++++++---------- .../promptflow/_sdk/_service/utils/utils.py | 24 ++++++++--------- .../promptflow/_sdk/_tracing.py | 4 +-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py index 99516e3db30..f84dcd22fe5 100644 --- a/src/promptflow-devkit/promptflow/_cli/_pf/_service.py +++ b/src/promptflow-devkit/promptflow/_cli/_pf/_service.py @@ -85,13 +85,13 @@ def add_parser_start_service(subparsers): # Start prompt flow service: pf service start - # Force restart promptflow service: + # Force restart prompt flow service: pf service start --force - # Start promptflow service with specific port: + # Start prompt flow service with specific port: pf service start --port 65553 """ # noqa: E501 add_param_port = lambda parser: parser.add_argument( # noqa: E731 - "-p", "--port", type=int, help="port of the promptflow service" + "-p", "--port", type=int, help="port of the prompt flow service" ) add_param_force = lambda parser: parser.add_argument( # noqa: E731 "--force", @@ -102,7 +102,7 @@ def add_parser_start_service(subparsers): "-d", "--debug", action="store_true", - help="Start the promptflow service in foreground, displaying debug level logs directly in the terminal.", + help="Start the prompt flow service in foreground, displaying debug level logs directly in the terminal.", ) activate_action( name="start", @@ -188,11 +188,11 @@ def start_service(args): _start_background_service_on_unix(port) is_healthy = check_pfs_service_status(port) if is_healthy: - message = f"Start Promptflow Service on port {port}, version: {get_pfs_version()}." + message = f"Start prompt flow service on port {port}, version: {get_pfs_version()}." print(message) logger.info(message) else: - logger.warning(f"Promptflow service start failed in {port}. {hint_stop_before_upgrade}") + logger.warning(f"Prompt flow service start failed in {port}. {hint_stop_before_upgrade}") def validate_port(port, force_start): @@ -247,7 +247,7 @@ def _prepare_app_for_foreground_service(port, force_start): app.logger.setLevel(logging.DEBUG) else: app.logger.setLevel(logging.INFO) - message = f"Starting Prompt Flow Service on {port}, version: {get_pfs_version()}." + message = f"Starting prompt flow Service on {port}, version: {get_pfs_version()}." app.logger.info(message) print(message) return port @@ -267,7 +267,7 @@ def _start_background_service_on_windows(port): f"waitress-serve --listen=127.0.0.1:{port} --threads={PF_SERVICE_WORKER_NUM} " "promptflow._cli._pf._service:get_app" ) - logger.debug(f"Start Promptflow Service in Windows: {command}") + logger.debug(f"Start prompt flow service in Windows: {command}") startupinfo = win32process.STARTUPINFO() startupinfo.dwFlags |= win32process.STARTF_USESHOWWINDOW startupinfo.wShowWindow = win32con.SW_HIDE @@ -301,7 +301,7 @@ def _start_background_service_on_unix(port): f"--threads={PF_SERVICE_WORKER_NUM}", "promptflow._cli._pf._service:get_app", ] - logger.debug(f"Start Promptflow Service in Unix: {cmd}") + logger.debug(f"Start prompt flow service in Unix: {cmd}") subprocess.Popen(cmd, stdout=subprocess.DEVNULL, start_new_session=True) @@ -309,9 +309,9 @@ def stop_service(): port = get_port_from_config() if port is not None and is_port_in_use(port): kill_exist_service(port) - message = f"Promptflow service stop in {port}." + message = f"Prompt flow service stop in {port}." else: - message = "Promptflow service is not started." + message = "Prompt flow service is not started." logger.debug(message) print(message) @@ -330,7 +330,7 @@ def show_service(): return else: logger.warning( - f"Promptflow service is not started. The promptflow service log is located at {log_file.as_posix()} " - f"and promptflow version is {get_pfs_version()}." + f"Prompt flow service is not started. The prompt flow service log is located at {log_file.as_posix()} " + f"and prompt flow version is {get_pfs_version()}." ) sys.exit(1) diff --git a/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py b/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py index 4bcc19befba..71380be2d4e 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py +++ b/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py @@ -38,17 +38,17 @@ logger = get_cli_sdk_logger() hint_stop_message = ( - f"You can stop the prompt flow tracing server with the following command:'\033[1mpf service stop\033[0m'.\n" + f"You can stop the prompt flow service with the following command:'\033[1mpf service stop\033[0m'.\n" f"Alternatively, if no requests are made within {PF_SERVICE_HOUR_TIMEOUT} " f"hours, it will automatically stop." ) hint_stop_before_upgrade = ( - "Kindly reminder: If you have previously upgraded the promptflow package , please " - "double-confirm that you have run '\033[1mpf service stop\033[0m' to stop the promptflow" + "Kindly reminder: If you have previously upgraded the prompt flow package , please " + "double-confirm that you have run '\033[1mpf service stop\033[0m' to stop the prompt flow" "service before proceeding with the upgrade. Otherwise, you may encounter unexpected " - "environmental issues or inconsistencies between the version of running promptflow service " - "and the local promptflow version. Alternatively, you can use the " - "'\033[1mpf upgrade\033[0m' command to proceed with the upgrade process for the promptflow " + "environmental issues or inconsistencies between the version of running prompt flow service " + "and the local prompt flow version. Alternatively, you can use the " + "'\033[1mpf upgrade\033[0m' command to proceed with the upgrade process for the prompt flow " "package." ) @@ -176,7 +176,7 @@ def make_response_no_content(): def get_pfs_version(): - """Promptflow service show promptflow version if installed from root, else devkit version""" + """Prompt flow service show promptflow version if installed from root, else devkit version""" version_promptflow = get_promptflow_sdk_version() if version_promptflow: return version_promptflow @@ -190,7 +190,7 @@ def is_pfs_service_healthy(pfs_port) -> bool: try: response = requests.get("http://localhost:{}/heartbeat".format(pfs_port)) if response.status_code == 200: - logger.debug(f"Promptflow service is already running on port {pfs_port}, {response.text}") + logger.debug(f"Prompt flow service is already running on port {pfs_port}, {response.text}") match = re.search(r'"promptflow":"(.*?)"', response.text) if match: version = match.group(1) @@ -198,12 +198,12 @@ def is_pfs_service_healthy(pfs_port) -> bool: is_healthy = version == local_version if not is_healthy: logger.warning( - f"Promptflow service is running on port {pfs_port}, but the version is not the same as " + f"Prompt flow service is running on port {pfs_port}, but the version is not the same as " f"local sdk version {local_version}. The service version is {version}." ) else: is_healthy = False - logger.warning("/heartbeat response doesn't contain current promptflow service version.") + logger.warning("/heartbeat response doesn't contain current prompt flow service version.") return is_healthy except Exception: # pylint: disable=broad-except pass @@ -217,7 +217,7 @@ def check_pfs_service_status(pfs_port, time_delay=1, count_threshold=10) -> bool is_healthy = is_pfs_service_healthy(pfs_port) while is_healthy is False and count_threshold > cnt: message = ( - f"Waiting for the Promptflow service status to become healthy... It has been tried for {cnt} times, will " + f"Waiting for the prompt flow service status to become healthy... It has been tried for {cnt} times, will " f"try at most {count_threshold} times." ) if cnt >= 3: @@ -307,7 +307,7 @@ def get_client_from_request(*, connection_provider=None) -> "PFClient": def is_run_from_built_binary(): """ - Use this function to trigger behavior difference between calling from promptflow sdk/cli and built binary. + Use this function to trigger behavior difference between calling from prompt flow sdk/cli and built binary. Allow customer to use environment variable to control the triggering. """ diff --git a/src/promptflow-devkit/promptflow/_sdk/_tracing.py b/src/promptflow-devkit/promptflow/_sdk/_tracing.py index 209d336244f..1bb6145508b 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_tracing.py +++ b/src/promptflow-devkit/promptflow/_sdk/_tracing.py @@ -92,12 +92,12 @@ def _invoke_pf_svc() -> str: cmd_args.append("--force") logger.debug("Prompt flow service is not healthy, force to start...") else: - print("Prompt flow Tracing Server has started...") + print("Prompt flow service has started...") print(hint_stop_message) return port add_executable_script_to_env_path() - print("Starting prompt flow Tracing Server...") + print("Starting prompt flow service...") start_pfs = None try: start_pfs = subprocess.Popen(cmd_args, shell=platform.system() == "Windows", stderr=subprocess.PIPE) From 04f362f0ba58c16606e8079e2a9e4a6400714bb3 Mon Sep 17 00:00:00 2001 From: Ying Chen <2601502859@qq.com> Date: Fri, 12 Apr 2024 10:19:09 +0800 Subject: [PATCH 7/7] update --- src/promptflow-devkit/promptflow/_sdk/_tracing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/promptflow-devkit/promptflow/_sdk/_tracing.py b/src/promptflow-devkit/promptflow/_sdk/_tracing.py index 1bb6145508b..d830b575e54 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_tracing.py +++ b/src/promptflow-devkit/promptflow/_sdk/_tracing.py @@ -93,7 +93,6 @@ def _invoke_pf_svc() -> str: logger.debug("Prompt flow service is not healthy, force to start...") else: print("Prompt flow service has started...") - print(hint_stop_message) return port add_executable_script_to_env_path()