Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Executor] Gen flow meta for eager flow (#2027)
# Description This pull request primarily adds function that generating flow meta for eager flow. the flow meta is similar to tool meta, including entry, function name, inputs, outputs and source. The function will be called by SDK and save the metadata to `flow.json`. Expected flow meta: ``` { "function": "my_flow", "entry": "flow_with_trace:my_flow", "inputs": { "text": { "type": "string" }, "models": { "type": "list" } }, "outputs": { "output": { "type": "string" } }, "source": "flow_with_trace.py" } ``` The most important changes are: New Functionality: * [`src/promptflow/promptflow/_core/tool_meta_generator.py`](diffhunk://#diff-5cd3c0319063421c9ff9210ca997e3f001e5d1e2c9f97b912f1a3f233f9ee5a6R103-R111): Added a new function `collect_flow_entry_in_module(m, entry)` to collect flow entries from a module. This function inspects the module members and returns the function corresponding to the provided entry. * [`src/promptflow/promptflow/_core/tool_meta_generator.py`](diffhunk://#diff-5cd3c0319063421c9ff9210ca997e3f001e5d1e2c9f97b912f1a3f233f9ee5a6R322-R340): Introduced another function `generate_flow_meta_dict_by_file(path: str, entry: str, source: str = None)`. This function generates a dictionary containing metadata about a eager flow, including its entry, function name, inputs, outputs, and source if provided. Unit Tests: * [`src/promptflow/tests/executor/unittests/_utils/test_generate_tool_meta_utils.py`](diffhunk://#diff-589487a3ccd77dbcc1241d9ee5d0678946185e6f4fea345c88d90e26dbc53631R38-R46): Added a new function `cd_and_run_generate_flow_meta(working_dir, source_path, entry, source=None)` to test the generation of flow metadata. * [`src/promptflow/tests/executor/unittests/_utils/test_generate_tool_meta_utils.py`](diffhunk://#diff-589487a3ccd77dbcc1241d9ee5d0678946185e6f4fea345c88d90e26dbc53631R100-R113): Included a new test case `test_generate_flow_meta(self, flow_dir, entry_path, entry)` to validate the functionality of the `generate_flow_meta_dict_by_file` function. Test Configurations: * [`src/promptflow/tests/test_configs/eager_flows/dummy_flow_with_trace/flow_with_trace.meta.json`](diffhunk://#diff-ba4a9d95000d35b60cd5133ecf22b71e457730888f2cbf6fd63f3cec96b691f1R1-R17): Added a new JSON file to the test configurations. This file contains metadata for the `my_flow` function from the `flow_with_trace.py` file. # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **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 - [x] Title of the pull request is clear and informative. - [x] 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 - [x] Pull request includes test coverage for the included changes. --------- Co-authored-by: Lina Tang <linatang@microsoft.com>
- Loading branch information