inspect-ai 0.3.65__py3-none-any.whl → 0.3.66__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,10 @@ def task_config(
35
35
  value = [str(v) for v in value]
36
36
  config_print.append(f"{name}: {','.join(value)}")
37
37
  elif name not in ["limit", "model"]:
38
+ if isinstance(value, list):
39
+ value = ",".join(value)
40
+ if isinstance(value, str):
41
+ value = value.replace("[", "\\[")
38
42
  config_print.append(f"{name}: {value}")
39
43
  values = ", ".join(config_print)
40
44
  if values:
@@ -0,0 +1,149 @@
1
+ # ISC License
2
+ #
3
+ # Copyright (c) 2018-2021, Andrea Giammarchi, @WebReflection
4
+ #
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+ #
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14
+ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ # PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ import json as _json
18
+
19
+ class _Known:
20
+ def __init__(self):
21
+ self.key = []
22
+ self.value = []
23
+
24
+ class _String:
25
+ def __init__(self, value):
26
+ self.value = value
27
+
28
+
29
+ def _array_keys(value):
30
+ keys = []
31
+ i = 0
32
+ for _ in value:
33
+ keys.append(i)
34
+ i += 1
35
+ return keys
36
+
37
+ def _object_keys(value):
38
+ keys = []
39
+ for key in value:
40
+ keys.append(key)
41
+ return keys
42
+
43
+ def _is_array(value):
44
+ return isinstance(value, list) or isinstance(value, tuple)
45
+
46
+ def _is_object(value):
47
+ return isinstance(value, dict)
48
+
49
+ def _is_string(value):
50
+ return isinstance(value, str)
51
+
52
+ def _index(known, input, value):
53
+ input.append(value)
54
+ index = str(len(input) - 1)
55
+ known.key.append(value)
56
+ known.value.append(index)
57
+ return index
58
+
59
+ def _loop(keys, input, known, output):
60
+ for key in keys:
61
+ value = output[key]
62
+ if isinstance(value, _String):
63
+ _ref(key, input[int(value.value)], input, known, output)
64
+
65
+ return output
66
+
67
+ def _ref(key, value, input, known, output):
68
+ if _is_array(value) and not value in known:
69
+ known.append(value)
70
+ value = _loop(_array_keys(value), input, known, value)
71
+ elif _is_object(value) and not value in known:
72
+ known.append(value)
73
+ value = _loop(_object_keys(value), input, known, value)
74
+
75
+ output[key] = value
76
+
77
+ def _relate(known, input, value):
78
+ if _is_string(value) or _is_array(value) or _is_object(value):
79
+ try:
80
+ return known.value[known.key.index(value)]
81
+ except:
82
+ return _index(known, input, value)
83
+
84
+ return value
85
+
86
+ def _transform(known, input, value):
87
+ if _is_array(value):
88
+ output = []
89
+ for val in value:
90
+ output.append(_relate(known, input, val))
91
+ return output
92
+
93
+ if _is_object(value):
94
+ obj = {}
95
+ for key in value:
96
+ obj[key] = _relate(known, input, value[key])
97
+ return obj
98
+
99
+ return value
100
+
101
+ def _wrap(value):
102
+ if _is_string(value):
103
+ return _String(value)
104
+
105
+ if _is_array(value):
106
+ i = 0
107
+ for val in value:
108
+ value[i] = _wrap(val)
109
+ i += 1
110
+
111
+ elif _is_object(value):
112
+ for key in value:
113
+ value[key] = _wrap(value[key])
114
+
115
+ return value
116
+
117
+ def parse(value, *args, **kwargs):
118
+ json = _json.loads(value, *args, **kwargs)
119
+ wrapped = []
120
+ for value in json:
121
+ wrapped.append(_wrap(value))
122
+
123
+ input = []
124
+ for value in wrapped:
125
+ if isinstance(value, _String):
126
+ input.append(value.value)
127
+ else:
128
+ input.append(value)
129
+
130
+ value = input[0]
131
+
132
+ if _is_array(value):
133
+ return _loop(_array_keys(value), input, [value], value)
134
+
135
+ if _is_object(value):
136
+ return _loop(_object_keys(value), input, [value], value)
137
+
138
+ return value
139
+
140
+
141
+ def stringify(value, *args, **kwargs):
142
+ known = _Known()
143
+ input = []
144
+ output = []
145
+ i = int(_index(known, input, value))
146
+ while i < len(input):
147
+ output.append(_transform(known, input, input[i]))
148
+ i += 1
149
+ return _json.dumps(output, *args, **kwargs)
@@ -0,0 +1,63 @@
1
+ from flatted import stringify as _stringify, parse
2
+
3
+ def stringify(value):
4
+ return _stringify(value, separators=(',', ':'))
5
+
6
+ assert stringify([None, None]) == '[[null,null]]'
7
+
8
+ a = []
9
+ o = {}
10
+
11
+ assert stringify(a) == '[[]]'
12
+ assert stringify(o) == '[{}]'
13
+
14
+ a.append(a)
15
+ o['o'] = o
16
+
17
+ assert stringify(a) == '[["0"]]'
18
+ assert stringify(o) == '[{"o":"0"}]'
19
+
20
+ b = parse(stringify(a))
21
+ assert isinstance(b, list) and b[0] == b
22
+
23
+ a.append(1)
24
+ a.append('two')
25
+ a.append(True)
26
+ o['one'] = 1
27
+ o['two'] = 'two'
28
+ o['three'] = True
29
+
30
+ assert stringify(a) == '[["0",1,"1",true],"two"]'
31
+ assert stringify(o) == '[{"o":"0","one":1,"two":"1","three":true},"two"]'
32
+
33
+ a.append(o)
34
+ o['a'] = a
35
+
36
+ assert stringify(a) == '[["0",1,"1",true,"2"],"two",{"o":"2","one":1,"two":"1","three":true,"a":"0"}]'
37
+ assert stringify(o) == '[{"o":"0","one":1,"two":"1","three":true,"a":"2"},"two",["2",1,"1",true,"0"]]'
38
+
39
+ a.append({'test': 'OK'})
40
+ a.append([1, 2, 3])
41
+
42
+ o['test'] = {'test': 'OK'}
43
+ o['array'] = [1, 2, 3]
44
+
45
+ assert stringify(a) == '[["0",1,"1",true,"2","3","4"],"two",{"o":"2","one":1,"two":"1","three":true,"a":"0","test":"3","array":"4"},{"test":"5"},[1,2,3],"OK"]'
46
+ assert stringify(o) == '[{"o":"0","one":1,"two":"1","three":true,"a":"2","test":"3","array":"4"},"two",["2",1,"1",true,"0","3","4"],{"test":"5"},[1,2,3],"OK"]'
47
+
48
+ a2 = parse(stringify(a));
49
+ o2 = parse(stringify(o));
50
+
51
+ assert a2[0] == a2
52
+ assert o2['o'] == o2
53
+
54
+ assert a2[1] == 1 and a2[2] == 'two' and a2[3] == True and isinstance(a2[4], dict)
55
+ assert a2[4] == a2[4]['o'] and a2 == a2[4]['o']['a']
56
+
57
+ str = parse('[{"prop":"1","a":"2","b":"3"},{"value":123},["4","5"],{"e":"6","t":"7","p":4},{},{"b":"8"},"f",{"a":"9"},["10"],"sup",{"a":1,"d":2,"c":"7","z":"11","h":1},{"g":2,"a":"7","b":"12","f":6},{"r":4,"u":"7","c":5}]')
58
+ assert str['b']['t']['a'] == 'sup' and str['a'][1]['b'][0]['c'] == str['b']['t']
59
+
60
+ oo = parse('[{"a":"1","b":"0","c":"2"},{"aa":"3"},{"ca":"4","cb":"5","cc":"6","cd":"7","ce":"8","cf":"9"},{"aaa":"10"},{"caa":"4"},{"cba":"5"},{"cca":"2"},{"cda":"4"},"value2","value3","value1"]');
61
+ assert oo['a']['aa']['aaa'] == 'value1' and oo == oo['b'] and oo['c']['ca']['caa'] == oo['c']['ca']
62
+
63
+ print('OK')
@@ -27,7 +27,9 @@ def resolve_compose_file(parent: str = "") -> str:
27
27
 
28
28
  # dockerfile just needs a compose.yaml synthesized
29
29
  elif has_dockerfile(parent):
30
- return auto_compose_file(COMPOSE_DOCKERFILE_YAML, parent)
30
+ return auto_compose_file(
31
+ COMPOSE_DOCKERFILE_YAML.format(dockerfile=DOCKERFILE), parent
32
+ )
31
33
 
32
34
  # otherwise provide a generic python container
33
35
  else:
@@ -92,6 +94,7 @@ services:
92
94
  default:
93
95
  build:
94
96
  context: "."
97
+ dockerfile: "{{dockerfile}}"
95
98
  command: "tail -f /dev/null"
96
99
  init: true
97
100
  network_mode: none
@@ -40,7 +40,8 @@ class ComposeProject:
40
40
  # if its a Dockerfile, then config is the auto-generated .compose.yaml
41
41
  if config_path and is_dockerfile(config_path.name):
42
42
  config = auto_compose_file(
43
- COMPOSE_DOCKERFILE_YAML, config_path.parent.as_posix()
43
+ COMPOSE_DOCKERFILE_YAML.format(dockerfile=config_path.name),
44
+ config_path.parent.as_posix(),
44
45
  )
45
46
 
46
47
  # if its another config file, just take its path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: inspect_ai
3
- Version: 0.3.65
3
+ Version: 0.3.66
4
4
  Summary: Framework for large language model evaluations
5
5
  Author: UK AI Security Institute
6
6
  License: MIT License
@@ -15,7 +15,7 @@ inspect_ai/_cli/util.py,sha256=rOyKR5p08-04IwJdcjakNXD1Gm-dGFtzaTTx7hyArPE,1402
15
15
  inspect_ai/_cli/view.py,sha256=QIL6QP0rJS5kcUzpIqKZMylx-zLAW2JXtjXoNjtxkHo,3113
16
16
  inspect_ai/_display/__init__.py,sha256=t9Xj8FbxvdBNsalnr16U0r3jSTFX9w4yXcUJwb06_6k,405
17
17
  inspect_ai/_display/core/active.py,sha256=6Z0-_6nduUp3UkGLbfYvrvgVVcnYdWLRkpvPOKZ_y5s,1259
18
- inspect_ai/_display/core/config.py,sha256=SuzdFbLTNy6BZYqpx3ZcCuWa0PYXGim4zWx2-JQdqLU,1961
18
+ inspect_ai/_display/core/config.py,sha256=9uEUjoLzcVXr2GxU5-WCEXyJDabCOpSXgnXyH-ETyw4,2130
19
19
  inspect_ai/_display/core/display.py,sha256=zgpNSU39pITyM_Xa41FsGIY5a4JtZbv7bDy7hjmJCM8,3057
20
20
  inspect_ai/_display/core/footer.py,sha256=wMe4P-4Bhx4WV01dUW12o9-KBAoD2CSCvWZ-9_CMSNU,805
21
21
  inspect_ai/_display/core/group.py,sha256=z8CIwQ-8Mm9adQ8JDuMjw94ih9GfymU5s-1qnbKoEPs,2871
@@ -140,6 +140,8 @@ inspect_ai/_view/www/dist/index.html,sha256=gpdu6SR-SOH9EWx15cCWHzujMZujnZR5tRlE
140
140
  inspect_ai/_view/www/dist/assets/favicon.svg,sha256=b9AHYZaO2zBzeKH6G4PwXZMGGW_UxY0omKHam-c9MAs,1508
141
141
  inspect_ai/_view/www/dist/assets/index.css,sha256=LXlByh-4-A1aCndGppGI5pnGE1jiUHayZ9VDuPBarno,893396
142
142
  inspect_ai/_view/www/dist/assets/index.js,sha256=cB5QrZSKv-815-Xr7xi8MZzkUdvGIFAn1PqtCiZ-X2g,2629550
143
+ inspect_ai/_view/www/node_modules/flatted/python/flatted.py,sha256=ke8FuEflns-WlphCcQ9CC0qJqWqX3zEEuak74o6rgE8,3879
144
+ inspect_ai/_view/www/node_modules/flatted/python/test.py,sha256=uTOn6HJd7KeY_PTRvvufv60dmvON3KWp3nnqACj8IlA,2129
143
145
  inspect_ai/_view/www/src/App.tsx,sha256=EvpnQfpWugx4PJivUN8GSUo8RXI4sHAFiIfacVXZ1Z0,28854
144
146
  inspect_ai/_view/www/src/AppErrorBoundary.tsx,sha256=RyhZWbIMZj1QeUOUUXh9hUFvq6LoDEoHuTY0giswmL0,1169
145
147
  inspect_ai/_view/www/src/constants.ts,sha256=UIxGbDscs61CcOQLQiW6MsZAU1uupSYNVLGxx2pp14A,1169
@@ -611,15 +613,15 @@ inspect_ai/util/_sandbox/self_check.py,sha256=YaonS0VQyutDpOlHchGhrIUm13juUzEkrk
611
613
  inspect_ai/util/_sandbox/service.py,sha256=2os7W8NYBDcaBoaHVfZ1YrI9hvldksmiwqkUYrCRCPo,11258
612
614
  inspect_ai/util/_sandbox/docker/cleanup.py,sha256=MK6UlADcWtTDotppeVJga2ibf9Ud-e4V-5ReoNbmhqg,4793
613
615
  inspect_ai/util/_sandbox/docker/compose.py,sha256=g98fwb33EsQQDHKEUYic8tPmi51IA7v3aWm3YoEBEgA,11904
614
- inspect_ai/util/_sandbox/docker/config.py,sha256=xXO3cc4dnN9cRYxjZHYgYmGQMPL8xwhHOC4SDjifIl8,2831
616
+ inspect_ai/util/_sandbox/docker/config.py,sha256=I2sxkN2mTS3kXoAGtJ2w7yuhMoacECgkdxiXftlAvKA,2918
615
617
  inspect_ai/util/_sandbox/docker/docker.py,sha256=Dhp2-H-CFPvHD0BlDNTZZtnXj0Jh9_IZjLl7qoyUaD4,17195
616
618
  inspect_ai/util/_sandbox/docker/internal.py,sha256=fATyk2pdtjSl-D0VPT4dmkXV-gOc5HrPH0EQDW4IAJY,1446
617
619
  inspect_ai/util/_sandbox/docker/prereqs.py,sha256=0j6_OauBBnVlpBleADcZavIAAQZy4WewVjbRn9c0stg,3355
618
620
  inspect_ai/util/_sandbox/docker/service.py,sha256=hhHIWH1VDFLwehdGd19aUBD_VKfDO3GCPxpw1HSwVQk,2437
619
- inspect_ai/util/_sandbox/docker/util.py,sha256=pSPsRGymrTmTnEUHiHoQSNqeurPP1mL5kB-105O6EWo,2794
620
- inspect_ai-0.3.65.dist-info/LICENSE,sha256=xZPCr8gTiFIerrA_DRpLAbw-UUftnLFsHxKeW-NTtq8,1081
621
- inspect_ai-0.3.65.dist-info/METADATA,sha256=nIJyGtqIHHKmAAWlL8DdZR00k3_EeATaqPxtU9j5L9E,4742
622
- inspect_ai-0.3.65.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
623
- inspect_ai-0.3.65.dist-info/entry_points.txt,sha256=WGGLmzTzDWLzYfiyovSY6oEKuf-gqzSDNOb5V-hk3fM,54
624
- inspect_ai-0.3.65.dist-info/top_level.txt,sha256=Tp3za30CHXJEKLk8xLe9qGsW4pBzJpEIOMHOHNCXiVo,11
625
- inspect_ai-0.3.65.dist-info/RECORD,,
621
+ inspect_ai/util/_sandbox/docker/util.py,sha256=CuYrt9iyLjPSVDEs_oGTas8wAwMwQc_45dZa2g3E4cY,2847
622
+ inspect_ai-0.3.66.dist-info/LICENSE,sha256=xZPCr8gTiFIerrA_DRpLAbw-UUftnLFsHxKeW-NTtq8,1081
623
+ inspect_ai-0.3.66.dist-info/METADATA,sha256=drMcoYJASKO4aBPr7_5b_wRXWNa7ZTFAZBIvQnLnxVY,4742
624
+ inspect_ai-0.3.66.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
625
+ inspect_ai-0.3.66.dist-info/entry_points.txt,sha256=WGGLmzTzDWLzYfiyovSY6oEKuf-gqzSDNOb5V-hk3fM,54
626
+ inspect_ai-0.3.66.dist-info/top_level.txt,sha256=Tp3za30CHXJEKLk8xLe9qGsW4pBzJpEIOMHOHNCXiVo,11
627
+ inspect_ai-0.3.66.dist-info/RECORD,,