Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Add remote attach debug option compatible with poetry run #448

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions modelgauge/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import click
import debugpy
from modelgauge.base_test import PromptResponseTest
from modelgauge.command_line import (
DATA_DIR_OPTION,
Expand Down Expand Up @@ -183,6 +184,13 @@ def run_sut(
default=False,
help="Disable displaying the 'Processing TestItems' progress bar.",
)
@click.option(
"--debug",
is_flag=True,
show_default=True,
default=False,
help="Enable debugging with debugpy.",
)
def run_test(
test: str,
sut: str,
Expand All @@ -191,8 +199,16 @@ def run_test(
output_file: Optional[str],
no_caching: bool,
no_progress_bar: bool,
debug: bool,
):
"""Run the Test on the desired SUT and output the TestRecord."""
if debug:
port = 5678
host = 'localhost'
print(f"Waiting for debugger to attach on {host}:{port}")
debugpy.listen((host, port))
debugpy.wait_for_client()

secrets = load_secrets_from_config()
# Check for missing secrets without instantiating any objects
missing_secrets: List[MissingSecretValues] = []
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ tomli = "^2.0.1"
click = "^8.1.7"
typing-extensions = "^4.10.0"
tenacity = "^8.3.0"
debugpy = "^1.8.1"

[tool.poetry.group.dev.dependencies]
modelgauge_demo_plugin = {path = "demo_plugin", develop = true, optional=true}
Expand Down
Loading