Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
chjinche committed Oct 20, 2023
1 parent 1fd3bb7 commit a5173cb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


def my_list_func(prefix: str = "", size: int = 10, **kwargs) -> List[Dict[str, Union[str, int, float, list, Dict]]]:
import pdb; pdb.set_trace()
"""This is a dummy function to generate a list of items.
:param prefix: prefix to add to each item.
Expand Down
2 changes: 1 addition & 1 deletion src/promptflow/promptflow/_core/tools_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def append_workspace_triple_to_func_input_params(func_sig_params, func_input_par
# 1. func signature has kwargs param.
# 2. func signature has param named 'subscription_id','resource_group_name','workspace_name'.
has_kwargs_param = any([param.kind == inspect.Parameter.VAR_KEYWORD for _, param in func_sig_params.items()])
if has_kwargs_param == False:
if has_kwargs_param is False:
# keep only params that are in func signature. Or run into error when calling func.
avail_ws_info_dict = {k: v for k, v in ws_triple_dict.items() if k in set(func_sig_params.keys())}
else:
Expand Down
8 changes: 3 additions & 5 deletions src/promptflow/promptflow/_sdk/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,10 @@ def _generate_tool_meta(
return res


def _gen_dynamic_list(function_config) -> List:
def _gen_dynamic_list(function_config: Dict) -> List:
"""Generate dynamic list for a tool input.
:param function_config: function config in tool meta. It should contain
'func_path' and 'func_kwargs'.
:type function_config: dict
:param function_config: function config in tool meta. Should contain'func_path' and 'func_kwargs'.
:return: a list of tool input dynamic enums.
"""
func_path = function_config.get("func_path", "")
Expand All @@ -643,7 +641,7 @@ def _gen_dynamic_list(function_config) -> List:

workspace_triad = get_workspace_triad_from_local()
if (workspace_triad.subscription_id and workspace_triad.resource_group_name
and workspace_triad.workspace_name):
and workspace_triad.workspace_name):
return gen_dynamic_list(func_path, func_kwargs, workspace_triad._asdict())
# if no workspace triple available, just skip.
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def test_collect_package_tools_and_connections(self, install_custom_tool_pkg):
@pytest.skip("Will enable this test after new my_tool_package is released")
def test_gen_dynamic_list(self):
from promptflow._sdk._utils import _gen_dynamic_list
func_path="my_tool_package.tools.tool_with_dynamic_list_input.my_list_func"
func_kwargs={"prefix": "My"}
func_path = "my_tool_package.tools.tool_with_dynamic_list_input.my_list_func"
func_kwargs = {"prefix": "My"}
result = _gen_dynamic_list({
"func_path": func_path, "func_kwargs": func_kwargs})
assert len(result) == 10
Expand Down

0 comments on commit a5173cb

Please sign in to comment.