release v1: 65 held-out tasks, 78 bootstrap records, r2e_local adapter, manifest ae94c40b (part 2)
559318d verified Download heldout/beetbox__confuse-34cb3b91f309/tests/test.sh from Benjamin-eecs/openrsi-commit-runtime-assets: direct link, hf CLI and curl.
- Browser
- Download file 9.25 kB
-
https://huggingface.co/datasets/Benjamin-eecs/openrsi-commit-runtime-assets/resolve/main/heldout/beetbox__confuse-34cb3b91f309/tests/test.sh
- Command line
-
hf download hf://datasets/Benjamin-eecs/openrsi-commit-runtime-assets/heldout/beetbox__confuse-34cb3b91f309/tests/test.sh
-
curl -L -o test.sh https://huggingface.co/datasets/Benjamin-eecs/openrsi-commit-runtime-assets/resolve/main/heldout/beetbox__confuse-34cb3b91f309/tests/test.sh
9.25 kB
| set -uxo pipefail | |
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | |
| cd /workspace | |
| git config --global --add safe.directory /workspace | |
| mkdir -p /logs/verifier | |
| git checkout 7a60ee1d0e8c6d40d512f2d86de7ab4933e57c6a -- test/test_cli.py test/test_views.py || true | |
| git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH' | |
| diff --git a/test/test_cli.py b/test/test_cli.py | |
| index 3dc5004..3b7153b 100644 | |
| --- a/test/test_cli.py | |
| +++ b/test/test_cli.py | |
| @@ -2,6 +2,7 @@ from __future__ import division, absolute_import, print_function | |
| import confuse | |
| import argparse | |
| +from argparse import Namespace | |
| import optparse | |
| import unittest | |
| @@ -11,9 +12,9 @@ class ArgparseTest(unittest.TestCase): | |
| self.config = confuse.Configuration('test', read=False) | |
| self.parser = argparse.ArgumentParser() | |
| - def _parse(self, args): | |
| + def _parse(self, args, **kwargs): | |
| args = self.parser.parse_args(args.split()) | |
| - self.config.set_args(args) | |
| + self.config.set_args(args, **kwargs) | |
| def test_text_argument_parsed(self): | |
| self.parser.add_argument('--foo', metavar='BAR') | |
| @@ -38,15 +39,53 @@ class ArgparseTest(unittest.TestCase): | |
| self._parse('--foo bar') | |
| self.assertEqual(self.config['foo'].get(), 'bar') | |
| + def test_nested_destination_single(self): | |
| + self.parser.add_argument('--one', dest='one.foo') | |
| + self.parser.add_argument('--two', dest='one.two.foo') | |
| + self._parse('--two TWO', dots=True) | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| + | |
| + def test_nested_destination_nested(self): | |
| + self.parser.add_argument('--one', dest='one.foo') | |
| + self.parser.add_argument('--two', dest='one.two.foo') | |
| + self._parse('--two TWO --one ONE', dots=True) | |
| + self.assertEqual(self.config['one']['foo'].get(), 'ONE') | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| + | |
| + def test_nested_destination_nested_rev(self): | |
| + self.parser.add_argument('--one', dest='one.foo') | |
| + self.parser.add_argument('--two', dest='one.two.foo') | |
| + # Reverse to ensure order doesn't matter | |
| + self._parse('--one ONE --two TWO', dots=True) | |
| + self.assertEqual(self.config['one']['foo'].get(), 'ONE') | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| + | |
| + def test_nested_destination_clobber(self): | |
| + self.parser.add_argument('--one', dest='one.two') | |
| + self.parser.add_argument('--two', dest='one.two.foo') | |
| + self._parse('--two TWO --one ONE', dots=True) | |
| + # Clobbered | |
| + self.assertEqual(self.config['one']['two'].get(), {'foo': 'TWO'}) | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| + | |
| + def test_nested_destination_clobber_rev(self): | |
| + # Reversed order | |
| + self.parser.add_argument('--two', dest='one.two.foo') | |
| + self.parser.add_argument('--one', dest='one.two') | |
| + self._parse('--one ONE --two TWO', dots=True) | |
| + # Clobbered just the same | |
| + self.assertEqual(self.config['one']['two'].get(), {'foo': 'TWO'}) | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| + | |
| class OptparseTest(unittest.TestCase): | |
| def setUp(self): | |
| self.config = confuse.Configuration('test', read=False) | |
| self.parser = optparse.OptionParser() | |
| - def _parse(self, args): | |
| + def _parse(self, args, **kwargs): | |
| options, _ = self.parser.parse_args(args.split()) | |
| - self.config.set_args(options) | |
| + self.config.set_args(options, **kwargs) | |
| def test_text_argument_parsed(self): | |
| self.parser.add_option('--foo', metavar='BAR') | |
| @@ -71,10 +110,26 @@ class OptparseTest(unittest.TestCase): | |
| self._parse('--foo bar') | |
| self.assertEqual(self.config['foo'].get(), 'bar') | |
| + def test_nested_destination_single(self): | |
| + self.parser.add_option('--one', dest='one.foo') | |
| + self.parser.add_option('--two', dest='one.two.foo') | |
| + self._parse('--two TWO', dots=True) | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| -class Namespace(object): | |
| - def __init__(self, **kwargs): | |
| - self.__dict__.update(kwargs) | |
| + def test_nested_destination_nested(self): | |
| + self.parser.add_option('--one', dest='one.foo') | |
| + self.parser.add_option('--two', dest='one.two.foo') | |
| + self._parse('--two TWO --one ONE', dots=True) | |
| + self.assertEqual(self.config['one']['foo'].get(), 'ONE') | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| + | |
| + def test_nested_destination_nested_rev(self): | |
| + self.parser.add_option('--one', dest='one.foo') | |
| + self.parser.add_option('--two', dest='one.two.foo') | |
| + # Reverse to ensure order doesn't matter | |
| + self._parse('--one ONE --two TWO', dots=True) | |
| + self.assertEqual(self.config['one']['foo'].get(), 'ONE') | |
| + self.assertEqual(self.config['one']['two']['foo'].get(), 'TWO') | |
| class GenericNamespaceTest(unittest.TestCase): | |
| @@ -88,3 +143,14 @@ class GenericNamespaceTest(unittest.TestCase): | |
| def test_value_added_to_subview(self): | |
| self.config['baz'].set_args(Namespace(foo='bar')) | |
| self.assertEqual(self.config['baz']['foo'].get(), 'bar') | |
| + | |
| + def test_nested_namespace(self): | |
| + args = Namespace( | |
| + first="Hello", | |
| + nested=Namespace( | |
| + second="World" | |
| + ) | |
| + ) | |
| + self.config.set_args(args, dots=True) | |
| + self.assertEqual(self.config['first'].get(), 'Hello') | |
| + self.assertEqual(self.config['nested']['second'].get(), 'World') | |
| diff --git a/test/test_views.py b/test/test_views.py | |
| index 65fcb62..860633c 100644 | |
| --- a/test/test_views.py | |
| +++ b/test/test_views.py | |
| @@ -1,5 +1,7 @@ | |
| from __future__ import division, absolute_import, print_function | |
| +from argparse import Namespace | |
| +from collections import OrderedDict | |
| import confuse | |
| import sys | |
| import unittest | |
| @@ -237,3 +239,50 @@ class SetTest(unittest.TestCase): | |
| config = _root({'foo': ['a', 'b', 'c']}) | |
| config['foo'][1] = 'bar' | |
| self.assertEqual(config['foo'][1].get(), 'bar') | |
| + | |
| + | |
| +class BuildNamespaceDictTests(unittest.TestCase): | |
| + def test_pure_dicts(self): | |
| + config = {'foo': {'bar': 1}} | |
| + result = confuse.ConfigView._build_namespace_dict(config) | |
| + self.assertEqual(1, result['foo']['bar']) | |
| + | |
| + def test_namespaces(self): | |
| + config = Namespace(foo=Namespace(bar=2), another=1) | |
| + result = confuse.ConfigView._build_namespace_dict(config) | |
| + self.assertEqual(2, result['foo']['bar']) | |
| + self.assertEqual(1, result['another']) | |
| + | |
| + def test_dots_keys(self): | |
| + config = {'foo.bar': 1} | |
| + result = confuse.ConfigView._build_namespace_dict(config.copy()) | |
| + self.assertEqual(1, result['foo.bar']) | |
| + | |
| + result = confuse.ConfigView._build_namespace_dict(config.copy(), | |
| + dots=True) | |
| + self.assertEqual(1, result['foo']['bar']) | |
| + | |
| + def test_dots_keys_clobber(self): | |
| + args = [('foo.bar', 1), ('foo.bar.zar', 2)] | |
| + config = OrderedDict(args) | |
| + result = confuse.ConfigView._build_namespace_dict(config.copy(), | |
| + dots=True) | |
| + self.assertEqual({'zar': 2}, result['foo']['bar']) | |
| + self.assertEqual(2, result['foo']['bar']['zar']) | |
| + | |
| + # Reverse and do it again! (should be stable) | |
| + args.reverse() | |
| + config = OrderedDict(args) | |
| + result = confuse.ConfigView._build_namespace_dict(config.copy(), | |
| + dots=True) | |
| + self.assertEqual({'zar': 2}, result['foo']['bar']) | |
| + self.assertEqual(2, result['foo']['bar']['zar']) | |
| + | |
| + def test_dots_keys_no_clobber(self): | |
| + args = [('foo.bar', 1), ('foo.far', 2), ('foo.zar.dar', 4)] | |
| + config = OrderedDict(args) | |
| + result = confuse.ConfigView._build_namespace_dict(config.copy(), | |
| + dots=True) | |
| + self.assertEqual(1, result['foo']['bar']) | |
| + self.assertEqual(2, result['foo']['far']) | |
| + self.assertEqual(4, result['foo']['zar']['dar']) | |
| EOF_R2E_TEST_PATCH | |
| R2E_APPLY_RC=$? | |
| if [ "$R2E_APPLY_RC" -ne 0 ]; then | |
| echo "0.000000" > /logs/verifier/reward.txt | |
| printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json | |
| echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2 | |
| exit 0 | |
| fi | |
| ( python -m pytest -v test/test_cli.py test/test_views.py ) > /logs/verifier/test_output.log 2>&1 | |
| TEST_EXIT_CODE=$? | |
| cat /logs/verifier/test_output.log | |
| python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/test_cli.py test/test_views.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; } | |
| git checkout 7a60ee1d0e8c6d40d512f2d86de7ab4933e57c6a -- test/test_cli.py test/test_views.py || true | |
| exit 0 | |