Skip to content

Commit

Permalink
add connection secret to context credential list
Browse files Browse the repository at this point in the history
  • Loading branch information
Min Shi committed Oct 23, 2023
1 parent 14a49a0 commit 1b2b816
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/promptflow/promptflow/_sdk/operations/_test_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from types import GeneratorType
from typing import Any, Mapping

from promptflow._internal import ConnectionManager
from promptflow._sdk._constants import LOGGER_NAME, PROMPT_FLOW_DIR_NAME
from promptflow._sdk._utils import dump_flow_result, parse_variant
from promptflow._sdk.entities._flow import Flow
Expand Down Expand Up @@ -149,12 +150,15 @@ def flow_test(

if not connections:
connections = SubmitterHelper.resolve_connections(flow=self.flow, client=self._client)
credential_list = ConnectionManager(connections).get_secret_list()

# resolve environment variables
SubmitterHelper.resolve_environment_variables(environment_variables=environment_variables, client=self._client)
environment_variables = environment_variables if environment_variables else {}
SubmitterHelper.init_env(environment_variables=environment_variables)

with LoggerOperations(file_path=self.flow.code / PROMPT_FLOW_DIR_NAME / "flow.log", stream=stream_log):
with LoggerOperations(file_path=self.flow.code / PROMPT_FLOW_DIR_NAME / "flow.log",\
stream=stream_log, credential_list=credential_list):
storage = DefaultRunStorage(base_dir=self.flow.code, sub_dir=Path(".promptflow/intermediate"))
flow_executor = FlowExecutor.create(
self.flow.path, connections, self.flow.code, storage=storage, raise_ex=False
Expand Down Expand Up @@ -190,11 +194,14 @@ def node_test(
from promptflow.executor import FlowExecutor

connections = SubmitterHelper.resolve_connections(flow=self.flow, client=self._client)
credential_list = ConnectionManager(connections).get_secret_list()

# resolve environment variables
SubmitterHelper.resolve_environment_variables(environment_variables=environment_variables, client=self._client)
SubmitterHelper.init_env(environment_variables=environment_variables)

with LoggerOperations(file_path=self.flow.code / PROMPT_FLOW_DIR_NAME / f"{node_name}.node.log", stream=stream):
with LoggerOperations(file_path=self.flow.code / PROMPT_FLOW_DIR_NAME / f"{node_name}.node.log",\
stream=stream, credential_list=credential_list):
result = FlowExecutor.load_and_exec_node(
self.flow.path,
node_name,
Expand Down

0 comments on commit 1b2b816

Please sign in to comment.