Skip to content

Commit

Permalink
[Bug fix] Input is changed when rerun the node after run the overall …
Browse files Browse the repository at this point in the history
…flow (#1365)

# Description
node test supports dict as input.
inputs.jsonl generated by extension:
```
{
    "get_dict_val.output.value": {"key": "value"},
}
```
pf flow test --node xxx --inputs inputs.jsonl
Please add an informative description that covers that changes made by
the pull request and link all relevant issues.

# All Promptflow Contribution checklist:
- [ ] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [ ] Title of the pull request is clear and informative.
- [ ] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [ ] Pull request includes test coverage for the included changes.
  • Loading branch information
lalala123123 authored Dec 20, 2023
1 parent d94bd4f commit 518d203
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/promptflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### Features Added
- [SDK/CLI] Support `pfazure run cancel` to cancel a run on Azure AI.

### Bugs Fixed
- [SDK/CLI] Fix single node run doesn't work when consuming sub item of upstream node

### Improvements
- Change `ruamel.yaml` lower bound to 0.17.10.
- [SDK/CLI] Improve `pfazure run download` to handle large run data files.
Expand Down
9 changes: 6 additions & 3 deletions src/promptflow/promptflow/_sdk/_submitter/test_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ def resolve_data(
else:
missing_inputs.append(name)
continue
dependency_nodes_outputs[value.value] = (
{value.property: dependency_input} if value.property else dependency_input
)
if value.property:
dependency_nodes_outputs[value.value] = dependency_nodes_outputs.get(value.value, {})
if value.property in dependency_input:
dependency_nodes_outputs[value.value][value.property] = dependency_input[value.property]
else:
dependency_nodes_outputs[value.value] = dependency_input
merged_inputs[name] = dependency_input
elif value.value_type == InputValueType.FLOW_INPUT:
input_name = f"{value.prefix}{value.value}"
Expand Down
9 changes: 8 additions & 1 deletion src/promptflow/tests/sdk_cli_test/e2etests/test_flow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ def test_pf_test_with_non_english_input(self):

def test_pf_node_test_with_dict_input(self):
flow_path = Path(f"{FLOWS_DIR}/flow_with_dict_input").absolute()
inputs = {"get_dict_val.output.value": {"key": "value"}}
flow_inputs = {"key": {"input_key": "input_value"}}
result = _client._flows._test(flow=flow_path, inputs=flow_inputs)
assert result.run_info.status.value == "Completed"

inputs = {
"get_dict_val.output.value": result.node_run_infos["get_dict_val"].output,
"get_dict_val.output.origin_value": result.node_run_infos["get_dict_val"].output,
}
result = _client._flows._test(flow=flow_path, node="print_val", inputs=inputs)
assert result.status.value == "Completed"
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ nodes:
path: print_val.py
inputs:
val: ${get_dict_val.output.value}
origin_val: ${get_dict_val.output.origin_value}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def get_dict_val(key):
print(key)
if not isinstance(key, dict):
raise TypeError(f"key must be a dict, got {type(key)}")
return {"value": f"{key}: {type(key)}"}
return {"value": f"{key}: {type(key)}", "origin_value": key}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


@tool
def print_val(val):
def print_val(val, origin_val):
print(val)
print(origin_val)
if not isinstance(origin_val, dict):
raise TypeError(f"key must be a dict, got {type(origin_val)}")
return val

0 comments on commit 518d203

Please sign in to comment.