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

Benchmark run and artifact fix #229

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,38 +139,24 @@ jobs:

- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: benchmarks-debug
path: ./benchmarks/benchmark-results

- name: Fetch Artifact ID
id: fetch-artifact-id
uses: actions/github-script@v6
with:
script: |
const run_id = ${{ github.run_id }};
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id,
});
const artifact = artifacts.data.artifacts.find(artifact => artifact.name === 'benchmarks-debug');
return artifact.id;

- name: Comment on PR with benchmark results and download link
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const summaryPath = './benchmarks/benchmark-results/summary.md';
const contents = fs.readFileSync(summaryPath, 'utf8');
const artifactID = ${{ steps.fetch-artifact-id.outputs.result }};
const artifactID = ${{ steps.upload-artifact.outputs.artifact-id }};
const downloadURL = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${artifactID}`;

github.rest.issues.updateComment({
comment_id: ${{ env.BENCHMARKS_COMMENT_ID }},
owner: context.repo.owner,
repo: context.repo.repo,
body: '[Finished benchmarks](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})\n\n' + contents + '\n\n[Download Artifacts](' + downloadURL + ')'
body: '[Finished benchmarks](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})\n\n' + contents + '\n\n[Download artifacts](' + downloadURL + ')'
})
4 changes: 2 additions & 2 deletions benchmarks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"autotx/tests/agents/token/research/test_research_and_swap.py::test_auto_tx_research_swap_and_send_governance_token": "70.00",
"autotx/tests/agents/token/research/test_research.py::test_price_change_information": "90.00",
"autotx/tests/agents/token/research/test_research.py::test_get_top_5_tokens_from_base": "90.00",
"autotx/tests/agents/token/test_swap.py::test_auto_tx_swap_multiple": "90.00",
"autotx/tests/agents/token/test_swap_and_send.py::test_auto_tx_swap_and_send_complex": "20.00",
"autotx/tests/agents/token/test_swap.py::test_auto_tx_swap_multiple": "100.00",
"autotx/tests/agents/token/test_swap_and_send.py::test_auto_tx_swap_and_send_complex": "100.00",
"autotx/tests/agents/token/test_swap.py::test_auto_tx_swap_with_non_default_token": "100.00",
"autotx/tests/agents/token/research/test_research.py::test_get_top_5_most_traded_tokens_from_l1": "70.00",
"autotx/tests/agents/token/research/test_research.py::test_get_token_exchanges": "90.00",
Expand Down
3 changes: 3 additions & 0 deletions benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def run_test(test_name, iterations, avg_time_across_tests, completed_tests, rema
def print_summary_table(test_path: str, iterations: int, tests_results: dict, total_run_time: float, output_dir: str, total_benchmarks: dict):
"""Prints a summary table of all tests in markdown format to the console and a file, including total success percentage."""

# Sort test results
tests_results = sorted(tests_results, key=lambda x: x['name'])

# Calculate total passes and fails
total_passes = sum(result['passes'] for result in tests_results)
total_fails = sum(result['fails'] for result in tests_results)
Expand Down
Loading