Skip to content

Commit 8941c8f

Browse files
committed
feat: make showing outputs optional on the cli
1 parent c6427a3 commit 8941c8f

File tree

7 files changed

+57
-16
lines changed

7 files changed

+57
-16
lines changed

docs/Gallery/dataflow_pipelines.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,24 @@ Example output:
6464

6565
You'll notice that the output shows 1 message for `write_results` and 10 for the others. That is because it is reporting the number of messages _emitted_ from each step, and `write_results` is a sink that collects all messages.
6666

67-
The final message of the output will be the result file where the data are written:
67+
By default, QType shows a summary of the results. The final message will show:
6868

6969
```
7070
2026-01-16 11:23:35,151 - INFO: ✅ Flow execution completed successfully
71-
2026-01-16 11:23:35,151 - INFO: Processed 1 em
71+
2026-01-16 11:23:35,151 - INFO: Processed 1 rows
72+
2026-01-16 11:23:35,152 - INFO:
73+
Results summary: 1 rows, 1 columns: ['result_file']
74+
```
75+
76+
To see the full output data, add the `--show-output` flag:
77+
78+
```bash
79+
qtype run -i '{"output_path":"results.parquet"}' --progress --show-output examples/data_processing/dataflow_pipelines.qtype.yaml
80+
```
81+
82+
This will display:
83+
84+
```
7285
2026-01-16 11:23:35,152 - INFO:
7386
Results:
7487
result_file: results.parquet

docs/Gallery/research_assistant.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ qtype validate examples/research_assistant/research_assistant.qtype.yaml
5959

6060
# Run directly
6161
qtype run -i '{"topic":"Latest developments in retrieval augmented generation"}' \
62-
examples/research_assistant/research_assistant.qtype.yaml
62+
--show-output examples/research_assistant/research_assistant.qtype.yaml
6363
```
6464

6565
### Example Output

docs/Reference/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ qtype run [options] spec
3838
- **`-I INPUT_FILE, --input-file INPUT_FILE`** - Path to a file (e.g., CSV, JSON, Parquet) with input data for batch processing
3939
- **`-o OUTPUT, --output OUTPUT`** - Path to save output data. If input is a DataFrame, output will be saved as parquet. If single result, saved as JSON
4040
- **`--progress`** - Show progress bars during flow execution
41+
- **`--show-output`** - Display full output data in console (default: summary only)
4142

4243
#### Examples
4344

docs/Tutorials/01-first-qtype-application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Replace `sk-your-key-here` with your actual OpenAI API key.
180180
Run your application:
181181

182182
```bash
183-
qtype run -i '{"question":"What is 2+2?"}' 01_hello_world.qtype.yaml
183+
qtype run -i '{"question":"What is 2+2?"}' --show-output 01_hello_world.qtype.yaml
184184
```
185185

186186
**What you should see:**

docs/Tutorials/03-structured-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Should pass ✅
316316
### Run It!
317317

318318
```bash
319-
qtype run -i '{"review_text":"These headphones are amazing! Great sound quality and super comfortable. Battery lasts all day."}' 03_structured_data.qtype.yaml
319+
qtype run -i '{"review_text":"These headphones are amazing! Great sound quality and super comfortable. Battery lasts all day."}' --show-output 03_structured_data.qtype.yaml
320320
```
321321

322322
**Expected output:**

docs/Tutorials/04-tools-and-function-calling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Should pass ✅
305305
### Run the Application
306306

307307
```bash
308-
qtype run -i '{"days_until_due": 3}' 04_tools_and_function_calling.qtype.yaml
308+
qtype run -i '{"days_until_due": 3}' --show-output 04_tools_and_function_calling.qtype.yaml
309309
```
310310

311311
**Expected output:**

qtype/commands/run.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def run_flow(args: Any) -> None:
185185

186186
# Display results
187187
if len(result_df) > 0:
188-
logger.info(f"Processed {len(result_df)} em")
188+
logger.info(f"Processed {len(result_df)} rows")
189189

190190
# Remove 'row' and 'error' columns for display if all errors are None
191191
display_df = result_df.copy()
@@ -197,15 +197,37 @@ def run_flow(args: Any) -> None:
197197
if "row" in display_df.columns:
198198
display_df = display_df.drop(columns=["row"])
199199

200-
if len(display_df) > 1:
201-
logger.info(f"\nResults:\n{display_df[0:10].to_string()}\n...")
202-
else:
203-
# Print the first row with column_name: value one per line
204-
fmt_str = []
205-
for col, val in display_df.iloc[0].items():
206-
fmt_str.append(f"{col}: {val}")
207-
fmt_str = "\n".join(fmt_str)
208-
logger.info(f"\nResults:\n{fmt_str}")
200+
# Show summary for console display
201+
logger.info(
202+
f"\nResults summary: {len(display_df)} rows, "
203+
f"{len(display_df.columns)} columns: {list(display_df.columns)}"
204+
)
205+
206+
# Optionally show full output
207+
if args.show_output:
208+
# Truncate long strings for display
209+
max_col_width = 100
210+
for col in display_df.columns:
211+
display_df[col] = display_df[col].apply(
212+
lambda x: (
213+
f"{str(x)[:max_col_width]}..."
214+
if isinstance(x, str)
215+
and len(str(x)) > max_col_width
216+
else x
217+
)
218+
)
219+
220+
if len(display_df) > 1:
221+
logger.info(
222+
f"\nResults:\n{display_df[0:10].to_string()}\n..."
223+
)
224+
else:
225+
# Print the first row with column_name: value one per line
226+
fmt_str = []
227+
for col, val in display_df.iloc[0].items():
228+
fmt_str.append(f"{col}: {val}")
229+
fmt_str = "\n".join(fmt_str)
230+
logger.info(f"\nResults:\n{fmt_str}")
209231

210232
# Save the output
211233
if args.output:
@@ -267,6 +289,11 @@ def parser(subparsers: argparse._SubParsersAction) -> None:
267289
action="store_true",
268290
help="Show progress bars during flow execution.",
269291
)
292+
cmd_parser.add_argument(
293+
"--show-output",
294+
action="store_true",
295+
help="Display full output data in console (default: summary only).",
296+
)
270297

271298
cmd_parser.add_argument(
272299
"spec", type=str, help="Path to the QType YAML spec file."

0 commit comments

Comments
 (0)