@delta-infra/cli 1.1.1 → 1.1.2
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.
- package/README.md +1 -1
- package/checksums.txt +5 -5
- package/package.json +1 -1
- package/scripts/install-wizard.js +701 -701
- package/scripts/install.js +442 -442
- package/scripts/run.js +65 -65
- package/skills/delta-sandbox/SKILL.md +383 -383
- package/skills/delta-sandbox/agents/openai.yaml +4 -4
- package/skills/delta-sandbox/references/commands.md +58 -58
- package/skills/delta-sandbox/references/lifecycle.md +100 -100
- package/skills/delta-sandbox/references/recipes.md +138 -138
- package/skills/delta-science/AGENTS.md +47 -47
- package/skills/delta-science/SKILL.md +174 -174
- package/skills/delta-science/agents/openai.yaml +4 -4
- package/skills/delta-science/references/antbo.md +100 -100
- package/skills/delta-science/references/delta-bo.md +89 -89
- package/skills/delta-science/references/gsasii.md +116 -116
- package/skills/delta-science/references/lammps.md +66 -66
- package/skills/delta-science/references/ldm-bo.md +129 -129
- package/skills/delta-science/references/materials-design.md +118 -118
- package/skills/delta-science/references/pubchem.md +126 -126
- package/skills/delta-science/references/pymatgen.md +68 -68
- package/skills/delta-science/references/qe.md +125 -125
- package/skills/delta-science/references/rdkit.md +138 -138
- package/skills/delta-science/references/strbo.md +87 -87
- package/skills/delta-science/references/synbo.md +198 -198
- package/skills/delta-science/scripts/catalog.py +92 -92
- package/skills/delta-science/scripts/generated_catalog.py +69 -69
- package/skills/delta-science/scripts/invoke.py +346 -346
- package/skills/delta-shared/SKILL.md +97 -97
- package/skills/delta-shared/agents/openai.yaml +4 -4
- package/skills/manifest.json +19 -19
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
# SynBO operation 参考
|
|
2
|
-
|
|
3
|
-
所有在线调用都通过 `delta-cli science invoke`,服务地址来自 CLI 的标准
|
|
4
|
-
`base_url` 派生配置(`{base_url}/science_tool`)。这里的路径只说明业务 operation,不得据此直连 HTTP。
|
|
5
|
-
|
|
6
|
-
用户说“优化反应条件”“推荐下一批实验”“偶联反应怎么继续做”,或给出溶剂、温度、
|
|
7
|
-
催化剂、碱、配体和历史得率时,即使没有提到 SynBO、BO、CLI 或字段名也使用本节。
|
|
8
|
-
每个用户任务最多一次 SynBO 业务调用;成功后立即结束,validation、502、504、
|
|
9
|
-
timeout、断连或空 recommendations 均不得换参数、换模型或重试。
|
|
10
|
-
|
|
11
|
-
## Health
|
|
12
|
-
|
|
13
|
-
operation:`health`,无 body。
|
|
14
|
-
|
|
15
|
-
Reports SynBO import status, Torch/CUDA runtime availability, service limits,
|
|
16
|
-
default device, and visible CUDA devices.
|
|
17
|
-
|
|
18
|
-
Important fields inside gateway `data`:
|
|
19
|
-
|
|
20
|
-
```json
|
|
21
|
-
{
|
|
22
|
-
"status": "ok",
|
|
23
|
-
"synbo_available": true,
|
|
24
|
-
"metadata": {
|
|
25
|
-
"service": "synbo-service",
|
|
26
|
-
"engine": "synbo",
|
|
27
|
-
"version": "0.1.0",
|
|
28
|
-
"synbo_version": "0.1.0",
|
|
29
|
-
"default_device": "cpu",
|
|
30
|
-
"cuda_visible_devices": ""
|
|
31
|
-
},
|
|
32
|
-
"limits": {
|
|
33
|
-
"max_batch_size": 128,
|
|
34
|
-
"max_reaction_space_size": 200000,
|
|
35
|
-
"max_previous_rows": 10000
|
|
36
|
-
},
|
|
37
|
-
"runtime": {
|
|
38
|
-
"torch_available": true,
|
|
39
|
-
"cuda_available": false,
|
|
40
|
-
"cuda_device_count": 0,
|
|
41
|
-
"cuda_device_names": []
|
|
42
|
-
},
|
|
43
|
-
"warnings": []
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Initialize
|
|
48
|
-
|
|
49
|
-
operation:`initialize`。
|
|
50
|
-
|
|
51
|
-
Use for initial condition sampling when no measured previous results exist.
|
|
52
|
-
|
|
53
|
-
Request body:
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
{
|
|
57
|
-
"condition_dict": {
|
|
58
|
-
"catalyst": ["Pd(OAc)2", "Pd(PPh3)4", "Pd2(dba)3"],
|
|
59
|
-
"solvent": ["THF", "Dioxane", "Toluene"],
|
|
60
|
-
"base": ["K2CO3", "NaOEt", "DBU"]
|
|
61
|
-
},
|
|
62
|
-
"opt_metrics": ["yield"],
|
|
63
|
-
"opt_metric_settings": [
|
|
64
|
-
{"opt_direct": "max", "opt_range": [0, 100], "metric_weight": 1.0}
|
|
65
|
-
],
|
|
66
|
-
"batch_size": 3,
|
|
67
|
-
"sampling_method": "random",
|
|
68
|
-
"desc_normalize": "minmax",
|
|
69
|
-
"random_seed": 42
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Supported `sampling_method` values: `sobol`, `random`, `lhs`, `kmeans`.
|
|
74
|
-
|
|
75
|
-
## Optimize
|
|
76
|
-
|
|
77
|
-
operation:`optimize`。
|
|
78
|
-
|
|
79
|
-
Use after measured experiment rows are available. Each previous row must contain
|
|
80
|
-
all condition columns and all objective metric columns.
|
|
81
|
-
|
|
82
|
-
Request body:
|
|
83
|
-
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"condition_dict": {
|
|
87
|
-
"catalyst": ["Pd(OAc)2", "Pd(PPh3)4", "Pd2(dba)3"],
|
|
88
|
-
"solvent": ["THF", "Dioxane", "Toluene"],
|
|
89
|
-
"base": ["K2CO3", "NaOEt", "DBU"]
|
|
90
|
-
},
|
|
91
|
-
"opt_metrics": ["yield"],
|
|
92
|
-
"previous_results": [
|
|
93
|
-
{"batch": 0, "catalyst": "Pd(OAc)2", "solvent": "THF", "base": "K2CO3", "yield": 42.0},
|
|
94
|
-
{"batch": 0, "catalyst": "Pd(PPh3)4", "solvent": "Dioxane", "base": "NaOEt", "yield": 55.0},
|
|
95
|
-
{"batch": 0, "catalyst": "Pd2(dba)3", "solvent": "Toluene", "base": "DBU", "yield": 63.0}
|
|
96
|
-
],
|
|
97
|
-
"batch_size": 2,
|
|
98
|
-
"accuracy": "tiny",
|
|
99
|
-
"surrogate_model": "RF",
|
|
100
|
-
"acq_func": "UCB",
|
|
101
|
-
"device": "cpu",
|
|
102
|
-
"random_seed": 42
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 数值条件必须先离散化
|
|
107
|
-
|
|
108
|
-
SynBO 的 `condition_dict` 只接受显式列表,不接受连续范围对象。对于“温度
|
|
109
|
-
40–100°C、催化剂用量 0.5–2.0%”并已有 60/70/80/90°C 与
|
|
110
|
-
0.5/1.0/1.5/2.0% 历史值的任务,使用:
|
|
111
|
-
|
|
112
|
-
```json
|
|
113
|
-
{
|
|
114
|
-
"condition_dict": {
|
|
115
|
-
"solvent": ["ethanol", "acetonitrile", "DMSO"],
|
|
116
|
-
"temperature_C": ["40", "60", "70", "80", "90", "100"],
|
|
117
|
-
"catalyst_loading_pct": ["0.5", "1.0", "1.5", "2.0"]
|
|
118
|
-
},
|
|
119
|
-
"opt_metrics": ["yield"],
|
|
120
|
-
"previous_results": [
|
|
121
|
-
{
|
|
122
|
-
"batch": 0,
|
|
123
|
-
"solvent": "ethanol",
|
|
124
|
-
"temperature_C": "60",
|
|
125
|
-
"catalyst_loading_pct": "1.0",
|
|
126
|
-
"yield": 55.0
|
|
127
|
-
}
|
|
128
|
-
],
|
|
129
|
-
"batch_size": 3,
|
|
130
|
-
"accuracy": "tiny",
|
|
131
|
-
"surrogate_model": "RF",
|
|
132
|
-
"acq_func": "UCB",
|
|
133
|
-
"device": "cpu",
|
|
134
|
-
"random_seed": 42
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
约束:
|
|
139
|
-
|
|
140
|
-
- 每个条件值统一为字符串,objective metric 保持数值。
|
|
141
|
-
- 每条 `previous_results` 中的条件值必须出现在对应 `condition_dict` 列表中。
|
|
142
|
-
- 连续范围的离散网格必须包含用户上下界和全部历史观测值;最终答案必须说明实际网格。
|
|
143
|
-
- 将条件值显式序列化为字符串,并确保每条历史记录只使用 `condition_dict` 中列出的值。
|
|
144
|
-
如需小数据 CPU 设置,显式传递 `accuracy:"tiny"`、`surrogate_model:"RF"`、
|
|
145
|
-
`acq_func:"UCB"` 和 `device:"cpu"`;不得假定客户端会补充默认值。
|
|
146
|
-
|
|
147
|
-
Useful optional fields:
|
|
148
|
-
|
|
149
|
-
- `accuracy`: `tiny`, `low`, `medium`, `high`, or `ultra`.
|
|
150
|
-
- `acq_func`: `EHVI`, `UCB`, `ParEGO`, or `NEI`.
|
|
151
|
-
- `surrogate_model`: `GP`, `RF`, `BNN`, or `BayesianLinear`.
|
|
152
|
-
- `device`: `cpu`, `auto`, `cuda`, or `cuda:0`.
|
|
153
|
-
- `cuda_visible_devices`: request-level CUDA visibility hint. Use only when the
|
|
154
|
-
user explicitly asks for it and `/health` indicates a CUDA-capable runtime.
|
|
155
|
-
- `constraints`: map condition type to prohibited values.
|
|
156
|
-
|
|
157
|
-
## Descriptors
|
|
158
|
-
|
|
159
|
-
If omitted, SynBO uses generated OneHot descriptors. To provide descriptors:
|
|
160
|
-
|
|
161
|
-
```json
|
|
162
|
-
{
|
|
163
|
-
"descriptors": {
|
|
164
|
-
"solvent": [
|
|
165
|
-
{"name": "THF", "polarity": 0.207, "boiling_point_C": 66.0},
|
|
166
|
-
{"name": "Toluene", "polarity": 0.099, "boiling_point_C": 110.6}
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
"descriptor_index_col": "name"
|
|
170
|
-
}
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
`descriptors` must contain exactly the same keys as `condition_dict`. Descriptor
|
|
174
|
-
rows must include the configured index column and numeric descriptor columns.
|
|
175
|
-
|
|
176
|
-
## Error Handling
|
|
177
|
-
|
|
178
|
-
Gateway errors have the standard envelope:
|
|
179
|
-
|
|
180
|
-
```json
|
|
181
|
-
{
|
|
182
|
-
"code": 1,
|
|
183
|
-
"message": "SynBO service returned HTTP 400",
|
|
184
|
-
"data": {
|
|
185
|
-
"endpoint": "/synbo/optimize",
|
|
186
|
-
"synbo_response": {
|
|
187
|
-
"detail": "previous_results is missing metric columns: ['yield']"
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
常见原因包括条件空间过大、条件值重复、历史条件值不在 condition_dict 中、
|
|
194
|
-
descriptor 非数值、历史行缺列、metric 非数值,以及无 GPU 时请求 CUDA。
|
|
195
|
-
|
|
196
|
-
服务端有独立于客户端的单次请求时限。GP、EHVI、高 accuracy 或共享资源繁忙可能导致
|
|
197
|
-
timeout。普通用户任务中不得自动换参数重试;应报告“未产生推荐”,保留本次错误,
|
|
198
|
-
由用户决定是否另起一次明确的回归测试。
|
|
1
|
+
# SynBO operation 参考
|
|
2
|
+
|
|
3
|
+
所有在线调用都通过 `delta-cli science invoke`,服务地址来自 CLI 的标准
|
|
4
|
+
`base_url` 派生配置(`{base_url}/science_tool`)。这里的路径只说明业务 operation,不得据此直连 HTTP。
|
|
5
|
+
|
|
6
|
+
用户说“优化反应条件”“推荐下一批实验”“偶联反应怎么继续做”,或给出溶剂、温度、
|
|
7
|
+
催化剂、碱、配体和历史得率时,即使没有提到 SynBO、BO、CLI 或字段名也使用本节。
|
|
8
|
+
每个用户任务最多一次 SynBO 业务调用;成功后立即结束,validation、502、504、
|
|
9
|
+
timeout、断连或空 recommendations 均不得换参数、换模型或重试。
|
|
10
|
+
|
|
11
|
+
## Health
|
|
12
|
+
|
|
13
|
+
operation:`health`,无 body。
|
|
14
|
+
|
|
15
|
+
Reports SynBO import status, Torch/CUDA runtime availability, service limits,
|
|
16
|
+
default device, and visible CUDA devices.
|
|
17
|
+
|
|
18
|
+
Important fields inside gateway `data`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"status": "ok",
|
|
23
|
+
"synbo_available": true,
|
|
24
|
+
"metadata": {
|
|
25
|
+
"service": "synbo-service",
|
|
26
|
+
"engine": "synbo",
|
|
27
|
+
"version": "0.1.0",
|
|
28
|
+
"synbo_version": "0.1.0",
|
|
29
|
+
"default_device": "cpu",
|
|
30
|
+
"cuda_visible_devices": ""
|
|
31
|
+
},
|
|
32
|
+
"limits": {
|
|
33
|
+
"max_batch_size": 128,
|
|
34
|
+
"max_reaction_space_size": 200000,
|
|
35
|
+
"max_previous_rows": 10000
|
|
36
|
+
},
|
|
37
|
+
"runtime": {
|
|
38
|
+
"torch_available": true,
|
|
39
|
+
"cuda_available": false,
|
|
40
|
+
"cuda_device_count": 0,
|
|
41
|
+
"cuda_device_names": []
|
|
42
|
+
},
|
|
43
|
+
"warnings": []
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Initialize
|
|
48
|
+
|
|
49
|
+
operation:`initialize`。
|
|
50
|
+
|
|
51
|
+
Use for initial condition sampling when no measured previous results exist.
|
|
52
|
+
|
|
53
|
+
Request body:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"condition_dict": {
|
|
58
|
+
"catalyst": ["Pd(OAc)2", "Pd(PPh3)4", "Pd2(dba)3"],
|
|
59
|
+
"solvent": ["THF", "Dioxane", "Toluene"],
|
|
60
|
+
"base": ["K2CO3", "NaOEt", "DBU"]
|
|
61
|
+
},
|
|
62
|
+
"opt_metrics": ["yield"],
|
|
63
|
+
"opt_metric_settings": [
|
|
64
|
+
{"opt_direct": "max", "opt_range": [0, 100], "metric_weight": 1.0}
|
|
65
|
+
],
|
|
66
|
+
"batch_size": 3,
|
|
67
|
+
"sampling_method": "random",
|
|
68
|
+
"desc_normalize": "minmax",
|
|
69
|
+
"random_seed": 42
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Supported `sampling_method` values: `sobol`, `random`, `lhs`, `kmeans`.
|
|
74
|
+
|
|
75
|
+
## Optimize
|
|
76
|
+
|
|
77
|
+
operation:`optimize`。
|
|
78
|
+
|
|
79
|
+
Use after measured experiment rows are available. Each previous row must contain
|
|
80
|
+
all condition columns and all objective metric columns.
|
|
81
|
+
|
|
82
|
+
Request body:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"condition_dict": {
|
|
87
|
+
"catalyst": ["Pd(OAc)2", "Pd(PPh3)4", "Pd2(dba)3"],
|
|
88
|
+
"solvent": ["THF", "Dioxane", "Toluene"],
|
|
89
|
+
"base": ["K2CO3", "NaOEt", "DBU"]
|
|
90
|
+
},
|
|
91
|
+
"opt_metrics": ["yield"],
|
|
92
|
+
"previous_results": [
|
|
93
|
+
{"batch": 0, "catalyst": "Pd(OAc)2", "solvent": "THF", "base": "K2CO3", "yield": 42.0},
|
|
94
|
+
{"batch": 0, "catalyst": "Pd(PPh3)4", "solvent": "Dioxane", "base": "NaOEt", "yield": 55.0},
|
|
95
|
+
{"batch": 0, "catalyst": "Pd2(dba)3", "solvent": "Toluene", "base": "DBU", "yield": 63.0}
|
|
96
|
+
],
|
|
97
|
+
"batch_size": 2,
|
|
98
|
+
"accuracy": "tiny",
|
|
99
|
+
"surrogate_model": "RF",
|
|
100
|
+
"acq_func": "UCB",
|
|
101
|
+
"device": "cpu",
|
|
102
|
+
"random_seed": 42
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 数值条件必须先离散化
|
|
107
|
+
|
|
108
|
+
SynBO 的 `condition_dict` 只接受显式列表,不接受连续范围对象。对于“温度
|
|
109
|
+
40–100°C、催化剂用量 0.5–2.0%”并已有 60/70/80/90°C 与
|
|
110
|
+
0.5/1.0/1.5/2.0% 历史值的任务,使用:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"condition_dict": {
|
|
115
|
+
"solvent": ["ethanol", "acetonitrile", "DMSO"],
|
|
116
|
+
"temperature_C": ["40", "60", "70", "80", "90", "100"],
|
|
117
|
+
"catalyst_loading_pct": ["0.5", "1.0", "1.5", "2.0"]
|
|
118
|
+
},
|
|
119
|
+
"opt_metrics": ["yield"],
|
|
120
|
+
"previous_results": [
|
|
121
|
+
{
|
|
122
|
+
"batch": 0,
|
|
123
|
+
"solvent": "ethanol",
|
|
124
|
+
"temperature_C": "60",
|
|
125
|
+
"catalyst_loading_pct": "1.0",
|
|
126
|
+
"yield": 55.0
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"batch_size": 3,
|
|
130
|
+
"accuracy": "tiny",
|
|
131
|
+
"surrogate_model": "RF",
|
|
132
|
+
"acq_func": "UCB",
|
|
133
|
+
"device": "cpu",
|
|
134
|
+
"random_seed": 42
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
约束:
|
|
139
|
+
|
|
140
|
+
- 每个条件值统一为字符串,objective metric 保持数值。
|
|
141
|
+
- 每条 `previous_results` 中的条件值必须出现在对应 `condition_dict` 列表中。
|
|
142
|
+
- 连续范围的离散网格必须包含用户上下界和全部历史观测值;最终答案必须说明实际网格。
|
|
143
|
+
- 将条件值显式序列化为字符串,并确保每条历史记录只使用 `condition_dict` 中列出的值。
|
|
144
|
+
如需小数据 CPU 设置,显式传递 `accuracy:"tiny"`、`surrogate_model:"RF"`、
|
|
145
|
+
`acq_func:"UCB"` 和 `device:"cpu"`;不得假定客户端会补充默认值。
|
|
146
|
+
|
|
147
|
+
Useful optional fields:
|
|
148
|
+
|
|
149
|
+
- `accuracy`: `tiny`, `low`, `medium`, `high`, or `ultra`.
|
|
150
|
+
- `acq_func`: `EHVI`, `UCB`, `ParEGO`, or `NEI`.
|
|
151
|
+
- `surrogate_model`: `GP`, `RF`, `BNN`, or `BayesianLinear`.
|
|
152
|
+
- `device`: `cpu`, `auto`, `cuda`, or `cuda:0`.
|
|
153
|
+
- `cuda_visible_devices`: request-level CUDA visibility hint. Use only when the
|
|
154
|
+
user explicitly asks for it and `/health` indicates a CUDA-capable runtime.
|
|
155
|
+
- `constraints`: map condition type to prohibited values.
|
|
156
|
+
|
|
157
|
+
## Descriptors
|
|
158
|
+
|
|
159
|
+
If omitted, SynBO uses generated OneHot descriptors. To provide descriptors:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"descriptors": {
|
|
164
|
+
"solvent": [
|
|
165
|
+
{"name": "THF", "polarity": 0.207, "boiling_point_C": 66.0},
|
|
166
|
+
{"name": "Toluene", "polarity": 0.099, "boiling_point_C": 110.6}
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
"descriptor_index_col": "name"
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`descriptors` must contain exactly the same keys as `condition_dict`. Descriptor
|
|
174
|
+
rows must include the configured index column and numeric descriptor columns.
|
|
175
|
+
|
|
176
|
+
## Error Handling
|
|
177
|
+
|
|
178
|
+
Gateway errors have the standard envelope:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"code": 1,
|
|
183
|
+
"message": "SynBO service returned HTTP 400",
|
|
184
|
+
"data": {
|
|
185
|
+
"endpoint": "/synbo/optimize",
|
|
186
|
+
"synbo_response": {
|
|
187
|
+
"detail": "previous_results is missing metric columns: ['yield']"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
常见原因包括条件空间过大、条件值重复、历史条件值不在 condition_dict 中、
|
|
194
|
+
descriptor 非数值、历史行缺列、metric 非数值,以及无 GPU 时请求 CUDA。
|
|
195
|
+
|
|
196
|
+
服务端有独立于客户端的单次请求时限。GP、EHVI、高 accuracy 或共享资源繁忙可能导致
|
|
197
|
+
timeout。普通用户任务中不得自动换参数重试;应报告“未产生推荐”,保留本次错误,
|
|
198
|
+
由用户决定是否另起一次明确的回归测试。
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Read the authoritative Delta Science catalog through delta-cli."""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import argparse
|
|
7
|
-
import json
|
|
8
|
-
import os
|
|
9
|
-
import subprocess
|
|
10
|
-
import sys
|
|
11
|
-
import time
|
|
12
|
-
|
|
13
|
-
from invoke import _parse_cli_error, _resolve_cli, _runtime_config
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def _parser() -> argparse.ArgumentParser:
|
|
17
|
-
parser = argparse.ArgumentParser(description=__doc__)
|
|
18
|
-
action = parser.add_mutually_exclusive_group(required=True)
|
|
19
|
-
action.add_argument("--tools", action="store_true")
|
|
20
|
-
action.add_argument("--endpoints", metavar="TOOL")
|
|
21
|
-
parser.add_argument("--cli")
|
|
22
|
-
parser.add_argument("--science-base-url")
|
|
23
|
-
parser.add_argument("--timeout", type=float, default=30.0)
|
|
24
|
-
return parser
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def main() -> int:
|
|
28
|
-
args = _parser().parse_args()
|
|
29
|
-
started = time.perf_counter()
|
|
30
|
-
kind = "tools" if args.tools else "endpoints"
|
|
31
|
-
try:
|
|
32
|
-
runtime = _runtime_config()
|
|
33
|
-
cli = _resolve_cli(args.cli, runtime)
|
|
34
|
-
env = os.environ.copy()
|
|
35
|
-
base_url = args.science_base_url or runtime.get("science_base_url")
|
|
36
|
-
if base_url:
|
|
37
|
-
env["DELTA_INFRA_SCIENCE_BASE_URL"] = str(base_url)
|
|
38
|
-
|
|
39
|
-
command = [cli, "science", "list"]
|
|
40
|
-
if args.endpoints:
|
|
41
|
-
command = [cli, "science", "endpoints", "list", args.endpoints]
|
|
42
|
-
completed = subprocess.run(
|
|
43
|
-
command,
|
|
44
|
-
capture_output=True,
|
|
45
|
-
text=True,
|
|
46
|
-
encoding="utf-8",
|
|
47
|
-
errors="replace",
|
|
48
|
-
env=env,
|
|
49
|
-
timeout=args.timeout,
|
|
50
|
-
check=False,
|
|
51
|
-
)
|
|
52
|
-
if completed.returncode != 0:
|
|
53
|
-
error_type, detail = _parse_cli_error(completed)
|
|
54
|
-
raise RuntimeError(f"{error_type}: {detail}")
|
|
55
|
-
root = json.loads(completed.stdout)
|
|
56
|
-
if not isinstance(root, dict) or root.get("ok") is not True:
|
|
57
|
-
raise RuntimeError(json.dumps(root, ensure_ascii=False))
|
|
58
|
-
if "data" not in root:
|
|
59
|
-
raise RuntimeError("CLI success envelope is missing data")
|
|
60
|
-
print(json.dumps({
|
|
61
|
-
"ok": True,
|
|
62
|
-
"transport": "delta-cli",
|
|
63
|
-
"catalog": kind,
|
|
64
|
-
"tool": args.endpoints,
|
|
65
|
-
"elapsed_seconds": round(time.perf_counter() - started, 3),
|
|
66
|
-
"native": root["data"],
|
|
67
|
-
}, ensure_ascii=False))
|
|
68
|
-
return 0
|
|
69
|
-
except subprocess.TimeoutExpired:
|
|
70
|
-
error_type = "timeout"
|
|
71
|
-
error = f"timeout after {args.timeout}s"
|
|
72
|
-
except (OSError, ValueError, json.JSONDecodeError) as exc:
|
|
73
|
-
error_type = "catalog"
|
|
74
|
-
error = str(exc)
|
|
75
|
-
except RuntimeError as exc:
|
|
76
|
-
error_type = "cli"
|
|
77
|
-
error = str(exc)
|
|
78
|
-
|
|
79
|
-
print(json.dumps({
|
|
80
|
-
"ok": False,
|
|
81
|
-
"transport": "delta-cli",
|
|
82
|
-
"catalog": kind,
|
|
83
|
-
"tool": args.endpoints,
|
|
84
|
-
"error_type": error_type,
|
|
85
|
-
"elapsed_seconds": round(time.perf_counter() - started, 3),
|
|
86
|
-
"error": error[:2000],
|
|
87
|
-
}, ensure_ascii=False))
|
|
88
|
-
return 1
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if __name__ == "__main__":
|
|
92
|
-
sys.exit(main())
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Read the authoritative Delta Science catalog through delta-cli."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
from invoke import _parse_cli_error, _resolve_cli, _runtime_config
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _parser() -> argparse.ArgumentParser:
|
|
17
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
18
|
+
action = parser.add_mutually_exclusive_group(required=True)
|
|
19
|
+
action.add_argument("--tools", action="store_true")
|
|
20
|
+
action.add_argument("--endpoints", metavar="TOOL")
|
|
21
|
+
parser.add_argument("--cli")
|
|
22
|
+
parser.add_argument("--science-base-url")
|
|
23
|
+
parser.add_argument("--timeout", type=float, default=30.0)
|
|
24
|
+
return parser
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main() -> int:
|
|
28
|
+
args = _parser().parse_args()
|
|
29
|
+
started = time.perf_counter()
|
|
30
|
+
kind = "tools" if args.tools else "endpoints"
|
|
31
|
+
try:
|
|
32
|
+
runtime = _runtime_config()
|
|
33
|
+
cli = _resolve_cli(args.cli, runtime)
|
|
34
|
+
env = os.environ.copy()
|
|
35
|
+
base_url = args.science_base_url or runtime.get("science_base_url")
|
|
36
|
+
if base_url:
|
|
37
|
+
env["DELTA_INFRA_SCIENCE_BASE_URL"] = str(base_url)
|
|
38
|
+
|
|
39
|
+
command = [cli, "science", "list"]
|
|
40
|
+
if args.endpoints:
|
|
41
|
+
command = [cli, "science", "endpoints", "list", args.endpoints]
|
|
42
|
+
completed = subprocess.run(
|
|
43
|
+
command,
|
|
44
|
+
capture_output=True,
|
|
45
|
+
text=True,
|
|
46
|
+
encoding="utf-8",
|
|
47
|
+
errors="replace",
|
|
48
|
+
env=env,
|
|
49
|
+
timeout=args.timeout,
|
|
50
|
+
check=False,
|
|
51
|
+
)
|
|
52
|
+
if completed.returncode != 0:
|
|
53
|
+
error_type, detail = _parse_cli_error(completed)
|
|
54
|
+
raise RuntimeError(f"{error_type}: {detail}")
|
|
55
|
+
root = json.loads(completed.stdout)
|
|
56
|
+
if not isinstance(root, dict) or root.get("ok") is not True:
|
|
57
|
+
raise RuntimeError(json.dumps(root, ensure_ascii=False))
|
|
58
|
+
if "data" not in root:
|
|
59
|
+
raise RuntimeError("CLI success envelope is missing data")
|
|
60
|
+
print(json.dumps({
|
|
61
|
+
"ok": True,
|
|
62
|
+
"transport": "delta-cli",
|
|
63
|
+
"catalog": kind,
|
|
64
|
+
"tool": args.endpoints,
|
|
65
|
+
"elapsed_seconds": round(time.perf_counter() - started, 3),
|
|
66
|
+
"native": root["data"],
|
|
67
|
+
}, ensure_ascii=False))
|
|
68
|
+
return 0
|
|
69
|
+
except subprocess.TimeoutExpired:
|
|
70
|
+
error_type = "timeout"
|
|
71
|
+
error = f"timeout after {args.timeout}s"
|
|
72
|
+
except (OSError, ValueError, json.JSONDecodeError) as exc:
|
|
73
|
+
error_type = "catalog"
|
|
74
|
+
error = str(exc)
|
|
75
|
+
except RuntimeError as exc:
|
|
76
|
+
error_type = "cli"
|
|
77
|
+
error = str(exc)
|
|
78
|
+
|
|
79
|
+
print(json.dumps({
|
|
80
|
+
"ok": False,
|
|
81
|
+
"transport": "delta-cli",
|
|
82
|
+
"catalog": kind,
|
|
83
|
+
"tool": args.endpoints,
|
|
84
|
+
"error_type": error_type,
|
|
85
|
+
"elapsed_seconds": round(time.perf_counter() - started, 3),
|
|
86
|
+
"error": error[:2000],
|
|
87
|
+
}, ensure_ascii=False))
|
|
88
|
+
return 1
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
sys.exit(main())
|