Skip to content

Commit

Permalink
Post demo - Prepping for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
monoxgas committed Oct 24, 2024
1 parent 475ec5a commit c4408b9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
53 changes: 30 additions & 23 deletions dreadnode_cli/agent/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def get_model_provider_style(provider: str) -> str:
return {
"OpenAI": "spring_green4",
"Hugging Face": "blue",
"Dreadnode": "magenta",
"Dreadnode (private)": "magenta",
"Anthropic": "tan",
"Google": "cyan",
"MistralAI": "orange_red1",
"Groq": "red",
}.get(provider, "")
Expand All @@ -47,8 +48,12 @@ def pretty_container_logs(logs: str) -> str:


def format_duration(start: datetime | None, end: datetime | None) -> str:
if not (start and end):
start = start.astimezone() if start else None
end = (end or datetime.now()).astimezone()

if not start:
return "..."

return f"{(end - start).total_seconds():.1f}s"


Expand All @@ -73,26 +78,6 @@ def format_models(models: list[api.Client.StrikeModel]) -> RenderableType:
return table


def format_runs(runs: list[api.Client.StrikeRunSummaryResponse]) -> RenderableType:
table = Table(box=box.ROUNDED)
table.add_column("id", style="dim")
table.add_column("agent")
table.add_column("status")
table.add_column("started")
table.add_column("duration")

for run in runs:
table.add_row(
str(run.id),
f"[bold magenta]{run.agent_key}[/] [dim]:[/] [yellow]{run.agent_revision}[/]",
Text(run.status, style="bold " + get_status_style(run.status)),
format_time(run.start),
Text(format_duration(run.start, run.end), style="bold cyan"),
)

return table


def format_strikes(strikes: list[api.Client.StrikeSummaryResponse]) -> RenderableType:
table = Table(box=box.ROUNDED)
table.add_column("key")
Expand Down Expand Up @@ -230,7 +215,7 @@ def format_zones_verbose(zones: list[api.Client.StrikeRunZone], *, include_logs:
)
sub_components.append(outputs_panel)

if zone.agent_logs:
if include_logs and zone.agent_logs:
agent_log_panel = Panel(
pretty_container_logs(zone.agent_logs),
title="[dim]logs:[/] [bold]agent[/]",
Expand Down Expand Up @@ -286,3 +271,25 @@ def format_run(run: api.Client.StrikeRunResponse, *, verbose: bool = False, incl
]

return Panel(Group(*components), title=f"[bold]run [dim]{run.id}[/]", title_align="left", border_style="blue")


def format_runs(runs: list[api.Client.StrikeRunSummaryResponse]) -> RenderableType:
table = Table(box=box.ROUNDED)
table.add_column("id", style="dim")
table.add_column("agent")
table.add_column("status")
table.add_column("model")
table.add_column("started")
table.add_column("duration")

for run in runs:
table.add_row(
str(run.id),
f"[bold magenta]{run.agent_key}[/] [dim]:[/] [yellow]{run.agent_revision}[/]",
Text(run.status, style="bold " + get_status_style(run.status)),
Text(run.model or "-"),
format_time(run.start),
Text(format_duration(run.start, run.end), style="bold cyan"),
)

return table
5 changes: 3 additions & 2 deletions dreadnode_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ class StrikeAgentResponse(BaseModel):
name: str | None
created_at: datetime
latest_run_status: t.Optional["Client.StrikeRunStatus"]
latest_run_id: UUID | None
versions: list["Client.StrikeAgentVersion"]
latest_version: "Client.StrikeAgentVersion"
latest_run_id: UUID | None
revision: int

class StrikeAgentSummaryResponse(BaseModel):
Expand All @@ -274,8 +274,8 @@ class StrikeAgentSummaryResponse(BaseModel):
name: str | None
created_at: datetime
latest_run_status: t.Optional["Client.StrikeRunStatus"]
latest_version: "Client.StrikeAgentVersion"
latest_run_id: UUID | None
latest_version: "Client.StrikeAgentVersion"
revision: int

class StrikeRunOutputScore(BaseModel):
Expand Down Expand Up @@ -306,6 +306,7 @@ class StrikeRunSummaryResponse(BaseModel):
strike_name: str
strike_type: str
strike_description: str | None
model: str | None
agent_id: UUID
agent_key: str
agent_revision: int
Expand Down

0 comments on commit c4408b9

Please sign in to comment.