Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## Prompt

Fix Click's handling of string values supplied through default_map for multi-value parameters. When default_map provides a string for an option with nargs greater than 1, or for a tuple option type, Click should split the string the same way it splits environment variable values. Already-structured list or tuple values should still pass through unchanged, single-value string defaults should not be split, and explicit CLI arguments should still override default_map. Keep this as a surgical behavior fix with focused default-map coverage; do not update release notes, documentation, configuration, dependencies, generated files, or broad unrelated tests.
Fix Click's handling of string values supplied through default_map for multi-value parameters. When default_map provides a string for an option with nargs greater than 1, or for a tuple option type, Click should split the string the same way it splits environment variable values. Already-structured list or tuple values should still pass through unchanged, single-value string defaults should not be split, and explicit CLI arguments should still override default_map. Do not update release notes, documentation, configuration, dependencies, generated files, or broad unrelated tests.

## Reference

Expand All @@ -30,16 +30,6 @@ In Option.consume_value, when a value comes from default_map and is a string for
- PYTHONPATH={workspace}/src
- VIRTUAL_ENV={workspace}/.agentlab/venv

## Visible Validation

- `python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2, type=int)(lambda point: click.echo(repr(point)))); runner = CliRunner(); result = runner.invoke(cli, [], default_map={"point":"3 4"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == (3, 4), result.output; override = runner.invoke(cli, ["--point", "10", "20"], default_map={"point":"3 4"}); assert override.exit_code == 0, override.output; assert ast.literal_eval(override.output.strip()) == (10, 20), override.output'`
- `python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--word-pair", type=(str, str))(lambda word_pair: click.echo(repr(word_pair)))); result = CliRunner().invoke(cli, [], default_map={"word_pair":"hello world"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("hello", "world"), result.output'`
- `python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2, type=int)(lambda point: click.echo(repr(point)))); result = CliRunner().invoke(cli, [], default_map={"point":[5, 6]}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == (5, 6), result.output'`
- `python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2)(lambda point: click.echo(repr(point)))); result = CliRunner().invoke(cli, [], default_map={"point":("a", "b")}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("a", "b"), result.output'`
- `python -c 'import click; from click.testing import CliRunner; cli = click.command()(click.option("--name")(lambda name: click.echo(name))); result = CliRunner().invoke(cli, [], default_map={"name":"hello world"}); assert result.exit_code == 0, result.output; assert result.output.strip() == "hello world", result.output'`
- `python -m pytest tests/test_defaults.py`
- `git diff --check`

## Graders

### Setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ prompt: >
string the same way it splits environment variable values. Already-structured
list or tuple values should still pass through unchanged, single-value string
defaults should not be split, and explicit CLI arguments should still
override default_map. Keep this as a surgical behavior fix with focused
default-map coverage; do not update release notes, documentation,
override default_map. Do not update release notes, documentation,
configuration, dependencies, generated files, or broad unrelated tests.
reference_solution: >
In Option.consume_value, when a value comes from default_map and is a string
Expand Down Expand Up @@ -50,19 +49,6 @@ test:
python -c 'import click; from click.testing import CliRunner; cli = click.command()(click.option("--name")(lambda name: click.echo(name))); result = CliRunner().invoke(cli, [], default_map={"name":"hello world"}); assert result.exit_code == 0, result.output; assert result.output.strip() == "hello world", result.output'
- python -m pytest tests/test_defaults.py
- git diff --check
visible_validation:
- >-
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2, type=int)(lambda point: click.echo(repr(point)))); runner = CliRunner(); result = runner.invoke(cli, [], default_map={"point":"3 4"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == (3, 4), result.output; override = runner.invoke(cli, ["--point", "10", "20"], default_map={"point":"3 4"}); assert override.exit_code == 0, override.output; assert ast.literal_eval(override.output.strip()) == (10, 20), override.output'
- >-
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--word-pair", type=(str, str))(lambda word_pair: click.echo(repr(word_pair)))); result = CliRunner().invoke(cli, [], default_map={"word_pair":"hello world"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("hello", "world"), result.output'
- >-
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2, type=int)(lambda point: click.echo(repr(point)))); result = CliRunner().invoke(cli, [], default_map={"point":[5, 6]}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == (5, 6), result.output'
- >-
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2)(lambda point: click.echo(repr(point)))); result = CliRunner().invoke(cli, [], default_map={"point":("a", "b")}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("a", "b"), result.output'
- >-
python -c 'import click; from click.testing import CliRunner; cli = click.command()(click.option("--name")(lambda name: click.echo(name))); result = CliRunner().invoke(cli, [], default_map={"name":"hello world"}); assert result.exit_code == 0, result.output; assert result.output.strip() == "hello world", result.output'
- python -m pytest tests/test_defaults.py
- git diff --check
consent_style: silent
success:
tests_must_pass: true
Expand Down
7 changes: 1 addition & 6 deletions tasks/starter/2048-advanced-snake-params-001/task-card.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## Prompt

Fix the simulation metadata bug where trials using the advanced-snake heuristic do not persist their custom heuristic weights in the result payload. The CLI exposes this heuristic as advanced-snake, so a simulation with custom weights should return those weights in the params field and preserve the trial tag. Keep the patch focused and run the relevant tests.
Fix the simulation metadata bug where trials using the advanced-snake heuristic do not persist their custom heuristic weights in the result payload. The CLI exposes this heuristic as advanced-snake, so a simulation with custom weights should return those weights in the params field and preserve the trial tag.

## Reference

Expand All @@ -27,11 +27,6 @@ In simulation.py, persist params when args.heuristic is advanced-snake instead o
- PYTEST_ADDOPTS=-p no:cacheprovider
- PYTHONDONTWRITEBYTECODE=1

## Visible Validation

- `python3 -c "from types import SimpleNamespace; from simulation import run_single_simulation; from ai.heuristics import get_advanced_heuristic_with_weights; weights = {'empty': 1.0, 'smooth': 2.0, 'mono': 3.0, 'snake': 4.0}; heuristic = get_advanced_heuristic_with_weights(weights); args = SimpleNamespace(ai='expectimax', heuristic='advanced-snake', depth=1, tag='eval-smoke'); result = run_single_simulation((args, weights, heuristic, {'name': heuristic.name, 'version': heuristic.version, 'description': heuristic.description})); assert result['params'] == weights, result; assert result['tag'] == 'eval-smoke', result"`
- `python3 -c "from game import Game; game = Game(); assert game.board.shape == (4, 4); assert not game.game_over()"`

## Graders

### Setup
Expand Down
5 changes: 0 additions & 5 deletions tasks/starter/2048-advanced-snake-params-001/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ prompt: >
do not persist their custom heuristic weights in the result payload. The CLI
exposes this heuristic as advanced-snake, so a simulation with custom weights
should return those weights in the params field and preserve the trial tag.
Keep the patch focused and run the relevant tests.
reference_solution: >
In simulation.py, persist params when args.heuristic is advanced-snake instead
of the obsolete advanced name; a focused solution changes only that condition
Expand All @@ -25,10 +24,6 @@ environment:
PYTEST_ADDOPTS: "-p no:cacheprovider"
baseline:
- python3 -c "from game import Game; game = Game(); assert game.board.shape == (4, 4); assert not game.game_over()"
visible_validation:
- >-
python3 -c "from types import SimpleNamespace; from simulation import run_single_simulation; from ai.heuristics import get_advanced_heuristic_with_weights; weights = {'empty': 1.0, 'smooth': 2.0, 'mono': 3.0, 'snake': 4.0}; heuristic = get_advanced_heuristic_with_weights(weights); args = SimpleNamespace(ai='expectimax', heuristic='advanced-snake', depth=1, tag='eval-smoke'); result = run_single_simulation((args, weights, heuristic, {'name': heuristic.name, 'version': heuristic.version, 'description': heuristic.description})); assert result['params'] == weights, result; assert result['tag'] == 'eval-smoke', result"
- python3 -c "from game import Game; game = Game(); assert game.board.shape == (4, 4); assert not game.game_over()"
test:
- >-
python3 -c "from types import SimpleNamespace; from simulation import run_single_simulation; from ai.heuristics import get_advanced_heuristic_with_weights; weights = {'empty': 1.0, 'smooth': 2.0, 'mono': 3.0, 'snake': 4.0}; heuristic = get_advanced_heuristic_with_weights(weights); args = SimpleNamespace(ai='expectimax', heuristic='advanced-snake', depth=1, tag='eval-smoke'); result = run_single_simulation((args, weights, heuristic, {'name': heuristic.name, 'version': heuristic.version, 'description': heuristic.description})); assert result['params'] == weights, result; assert result['tag'] == 'eval-smoke', result"
Expand Down
8 changes: 1 addition & 7 deletions tasks/starter/click-default-map-nargs-001/task-card.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## Prompt

Fix Click's handling of string values supplied through default_map for multi-value parameters. When default_map provides a string for an option with nargs greater than 1, or for a tuple option type, Click should split the string the same way it splits environment variable values. Already-structured list or tuple values should still pass through unchanged, single-value string defaults should not be split, and explicit CLI arguments should still override default_map. Keep the production patch focused.
Fix Click's handling of string values supplied through default_map for multi-value parameters. When default_map provides a string for an option with nargs greater than 1, or for a tuple option type, Click should split the string the same way it splits environment variable values. Already-structured list or tuple values should still pass through unchanged, single-value string defaults should not be split, and explicit CLI arguments should still override default_map.

## Reference

Expand All @@ -30,12 +30,6 @@ In Option.consume_value, when a value comes from default_map and is a string for
- PYTHONPATH={workspace}/src
- VIRTUAL_ENV={workspace}/.agentlab/venv

## Visible Validation

- `python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2, type=int)(lambda point: click.echo(repr(point)))); runner = CliRunner(); result = runner.invoke(cli, [], default_map={"point":"3 4"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == (3, 4), result.output; override = runner.invoke(cli, ["--point", "10", "20"], default_map={"point":"3 4"}); assert override.exit_code == 0, override.output; assert ast.literal_eval(override.output.strip()) == (10, 20), override.output'`
- `python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--word-pair", type=(str, str))(lambda word_pair: click.echo(repr(word_pair)))); result = CliRunner().invoke(cli, [], default_map={"word_pair":"hello world"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("hello", "world"), result.output'`
- `python -c 'import click; from click.testing import CliRunner; cli = click.command()(click.option("--name")(lambda name: click.echo(name))); result = CliRunner().invoke(cli, [], default_map={"name":"hello world"}); assert result.exit_code == 0, result.output; assert result.output.strip() == "hello world", result.output'`

## Graders

### Setup
Expand Down
9 changes: 1 addition & 8 deletions tasks/starter/click-default-map-nargs-001/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ prompt: >
string the same way it splits environment variable values. Already-structured
list or tuple values should still pass through unchanged, single-value string
defaults should not be split, and explicit CLI arguments should still override
default_map. Keep the production patch focused.
default_map.
reference_solution: >
In Option.consume_value, when a value comes from default_map and is a string
for a multi-value parameter, split it with the parameter type's existing
Expand Down Expand Up @@ -40,13 +40,6 @@ test:
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--word-pair", type=(str, str))(lambda word_pair: click.echo(repr(word_pair)))); result = CliRunner().invoke(cli, [], default_map={"word_pair":"hello world"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("hello", "world"), result.output'
- >-
python -c 'import click; from click.testing import CliRunner; cli = click.command()(click.option("--name")(lambda name: click.echo(name))); result = CliRunner().invoke(cli, [], default_map={"name":"hello world"}); assert result.exit_code == 0, result.output; assert result.output.strip() == "hello world", result.output'
visible_validation:
- >-
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--point", nargs=2, type=int)(lambda point: click.echo(repr(point)))); runner = CliRunner(); result = runner.invoke(cli, [], default_map={"point":"3 4"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == (3, 4), result.output; override = runner.invoke(cli, ["--point", "10", "20"], default_map={"point":"3 4"}); assert override.exit_code == 0, override.output; assert ast.literal_eval(override.output.strip()) == (10, 20), override.output'
- >-
python -c 'import ast, click; from click.testing import CliRunner; cli = click.command()(click.option("--word-pair", type=(str, str))(lambda word_pair: click.echo(repr(word_pair)))); result = CliRunner().invoke(cli, [], default_map={"word_pair":"hello world"}); assert result.exit_code == 0, result.output; assert ast.literal_eval(result.output.strip()) == ("hello", "world"), result.output'
- >-
python -c 'import click; from click.testing import CliRunner; cli = click.command()(click.option("--name")(lambda name: click.echo(name))); result = CliRunner().invoke(cli, [], default_map={"name":"hello world"}); assert result.exit_code == 0, result.output; assert result.output.strip() == "hello world", result.output'
success:
tests_must_pass: true
max_files_changed: 2
Expand Down
Loading