inspect-ai 0.3.68__py3-none-any.whl → 0.3.70__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.
- inspect_ai/_cli/eval.py +13 -1
- inspect_ai/_display/plain/display.py +9 -11
- inspect_ai/_display/textual/app.py +5 -5
- inspect_ai/_display/textual/widgets/samples.py +47 -18
- inspect_ai/_display/textual/widgets/transcript.py +25 -12
- inspect_ai/_eval/eval.py +14 -2
- inspect_ai/_eval/evalset.py +6 -1
- inspect_ai/_eval/run.py +6 -0
- inspect_ai/_eval/task/run.py +44 -15
- inspect_ai/_eval/task/task.py +26 -3
- inspect_ai/_util/interrupt.py +15 -0
- inspect_ai/_util/logger.py +23 -0
- inspect_ai/_util/rich.py +7 -8
- inspect_ai/_util/text.py +301 -1
- inspect_ai/_util/transcript.py +10 -2
- inspect_ai/_util/working.py +46 -0
- inspect_ai/_view/www/dist/assets/index.css +56 -12
- inspect_ai/_view/www/dist/assets/index.js +905 -751
- inspect_ai/_view/www/log-schema.json +337 -2
- inspect_ai/_view/www/node_modules/flatted/python/flatted.py +149 -0
- inspect_ai/_view/www/node_modules/flatted/python/test.py +63 -0
- inspect_ai/_view/www/src/appearance/icons.ts +3 -1
- inspect_ai/_view/www/src/metadata/RenderedContent.tsx +0 -1
- inspect_ai/_view/www/src/samples/SampleDisplay.module.css +9 -1
- inspect_ai/_view/www/src/samples/SampleDisplay.tsx +28 -1
- inspect_ai/_view/www/src/samples/SampleSummaryView.module.css +4 -0
- inspect_ai/_view/www/src/samples/SampleSummaryView.tsx +23 -2
- inspect_ai/_view/www/src/samples/descriptor/score/ObjectScoreDescriptor.tsx +1 -1
- inspect_ai/_view/www/src/samples/transcript/SampleLimitEventView.tsx +4 -0
- inspect_ai/_view/www/src/samples/transcript/SandboxEventView.module.css +32 -0
- inspect_ai/_view/www/src/samples/transcript/SandboxEventView.tsx +152 -0
- inspect_ai/_view/www/src/samples/transcript/StepEventView.tsx +9 -2
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.tsx +19 -1
- inspect_ai/_view/www/src/samples/transcript/event/EventPanel.tsx +6 -3
- inspect_ai/_view/www/src/samples/transcript/types.ts +3 -1
- inspect_ai/_view/www/src/types/log.d.ts +188 -108
- inspect_ai/_view/www/src/utils/format.ts +7 -4
- inspect_ai/_view/www/src/workspace/WorkSpaceView.tsx +9 -6
- inspect_ai/log/__init__.py +2 -0
- inspect_ai/log/_condense.py +1 -0
- inspect_ai/log/_log.py +72 -12
- inspect_ai/log/_samples.py +5 -5
- inspect_ai/log/_transcript.py +31 -1
- inspect_ai/model/_call_tools.py +1 -1
- inspect_ai/model/_conversation.py +1 -1
- inspect_ai/model/_model.py +35 -16
- inspect_ai/model/_model_call.py +10 -3
- inspect_ai/model/_providers/anthropic.py +13 -2
- inspect_ai/model/_providers/bedrock.py +7 -0
- inspect_ai/model/_providers/cloudflare.py +20 -7
- inspect_ai/model/_providers/google.py +358 -302
- inspect_ai/model/_providers/groq.py +57 -23
- inspect_ai/model/_providers/hf.py +6 -0
- inspect_ai/model/_providers/mistral.py +81 -52
- inspect_ai/model/_providers/openai.py +9 -0
- inspect_ai/model/_providers/providers.py +6 -6
- inspect_ai/model/_providers/util/tracker.py +92 -0
- inspect_ai/model/_providers/vllm.py +13 -5
- inspect_ai/solver/_basic_agent.py +1 -3
- inspect_ai/solver/_bridge/patch.py +0 -2
- inspect_ai/solver/_limit.py +4 -4
- inspect_ai/solver/_plan.py +3 -3
- inspect_ai/solver/_solver.py +3 -0
- inspect_ai/solver/_task_state.py +10 -1
- inspect_ai/tool/_tools/_web_search.py +3 -3
- inspect_ai/util/_concurrency.py +14 -8
- inspect_ai/util/_sandbox/context.py +15 -0
- inspect_ai/util/_sandbox/docker/cleanup.py +8 -3
- inspect_ai/util/_sandbox/docker/compose.py +5 -9
- inspect_ai/util/_sandbox/docker/docker.py +20 -6
- inspect_ai/util/_sandbox/docker/util.py +10 -1
- inspect_ai/util/_sandbox/environment.py +32 -1
- inspect_ai/util/_sandbox/events.py +149 -0
- inspect_ai/util/_sandbox/local.py +3 -3
- inspect_ai/util/_sandbox/self_check.py +2 -1
- inspect_ai/util/_subprocess.py +4 -1
- {inspect_ai-0.3.68.dist-info → inspect_ai-0.3.70.dist-info}/METADATA +5 -5
- {inspect_ai-0.3.68.dist-info → inspect_ai-0.3.70.dist-info}/RECORD +82 -74
- {inspect_ai-0.3.68.dist-info → inspect_ai-0.3.70.dist-info}/LICENSE +0 -0
- {inspect_ai-0.3.68.dist-info → inspect_ai-0.3.70.dist-info}/WHEEL +0 -0
- {inspect_ai-0.3.68.dist-info → inspect_ai-0.3.70.dist-info}/entry_points.txt +0 -0
- {inspect_ai-0.3.68.dist-info → inspect_ai-0.3.70.dist-info}/top_level.txt +0 -0
@@ -830,6 +830,18 @@
|
|
830
830
|
"default": null,
|
831
831
|
"title": "Time Limit"
|
832
832
|
},
|
833
|
+
"working_limit": {
|
834
|
+
"anyOf": [
|
835
|
+
{
|
836
|
+
"type": "integer"
|
837
|
+
},
|
838
|
+
{
|
839
|
+
"type": "null"
|
840
|
+
}
|
841
|
+
],
|
842
|
+
"default": null,
|
843
|
+
"title": "Working Limit"
|
844
|
+
},
|
833
845
|
"max_samples": {
|
834
846
|
"anyOf": [
|
835
847
|
{
|
@@ -951,6 +963,7 @@
|
|
951
963
|
"message_limit",
|
952
964
|
"token_limit",
|
953
965
|
"time_limit",
|
966
|
+
"working_limit",
|
954
967
|
"max_samples",
|
955
968
|
"max_tasks",
|
956
969
|
"max_subprocesses",
|
@@ -1118,6 +1131,33 @@
|
|
1118
1131
|
"type": "object",
|
1119
1132
|
"additionalProperties": false
|
1120
1133
|
},
|
1134
|
+
"EvalMetricDefinition": {
|
1135
|
+
"properties": {
|
1136
|
+
"name": {
|
1137
|
+
"title": "Name",
|
1138
|
+
"type": "string"
|
1139
|
+
},
|
1140
|
+
"options": {
|
1141
|
+
"anyOf": [
|
1142
|
+
{
|
1143
|
+
"type": "object"
|
1144
|
+
},
|
1145
|
+
{
|
1146
|
+
"type": "null"
|
1147
|
+
}
|
1148
|
+
],
|
1149
|
+
"default": null,
|
1150
|
+
"title": "Options"
|
1151
|
+
}
|
1152
|
+
},
|
1153
|
+
"required": [
|
1154
|
+
"name",
|
1155
|
+
"options"
|
1156
|
+
],
|
1157
|
+
"title": "EvalMetricDefinition",
|
1158
|
+
"type": "object",
|
1159
|
+
"additionalProperties": false
|
1160
|
+
},
|
1121
1161
|
"EvalPlan": {
|
1122
1162
|
"description": "Plan (solvers) used in evaluation.",
|
1123
1163
|
"properties": {
|
@@ -1441,6 +1481,9 @@
|
|
1441
1481
|
{
|
1442
1482
|
"$ref": "#/$defs/SampleLimitEvent"
|
1443
1483
|
},
|
1484
|
+
{
|
1485
|
+
"$ref": "#/$defs/SandboxEvent"
|
1486
|
+
},
|
1444
1487
|
{
|
1445
1488
|
"$ref": "#/$defs/StateEvent"
|
1446
1489
|
},
|
@@ -1489,6 +1532,30 @@
|
|
1489
1532
|
"title": "Model Usage",
|
1490
1533
|
"type": "object"
|
1491
1534
|
},
|
1535
|
+
"total_time": {
|
1536
|
+
"anyOf": [
|
1537
|
+
{
|
1538
|
+
"type": "number"
|
1539
|
+
},
|
1540
|
+
{
|
1541
|
+
"type": "null"
|
1542
|
+
}
|
1543
|
+
],
|
1544
|
+
"default": null,
|
1545
|
+
"title": "Total Time"
|
1546
|
+
},
|
1547
|
+
"working_time": {
|
1548
|
+
"anyOf": [
|
1549
|
+
{
|
1550
|
+
"type": "number"
|
1551
|
+
},
|
1552
|
+
{
|
1553
|
+
"type": "null"
|
1554
|
+
}
|
1555
|
+
],
|
1556
|
+
"default": null,
|
1557
|
+
"title": "Working Time"
|
1558
|
+
},
|
1492
1559
|
"error": {
|
1493
1560
|
"anyOf": [
|
1494
1561
|
{
|
@@ -1535,6 +1602,8 @@
|
|
1535
1602
|
"store",
|
1536
1603
|
"events",
|
1537
1604
|
"model_usage",
|
1605
|
+
"total_time",
|
1606
|
+
"working_time",
|
1538
1607
|
"error",
|
1539
1608
|
"attachments",
|
1540
1609
|
"limit"
|
@@ -1550,6 +1619,7 @@
|
|
1550
1619
|
"enum": [
|
1551
1620
|
"context",
|
1552
1621
|
"time",
|
1622
|
+
"working",
|
1553
1623
|
"message",
|
1554
1624
|
"token",
|
1555
1625
|
"operator",
|
@@ -1790,6 +1860,84 @@
|
|
1790
1860
|
"type": "object",
|
1791
1861
|
"additionalProperties": false
|
1792
1862
|
},
|
1863
|
+
"EvalScorer": {
|
1864
|
+
"properties": {
|
1865
|
+
"name": {
|
1866
|
+
"title": "Name",
|
1867
|
+
"type": "string"
|
1868
|
+
},
|
1869
|
+
"options": {
|
1870
|
+
"anyOf": [
|
1871
|
+
{
|
1872
|
+
"type": "object"
|
1873
|
+
},
|
1874
|
+
{
|
1875
|
+
"type": "null"
|
1876
|
+
}
|
1877
|
+
],
|
1878
|
+
"default": null,
|
1879
|
+
"title": "Options"
|
1880
|
+
},
|
1881
|
+
"metrics": {
|
1882
|
+
"anyOf": [
|
1883
|
+
{
|
1884
|
+
"items": {
|
1885
|
+
"anyOf": [
|
1886
|
+
{
|
1887
|
+
"$ref": "#/$defs/EvalMetricDefinition"
|
1888
|
+
},
|
1889
|
+
{
|
1890
|
+
"additionalProperties": {
|
1891
|
+
"items": {
|
1892
|
+
"$ref": "#/$defs/EvalMetricDefinition"
|
1893
|
+
},
|
1894
|
+
"type": "array"
|
1895
|
+
},
|
1896
|
+
"type": "object"
|
1897
|
+
}
|
1898
|
+
]
|
1899
|
+
},
|
1900
|
+
"type": "array"
|
1901
|
+
},
|
1902
|
+
{
|
1903
|
+
"additionalProperties": {
|
1904
|
+
"items": {
|
1905
|
+
"$ref": "#/$defs/EvalMetricDefinition"
|
1906
|
+
},
|
1907
|
+
"type": "array"
|
1908
|
+
},
|
1909
|
+
"type": "object"
|
1910
|
+
},
|
1911
|
+
{
|
1912
|
+
"type": "null"
|
1913
|
+
}
|
1914
|
+
],
|
1915
|
+
"default": null,
|
1916
|
+
"title": "Metrics"
|
1917
|
+
},
|
1918
|
+
"metadata": {
|
1919
|
+
"anyOf": [
|
1920
|
+
{
|
1921
|
+
"type": "object"
|
1922
|
+
},
|
1923
|
+
{
|
1924
|
+
"type": "null"
|
1925
|
+
}
|
1926
|
+
],
|
1927
|
+
"default": null,
|
1928
|
+
"title": "Metadata"
|
1929
|
+
}
|
1930
|
+
},
|
1931
|
+
"required": [
|
1932
|
+
"name",
|
1933
|
+
"options",
|
1934
|
+
"metrics",
|
1935
|
+
"metadata"
|
1936
|
+
],
|
1937
|
+
"title": "EvalScorer",
|
1938
|
+
"type": "object",
|
1939
|
+
"additionalProperties": false
|
1940
|
+
},
|
1793
1941
|
"EvalSpec": {
|
1794
1942
|
"description": "Eval target and configuration.",
|
1795
1943
|
"properties": {
|
@@ -1939,6 +2087,45 @@
|
|
1939
2087
|
],
|
1940
2088
|
"default": null,
|
1941
2089
|
"title": "Metadata"
|
2090
|
+
},
|
2091
|
+
"scorers": {
|
2092
|
+
"anyOf": [
|
2093
|
+
{
|
2094
|
+
"items": {
|
2095
|
+
"$ref": "#/$defs/EvalScorer"
|
2096
|
+
},
|
2097
|
+
"type": "array"
|
2098
|
+
},
|
2099
|
+
{
|
2100
|
+
"type": "null"
|
2101
|
+
}
|
2102
|
+
],
|
2103
|
+
"default": null,
|
2104
|
+
"title": "Scorers"
|
2105
|
+
},
|
2106
|
+
"metrics": {
|
2107
|
+
"anyOf": [
|
2108
|
+
{
|
2109
|
+
"items": {
|
2110
|
+
"$ref": "#/$defs/EvalMetricDefinition"
|
2111
|
+
},
|
2112
|
+
"type": "array"
|
2113
|
+
},
|
2114
|
+
{
|
2115
|
+
"additionalProperties": {
|
2116
|
+
"items": {
|
2117
|
+
"$ref": "#/$defs/EvalMetricDefinition"
|
2118
|
+
},
|
2119
|
+
"type": "array"
|
2120
|
+
},
|
2121
|
+
"type": "object"
|
2122
|
+
},
|
2123
|
+
{
|
2124
|
+
"type": "null"
|
2125
|
+
}
|
2126
|
+
],
|
2127
|
+
"default": null,
|
2128
|
+
"title": "Metrics"
|
1942
2129
|
}
|
1943
2130
|
},
|
1944
2131
|
"required": [
|
@@ -1961,7 +2148,9 @@
|
|
1961
2148
|
"config",
|
1962
2149
|
"revision",
|
1963
2150
|
"packages",
|
1964
|
-
"metadata"
|
2151
|
+
"metadata",
|
2152
|
+
"scorers",
|
2153
|
+
"metrics"
|
1965
2154
|
],
|
1966
2155
|
"title": "EvalSpec",
|
1967
2156
|
"type": "object",
|
@@ -2662,11 +2851,23 @@
|
|
2662
2851
|
},
|
2663
2852
|
"title": "Response",
|
2664
2853
|
"type": "object"
|
2854
|
+
},
|
2855
|
+
"time": {
|
2856
|
+
"anyOf": [
|
2857
|
+
{
|
2858
|
+
"type": "number"
|
2859
|
+
},
|
2860
|
+
{
|
2861
|
+
"type": "null"
|
2862
|
+
}
|
2863
|
+
],
|
2864
|
+
"title": "Time"
|
2665
2865
|
}
|
2666
2866
|
},
|
2667
2867
|
"required": [
|
2668
2868
|
"request",
|
2669
|
-
"response"
|
2869
|
+
"response",
|
2870
|
+
"time"
|
2670
2871
|
],
|
2671
2872
|
"title": "ModelCall",
|
2672
2873
|
"type": "object",
|
@@ -3151,6 +3352,7 @@
|
|
3151
3352
|
"enum": [
|
3152
3353
|
"message",
|
3153
3354
|
"time",
|
3355
|
+
"working",
|
3154
3356
|
"token",
|
3155
3357
|
"operator",
|
3156
3358
|
"custom"
|
@@ -3213,6 +3415,133 @@
|
|
3213
3415
|
],
|
3214
3416
|
"type": "array"
|
3215
3417
|
},
|
3418
|
+
"SandboxEvent": {
|
3419
|
+
"description": "Sandbox execution or I/O",
|
3420
|
+
"properties": {
|
3421
|
+
"timestamp": {
|
3422
|
+
"format": "date-time",
|
3423
|
+
"title": "Timestamp",
|
3424
|
+
"type": "string"
|
3425
|
+
},
|
3426
|
+
"pending": {
|
3427
|
+
"anyOf": [
|
3428
|
+
{
|
3429
|
+
"type": "boolean"
|
3430
|
+
},
|
3431
|
+
{
|
3432
|
+
"type": "null"
|
3433
|
+
}
|
3434
|
+
],
|
3435
|
+
"default": null,
|
3436
|
+
"title": "Pending"
|
3437
|
+
},
|
3438
|
+
"event": {
|
3439
|
+
"const": "sandbox",
|
3440
|
+
"default": "sandbox",
|
3441
|
+
"title": "Event",
|
3442
|
+
"type": "string"
|
3443
|
+
},
|
3444
|
+
"action": {
|
3445
|
+
"enum": [
|
3446
|
+
"exec",
|
3447
|
+
"read_file",
|
3448
|
+
"write_file"
|
3449
|
+
],
|
3450
|
+
"title": "Action",
|
3451
|
+
"type": "string"
|
3452
|
+
},
|
3453
|
+
"cmd": {
|
3454
|
+
"anyOf": [
|
3455
|
+
{
|
3456
|
+
"type": "string"
|
3457
|
+
},
|
3458
|
+
{
|
3459
|
+
"type": "null"
|
3460
|
+
}
|
3461
|
+
],
|
3462
|
+
"default": null,
|
3463
|
+
"title": "Cmd"
|
3464
|
+
},
|
3465
|
+
"options": {
|
3466
|
+
"anyOf": [
|
3467
|
+
{
|
3468
|
+
"additionalProperties": {
|
3469
|
+
"$ref": "#/$defs/JsonValue"
|
3470
|
+
},
|
3471
|
+
"type": "object"
|
3472
|
+
},
|
3473
|
+
{
|
3474
|
+
"type": "null"
|
3475
|
+
}
|
3476
|
+
],
|
3477
|
+
"default": null,
|
3478
|
+
"title": "Options"
|
3479
|
+
},
|
3480
|
+
"file": {
|
3481
|
+
"anyOf": [
|
3482
|
+
{
|
3483
|
+
"type": "string"
|
3484
|
+
},
|
3485
|
+
{
|
3486
|
+
"type": "null"
|
3487
|
+
}
|
3488
|
+
],
|
3489
|
+
"default": null,
|
3490
|
+
"title": "File"
|
3491
|
+
},
|
3492
|
+
"input": {
|
3493
|
+
"anyOf": [
|
3494
|
+
{
|
3495
|
+
"type": "string"
|
3496
|
+
},
|
3497
|
+
{
|
3498
|
+
"type": "null"
|
3499
|
+
}
|
3500
|
+
],
|
3501
|
+
"default": null,
|
3502
|
+
"title": "Input"
|
3503
|
+
},
|
3504
|
+
"result": {
|
3505
|
+
"anyOf": [
|
3506
|
+
{
|
3507
|
+
"type": "integer"
|
3508
|
+
},
|
3509
|
+
{
|
3510
|
+
"type": "null"
|
3511
|
+
}
|
3512
|
+
],
|
3513
|
+
"default": null,
|
3514
|
+
"title": "Result"
|
3515
|
+
},
|
3516
|
+
"output": {
|
3517
|
+
"anyOf": [
|
3518
|
+
{
|
3519
|
+
"type": "string"
|
3520
|
+
},
|
3521
|
+
{
|
3522
|
+
"type": "null"
|
3523
|
+
}
|
3524
|
+
],
|
3525
|
+
"default": null,
|
3526
|
+
"title": "Output"
|
3527
|
+
}
|
3528
|
+
},
|
3529
|
+
"required": [
|
3530
|
+
"timestamp",
|
3531
|
+
"pending",
|
3532
|
+
"event",
|
3533
|
+
"action",
|
3534
|
+
"cmd",
|
3535
|
+
"options",
|
3536
|
+
"file",
|
3537
|
+
"input",
|
3538
|
+
"result",
|
3539
|
+
"output"
|
3540
|
+
],
|
3541
|
+
"title": "SandboxEvent",
|
3542
|
+
"type": "object",
|
3543
|
+
"additionalProperties": false
|
3544
|
+
},
|
3216
3545
|
"Score": {
|
3217
3546
|
"description": "Score generated by a scorer.",
|
3218
3547
|
"properties": {
|
@@ -3596,6 +3925,9 @@
|
|
3596
3925
|
{
|
3597
3926
|
"$ref": "#/$defs/SampleLimitEvent"
|
3598
3927
|
},
|
3928
|
+
{
|
3929
|
+
"$ref": "#/$defs/SandboxEvent"
|
3930
|
+
},
|
3599
3931
|
{
|
3600
3932
|
"$ref": "#/$defs/StateEvent"
|
3601
3933
|
},
|
@@ -3956,6 +4288,9 @@
|
|
3956
4288
|
{
|
3957
4289
|
"$ref": "#/$defs/SampleLimitEvent"
|
3958
4290
|
},
|
4291
|
+
{
|
4292
|
+
"$ref": "#/$defs/SandboxEvent"
|
4293
|
+
},
|
3959
4294
|
{
|
3960
4295
|
"$ref": "#/$defs/StateEvent"
|
3961
4296
|
},
|
@@ -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')
|
@@ -59,7 +59,8 @@ export const ApplicationIcons = {
|
|
59
59
|
custom: "bi bi-person-workspace",
|
60
60
|
operator: "bi bi-person-workspace",
|
61
61
|
tokens: "bi bi-list",
|
62
|
-
time: "bi bi-
|
62
|
+
time: "bi bi-clock",
|
63
|
+
execution: "bi bi-stopwatch",
|
63
64
|
},
|
64
65
|
logging: loggingIcons,
|
65
66
|
menu: "bi bi-list",
|
@@ -83,6 +84,7 @@ export const ApplicationIcons = {
|
|
83
84
|
running: "bi bi-stars",
|
84
85
|
sample: "bi bi-database",
|
85
86
|
samples: "bi bi-file-spreadsheet",
|
87
|
+
sandbox: "bi bi-box-seam",
|
86
88
|
scorer: "bi bi-calculator",
|
87
89
|
search: "bi bi-search",
|
88
90
|
solvers: {
|
@@ -9,7 +9,7 @@
|
|
9
9
|
.metadataPanel {
|
10
10
|
display: flex;
|
11
11
|
flex-wrap: wrap;
|
12
|
-
align-items:
|
12
|
+
align-items: stretch;
|
13
13
|
gap: 1em;
|
14
14
|
padding-left: 0;
|
15
15
|
margin-top: 0.5em;
|
@@ -27,3 +27,11 @@
|
|
27
27
|
.noTop {
|
28
28
|
margin-top: 0;
|
29
29
|
}
|
30
|
+
|
31
|
+
.timePanel {
|
32
|
+
display: grid;
|
33
|
+
grid-template-columns: max-content max-content;
|
34
|
+
grid-template-rows: auto;
|
35
|
+
column-gap: 0.5em;
|
36
|
+
min-width: 200px;
|
37
|
+
}
|