Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PF Recording/Replaying part for sdk_cli #719

Closed
wants to merge 61 commits into from
Closed

Conversation

crazygao
Copy link
Contributor

@crazygao crazygao commented Oct 11, 2023

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

Recording functionalities

  • PF_RECORDING_MODE is the key env var to control this test feature.
  • Record mode:
    • Get node run info (currently llm node), and save the info in the following key value pair
    • Key: Ordered dict of all inputs => sha1 hash value
    • Value: base64 of output value.
  • Replay mode:
    • hijack all llm nodes with customized tool, it calculate the hash of inputs, and get outputs.

Generated recording files will save in test_config/node_recordings folder

Some tricks

  1. for youtube urls add the following will enforce the language to German &hl=de&persist_hl=1
  2. Some output from url is not stable, mark these tests with Instable tests.

Time estimation
166 Tests run in 3min51s, total 226 tests estimate 5min18s
Most of the time is from fetching URLs.

About techniques of copying method and inject:
Currently I didn't get good ways to reuse the original method and make some patches to the method. All these mocked functions are copied and changed separately.

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.
  • Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: 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.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@crazygao crazygao requested a review from a team as a code owner October 11, 2023 07:15
@crazygao crazygao temporarily deployed to internal October 11, 2023 07:16 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 11, 2023 07:16 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 11, 2023 07:16 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 11, 2023 07:16 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 11, 2023 07:16 — with GitHub Actions Inactive
@github-actions github-actions bot added sdk prompt flow SDK promptflow labels Oct 11, 2023
@github-actions
Copy link

github-actions bot commented Oct 11, 2023

SDK CLI Global Config Test Result yigao/recording_draft

2 tests   2 ✔️  1m 3s ⏱️
1 suites  0 💤
1 files    0

Results for commit d3b4c4a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 11, 2023

Executor Unit Test Result yigao/recording_draft

413 tests   413 ✔️  48s ⏱️
    1 suites      0 💤
    1 files        0

Results for commit d3b4c4a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 11, 2023

SDK PFS E2E Test Result yigao/recording_draft

8 tests   8 ✔️  57s ⏱️
1 suites  0 💤
1 files    0

Results for commit d3b4c4a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 11, 2023

Executor E2E Test Result yigao/recording_draft

124 tests   122 ✔️  3m 32s ⏱️
    1 suites      2 💤
    1 files        0

Results for commit d3b4c4a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 11, 2023

SDK CLI Test Result yigao/recording_draft

320 tests   308 ✔️  23m 16s ⏱️
    1 suites    11 💤
    1 files        1

For more details on these failures, see this check.

Results for commit d3b4c4a.

♻️ This comment has been updated with latest results.

@crazygao crazygao temporarily deployed to internal October 13, 2023 03:10 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 03:10 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 03:10 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 03:10 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 03:10 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 06:19 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 06:19 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 06:19 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 06:19 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 06:19 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 13, 2023 11:05 — with GitHub Actions Inactive

def mock_bulkresult_get_openai_metrics(self):
# Some tests request the metrics in replay mode.
total_metrics = {"total_tokens": 0, "duration": 0}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this return a constant ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of the tests are testing against these constants.

example:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since our tool doesn't have a real llm connection, we need to mock these returns.

@crazygao crazygao temporarily deployed to internal October 30, 2023 08:26 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:26 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:26 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:26 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:26 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:31 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:31 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:31 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:31 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:31 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:33 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:33 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:33 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:33 — with GitHub Actions Inactive
@crazygao crazygao temporarily deployed to internal October 30, 2023 08:33 — with GitHub Actions Inactive
result = {}
for n in connection_names:
try:
conn = client.connections.get(name=n, with_secrets=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to mock this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Point. After replaying, this is useless.

return total_metrics


def mock_toolresolver_resolve_tool_by_node(recording_file: Path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstirng for why we need these fucntions

@crazygao crazygao deleted the yigao/recording_draft branch May 14, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants