Skip to content

Commit

Permalink
[SDK]raise proper error when output's empty (#259)
Browse files Browse the repository at this point in the history
# Description

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).**

## 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
D-W- authored Sep 6, 2023
1 parent 0e7570f commit 139190c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/promptflow/promptflow/_sdk/operations/_run_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,14 @@ def _resolve_data(self, run: Run):
for input_key, local_file in input_dicts.items():
result[input_key] = load_data(local_file)
if run.run is not None:
variant_output = reverse_transpose(self.run_operations._get_outputs(run.run))
result["run.outputs"] = variant_output
variant_input = reverse_transpose(self.run_operations._get_inputs(run.run))
result["run.inputs"] = variant_input
referenced_outputs = self.run_operations._get_outputs(run.run)
if referenced_outputs:
variant_output = reverse_transpose(referenced_outputs)
result["run.outputs"] = variant_output
referenced_inputs = self.run_operations._get_inputs(run.run)
if referenced_inputs:
variant_input = reverse_transpose(referenced_inputs)
result["run.inputs"] = variant_input
return result

@classmethod
Expand Down
22 changes: 22 additions & 0 deletions src/promptflow/tests/sdk_cli_test/e2etests/test_flow_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,28 @@ def test_run_reference_failed_run(self, pf):
with pytest.raises(RunNotFoundError):
pf.runs.get(name=run_name)

def test_referenced_output_not_exist(self, pf):
# failed run won't generate output
failed_run = pf.run(
flow=f"{FLOWS_DIR}/failed_flow",
data=f"{DATAS_DIR}/webClassification1.jsonl",
column_mapping={"text": "${data.url}"},
)

run_name = str(uuid.uuid4())
with pytest.raises(MappingSourceNotFound) as e:
pf.run(
name=run_name,
run=failed_run,
flow=f"{FLOWS_DIR}/failed_flow",
column_mapping={"text": "${run.outputs.text}"},
)
assert "Couldn't find these mapping relations: ${run.outputs.text}." in str(e.value)

# run should not be created
with pytest.raises(RunNotFoundError):
pf.runs.get(name=run_name)

def test_connection_overwrite_file(self, local_client, local_aoai_connection):
run = create_yaml_run(
source=f"{RUNS_DIR}/run_with_connections.yaml",
Expand Down

0 comments on commit 139190c

Please sign in to comment.