Skip to content

Commit

Permalink
raise exception when pfs inovke error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengfeiwang committed Apr 11, 2024
1 parent 07590a3 commit 8df1c3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/promptflow-devkit/promptflow/_sdk/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,9 @@ def __init__(
'please install it by running "pip install promptflow-azure" with your version.'
)
super().__init__(message=msg, no_personal_data_message=msg, **kwargs)


class PromptFlowServiceInvokeError(SDKError):
"""Exception raised if prompt flow service invoke failed."""

pass
5 changes: 5 additions & 0 deletions src/promptflow-devkit/promptflow/_sdk/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
AzureMLWorkspaceTriad,
ContextAttributeKey,
)
from promptflow._sdk._errors import PromptFlowServiceInvokeError
from promptflow._sdk._service.utils.utils import (
add_executable_script_to_env_path,
get_port_from_config,
Expand Down Expand Up @@ -258,6 +259,10 @@ def start_trace_with_devkit(

# invoke prompt flow service
pfs_port = _invoke_pf_svc()
if not is_pfs_service_healthy(pfs_port):
error_msg = "prompt flow service is not healthy, please check the logs for more details."
logger.error(error_msg)
raise PromptFlowServiceInvokeError(error_msg)

_inject_res_attrs_to_environ(pfs_port=pfs_port, collection=collection, exp=exp, ws_triad=ws_triad)
# instrument openai and setup exporter to pfs here for flex mode
Expand Down

0 comments on commit 8df1c3d

Please sign in to comment.