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

feat: Easier entry point using bench commands #34

Merged
merged 1 commit into from
Dec 19, 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
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
working-directory: /home/runner/frappe-bench/sites
run: |
bench --site test_site set-config allow_tests true
source ../env/bin/activate
../apps/caffeine/caffeine/microbenchmarks/run_benchmarks.py --site test_site -l2 -p2 -w0 --quiet
bench --site test_site run-microbenchmarks -l2 -p2 -w0 --quiet
env:
TYPE: server
32 changes: 32 additions & 0 deletions caffeine/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import subprocess

import click
from frappe.commands import pass_context
from frappe.exceptions import SiteNotSpecifiedError


@click.command(
"run-microbenchmarks",
context_settings=dict(
ignore_unknown_options=True,
),
add_help_option=False,
)
@click.argument("benchargs", nargs=-1, type=click.UNPROCESSED)
@pass_context
def run_benchmarks(ctx, benchargs):
if not ctx.sites:
raise SiteNotSpecifiedError
site = ctx.sites[0]
benchargs = ("--site", site) + benchargs

from caffeine.microbenchmarks import run_benchmarks

# XXX: We can't invoke it directly pyperf wants to be the entry point
# Anyway, this shouldn't be a problem. It's no different than shell invoking it.
subprocess.check_call(["../env/bin/python3", run_benchmarks.__file__, *benchargs])


commands = [
run_benchmarks,
]
Loading