Skip to content

Commit bf113b6

Browse files
authored
fix(cli): add --full-id flag to show complete batch IDs (#2068)
1 parent 94b7aed commit bf113b6

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

instructor/cli/batch.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
console = Console()
1616

1717

18-
def generate_table(batch_jobs: list[BatchJobInfo], provider: str):
19-
"""Generate enhanced table for batch jobs using unified BatchJobInfo objects"""
18+
def generate_table(batch_jobs: list[BatchJobInfo], provider: str, full_id: bool = False):
19+
"""Generate enhanced table for batch jobs using unified BatchJobInfo objects
20+
21+
Args:
22+
batch_jobs: List of batch job info objects
23+
provider: Provider name (openai, anthropic)
24+
full_id: If True, show full batch IDs without truncation
25+
"""
2026
table = Table(title=f"{provider.title()} Batch Jobs")
2127

22-
table.add_column("Batch ID", style="dim", max_width=20, no_wrap=True)
28+
# Adjust column width based on full_id flag
29+
id_max_width = None if full_id else 20
30+
table.add_column("Batch ID", style="dim", max_width=id_max_width, no_wrap=True)
2331
table.add_column("Status", min_width=10)
2432
table.add_column("Created", style="dim", min_width=10)
2533
table.add_column("Started", style="dim", min_width=10)
@@ -83,9 +91,9 @@ def generate_table(batch_jobs: list[BatchJobInfo], provider: str):
8391
hours = total_minutes / 60
8492
duration_str = f"{hours:.1f}h"
8593

86-
# Truncate batch ID for display
94+
# Truncate batch ID for display only if full_id is False
8795
batch_id_display = str(batch_job.id)
88-
if len(batch_id_display) > 18:
96+
if not full_id and len(batch_id_display) > 18:
8997
batch_id_display = batch_id_display[:15] + "..."
9098

9199
if provider == "openai":
@@ -162,6 +170,11 @@ def watch(
162170
None,
163171
help="[DEPRECATED] Use --model instead. Use Anthropic API instead of OpenAI",
164172
),
173+
full_id: bool = typer.Option(
174+
False,
175+
"--full-id",
176+
help="Show full batch IDs without truncation",
177+
),
165178
):
166179
"""
167180
Monitor the status of the most recent batch jobs
@@ -189,7 +202,7 @@ def watch(
189202
return
190203

191204
batch_jobs = get_jobs(limit, provider)
192-
table = generate_table(batch_jobs, provider)
205+
table = generate_table(batch_jobs, provider, full_id=full_id)
193206

194207
if not live:
195208
# Show table once and exit
@@ -200,7 +213,7 @@ def watch(
200213
with Live(table, refresh_per_second=2, screen=screen) as live_table:
201214
while True:
202215
batch_jobs = get_jobs(limit, provider)
203-
table = generate_table(batch_jobs, provider)
216+
table = generate_table(batch_jobs, provider, full_id=full_id)
204217
live_table.update(table)
205218
time.sleep(poll)
206219

0 commit comments

Comments
 (0)