-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for class based eager flow without yaml (#2985)
# 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).** - [ ] **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. --------- Co-authored-by: Ying Chen <[email protected]>
- Loading branch information
1 parent
ec19c30
commit 0a7cde3
Showing
5 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/promptflow/tests/test_configs/eager_flows/basic_callable_class_without_yaml/init.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"obj_input": "val"} |
4 changes: 4 additions & 0 deletions
4
src/promptflow/tests/test_configs/eager_flows/basic_callable_class_without_yaml/inputs.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{"func_input": "func_input"} | ||
{"func_input": "func_input"} | ||
{"func_input": "func_input"} | ||
{"func_input": "func_input"} |
34 changes: 34 additions & 0 deletions
34
...tests/test_configs/eager_flows/basic_callable_class_without_yaml/simple_callable_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
from typing import TypedDict | ||
|
||
from promptflow.tracing import trace | ||
|
||
class FlowOutput(TypedDict): | ||
obj_input: str | ||
func_input: str | ||
obj_id: str | ||
|
||
|
||
class MyFlow: | ||
def __init__(self, obj_input: str): | ||
self.obj_input = obj_input | ||
|
||
@trace | ||
def __call__(self, func_input: str) -> FlowOutput: | ||
return { | ||
"obj_input": self.obj_input, | ||
"func_input": func_input, | ||
"obj_id": id(self), | ||
} | ||
|
||
def __aggregate__(self, results: list) -> dict: | ||
return {"length": len(results)} | ||
|
||
|
||
if __name__ == "__main__": | ||
flow = MyFlow("obj_input") | ||
result = flow("func_input") | ||
print(result) | ||
|