Skip to content

Add validation warnings to %choose magic for missing tasks/runs#128

Closed
kaggle-agent wants to merge 2 commits intocifrom
agent/psbang-20260410141748-045eace4
Closed

Add validation warnings to %choose magic for missing tasks/runs#128
kaggle-agent wants to merge 2 commits intocifrom
agent/psbang-20260410141748-045eace4

Conversation

@kaggle-agent
Copy link
Copy Markdown
Collaborator

When users run %choose with no tasks defined, they previously got
a confusing "run or evaluate" message. Now the magic distinguishes
between no tasks defined (links to @kbench.task docs) and tasks
defined but not run (links to .run()/.evaluate() docs). Warning
styling uses red text with code blocks at the same font size.

Co-authored-by: kaggle-agent [email protected]


Task: psbang-20260410141748-045eace4
Context: https://chat.kaggle.net/kaggle/pl/da7aknogw7g5xr5yrj6ep4jr7e

When users run `%choose` with no tasks defined, they previously got
a confusing "run or evaluate" message. Now the magic distinguishes
between no tasks defined (links to @kbench.task docs) and tasks
defined but not run (links to .run()/.evaluate() docs). Warning
styling uses red text with code blocks at the same font size.

Co-authored-by: kaggle-agent <[email protected]>
@psbang
Copy link
Copy Markdown
Contributor

psbang commented Apr 10, 2026

@kaggle-agent this is completely wrong. The logic should live entirely in typescript/projects/kernel-editor/src/kernels/components/benchmarks/utils.tsx. Remember my instructions:

Just one small nit I noticed, if I have no tasks defined in the notebook I still get the new message saying I need to run or evaluate the task. Maybe if there are no tasks defined we could add a similar message that says "No tasks detected. Please create a task using the @kbench.task decorator". The kbench.task could link to this documentation: https://github.com/Kaggle/kaggle-benchmarks/blob/ci/user_guide.md#the-kbenchtask-decorator

We could also have the new message you wrote link to the documentation [here](https://github.com/Kaggle/kaggle-benchmarks/blob/ci/quick_start.md#basic-task) at the .run() or .evaluate() text block.

This should be a follow up to https://github.com/Kaggle/kaggleazure/pull/41465/changes. The "new message" I'm referring to is the message that starts with "Building a task requires benchmark results."

Follow-up to PR #41465: when no tasks are defined in the notebook,
users saw the "run or evaluate" message which was confusing. Now we
show a distinct "No tasks detected" message linking to the
@kbench.task docs. Also adds doc links on .run()/.evaluate() text
pointing to quick_start.md#basic-task.

Co-authored-by: kaggle-agent <[email protected]>
@kaggle-agent
Copy link
Copy Markdown
Collaborator Author

Re: @psbang's review:

You're right, I apologize. I've fully reverted the Python SDK changes (ipython_magics.py restored to original, test_choose_magic.py deleted) and moved the logic to typescript/projects/kernel-editor/src/kernels/components/benchmarks/utils.tsx as a follow-up to PR #41465.

Changes to utils.tsx:

  1. No tasks detected (localTasks.length === 0): Added before the existing runTasks.length === 0 check. Displays "No tasks detected. Please create a task using the @kbench.task decorator" where @kbench.task is wrapped in TextLink → user_guide.md#the-kbenchtask-decorator and WarningCode for consistent font-size: 12px.

  2. Doc links on .run() / .evaluate(): Wrapped the existing code blocks in TextLink components pointing to quick_start.md#basic-task.

  3. Validation: Added localTasks.length === 0return false in validateBenchmarkTaskSelection.

All messages use the same WarningBody (red error color) + WarningCode (font-size: 12px) components as the existing "Can only save one task" warning.

@psbang psbang closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants