atomict 0.1.2__py3-none-any.whl → 0.2.4__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.
- atomict/__init__.py +1 -1
- atomict/__version__.py +1 -0
- atomict/api.py +182 -0
- atomict/auth.py +47 -0
- atomict/cli/commands/adsorbate.py +183 -0
- atomict/cli/commands/ai_assist.py +111 -0
- atomict/cli/commands/catalysis.py +171 -0
- atomict/cli/commands/common.py +57 -0
- atomict/cli/commands/exploration/__init__.py +7 -0
- atomict/cli/commands/exploration/soec.py +564 -0
- atomict/cli/commands/exploration/sqs.py +440 -0
- atomict/cli/commands/helpers.py +74 -0
- atomict/cli/commands/k8s.py +211 -0
- atomict/cli/commands/login.py +34 -0
- atomict/cli/commands/organization.py +76 -0
- atomict/cli/commands/project.py +876 -0
- atomict/cli/commands/simulation/__init__.py +20 -0
- atomict/cli/commands/simulation/catalysis.py +223 -0
- atomict/cli/commands/simulation/fhiaims.py +279 -0
- atomict/cli/commands/simulation/kpoint.py +380 -0
- atomict/cli/commands/simulation/vibes.py +161 -0
- atomict/cli/commands/simulation.py +176 -0
- atomict/cli/commands/task.py +181 -0
- atomict/cli/commands/upload.py +89 -0
- atomict/cli/commands/user.py +201 -0
- atomict/cli/core/client.py +202 -0
- atomict/cli/core/config.py +43 -0
- atomict/cli/core/utils.py +32 -0
- atomict/cli/main.py +130 -0
- atomict/env.py +79 -0
- atomict/exceptions.py +12 -0
- atomict/infra/distwork/environment.py +26 -0
- atomict/infra/distwork/task.py +49 -0
- atomict/infra/logging.py +22 -0
- atomict/io/cif.py +138 -0
- atomict/io/fhiaims.py +30 -0
- atomict/io/json.py +28 -0
- atomict/io/utils.py +11 -0
- atomict/ml/__init__.py +0 -0
- atomict/ml/model.py +13 -0
- atomict/project/__init__.py +1 -0
- atomict/project/link.py +26 -0
- atomict/project/note.py +18 -0
- atomict/project/project.py +32 -0
- atomict/project/tags.py +48 -0
- atomict/project/workbench.py +6 -0
- atomict/reality/__init__.py +0 -0
- atomict/reality/oqmd.py +5 -0
- atomict/reality/slabs.py +5 -0
- atomict/simulation/__init__.py +0 -0
- atomict/simulation/cantera.py +35 -0
- atomict/simulation/catalysis.py +20 -0
- atomict/simulation/counterfactual.py +28 -0
- atomict/simulation/ea.py +64 -0
- atomict/simulation/fhi_aims.py +72 -0
- atomict/simulation/kpoint.py +74 -0
- atomict/simulation/mattergen.py +20 -0
- atomict/simulation/mlrelax.py +83 -0
- atomict/simulation/phonon.py +12 -0
- atomict/simulation/qe.py +74 -0
- atomict/simulation/sqs.py +24 -0
- atomict/simulation/utils.py +90 -0
- atomict/user/__init__.py +0 -0
- atomict/user/files.py +31 -0
- atomict/user/workspace.py +112 -0
- atomict/utils/fhiaims/__init__.py +0 -0
- atomict/utils/fhiaims/geometry.py +73 -0
- atomict/utils/tenacity.py +36 -0
- {atomict-0.1.2.dist-info → atomict-0.2.4.dist-info}/LICENSE +0 -0
- atomict-0.2.4.dist-info/METADATA +109 -0
- atomict-0.2.4.dist-info/RECORD +78 -0
- {atomict-0.1.2.dist-info → atomict-0.2.4.dist-info}/WHEEL +1 -1
- atomict-0.2.4.dist-info/entry_points.txt +2 -0
- {atomict-0.1.2.dist-info → atomict-0.2.4.dist-info}/top_level.txt +0 -1
- atomict/__main__.py +0 -3
- atomict/cli.py +0 -59
- atomict/datasets/__init__.py +0 -25
- atomict/datasets/io.py +0 -47
- atomict/datasets/public.py +0 -32
- atomict/utils/requests.py +0 -19
- atomict/version.py +0 -2
- atomict-0.1.2.dist-info/METADATA +0 -97
- atomict-0.1.2.dist-info/RECORD +0 -19
- atomict-0.1.2.dist-info/entry_points.txt +0 -2
- tests/test_sdk.py +0 -16
- /atomict/{auth → cli}/__init__.py +0 -0
- /atomict/{utils → infra}/__init__.py +0 -0
- {tests → atomict/infra/distwork}/__init__.py +0 -0
- /tests/test_cli.py → /atomict/io/__init__.py +0 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from rich.panel import Panel
|
|
6
|
+
|
|
7
|
+
from atomict.cli.commands.common import create_table
|
|
8
|
+
from atomict.cli.commands.helpers import format_datetime, get_status_string
|
|
9
|
+
from atomict.cli.core.client import get_client
|
|
10
|
+
from atomict.cli.core.utils import get_pagination_info
|
|
11
|
+
|
|
12
|
+
console = Console()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@click.group(name="kpoint")
|
|
16
|
+
def kpoint_group():
|
|
17
|
+
"""Manage K-point simulations"""
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@kpoint_group.command()
|
|
22
|
+
@click.argument("id", required=False)
|
|
23
|
+
@click.option("--search", help="Search term")
|
|
24
|
+
@click.option("--ordering", help="Field to order results by")
|
|
25
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
26
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
27
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
28
|
+
def get(
|
|
29
|
+
id: Optional[str] = None,
|
|
30
|
+
search: Optional[str] = None,
|
|
31
|
+
ordering: Optional[str] = None,
|
|
32
|
+
filters: tuple = (),
|
|
33
|
+
json_output: bool = False,
|
|
34
|
+
fetch_all: bool = False,
|
|
35
|
+
):
|
|
36
|
+
"""Get K-point simulation details or list all simulations"""
|
|
37
|
+
client = get_client()
|
|
38
|
+
console = Console()
|
|
39
|
+
params = {}
|
|
40
|
+
|
|
41
|
+
if id:
|
|
42
|
+
simulation = client.get(f"/api/kpoint-simulation/{id}/")
|
|
43
|
+
if json_output:
|
|
44
|
+
console.print_json(data=simulation, params=params)
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
# Format single simulation output
|
|
48
|
+
console.print(Panel(f"[bold]K-point Simulation Details[/bold]"))
|
|
49
|
+
console.print(f"ID: {simulation['id']}")
|
|
50
|
+
if simulation.get("exploration"):
|
|
51
|
+
console.print(f"Exploration: {simulation['exploration'].get('name', 'N/A')}")
|
|
52
|
+
status = get_status_string(simulation["exploration"].get("status"))
|
|
53
|
+
console.print(f"Status: {status}")
|
|
54
|
+
console.print(f"K-points: {simulation.get('k_points', [])}")
|
|
55
|
+
if simulation.get("simulation"):
|
|
56
|
+
console.print(
|
|
57
|
+
f"Simulation Name: {simulation['simulation'].get('name', 'N/A')}"
|
|
58
|
+
)
|
|
59
|
+
status = get_status_string(simulation["simulation"].get("status"))
|
|
60
|
+
console.print(f"Status: {status}")
|
|
61
|
+
|
|
62
|
+
else:
|
|
63
|
+
if search:
|
|
64
|
+
params["search"] = search
|
|
65
|
+
if ordering:
|
|
66
|
+
params["ordering"] = ordering
|
|
67
|
+
|
|
68
|
+
# Add filter parameters
|
|
69
|
+
for f in filters:
|
|
70
|
+
try:
|
|
71
|
+
field, value = f.split("=", 1)
|
|
72
|
+
params[field] = value
|
|
73
|
+
except ValueError:
|
|
74
|
+
click.echo(f"Invalid filter format: {f}. Use field=value", err=True)
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
if fetch_all:
|
|
78
|
+
results = client.get_all("/api/kpoint-simulation/", params=params)
|
|
79
|
+
else:
|
|
80
|
+
results = client.get("/api/kpoint-simulation/", params=params)
|
|
81
|
+
|
|
82
|
+
if json_output:
|
|
83
|
+
console.print_json(data=results)
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
columns = [
|
|
87
|
+
("ID", "id", None),
|
|
88
|
+
(
|
|
89
|
+
"Exploration Name",
|
|
90
|
+
"exploration",
|
|
91
|
+
None
|
|
92
|
+
),
|
|
93
|
+
(
|
|
94
|
+
"Simulation Name",
|
|
95
|
+
"simulation",
|
|
96
|
+
lambda x: x.get("name") if isinstance(x, dict) else None,
|
|
97
|
+
),
|
|
98
|
+
("K-points", "k_points", str),
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
items, footer_string = get_pagination_info(results)
|
|
102
|
+
|
|
103
|
+
if not items:
|
|
104
|
+
console.print(
|
|
105
|
+
f"[white]No simulations found with the given criteria:[/white]\n[green]{params}"
|
|
106
|
+
)
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
table = create_table(
|
|
110
|
+
columns=columns,
|
|
111
|
+
items=items,
|
|
112
|
+
title="K-point Simulations",
|
|
113
|
+
caption=footer_string,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
console.print(table)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@kpoint_group.command()
|
|
120
|
+
@click.option("--exploration", required=True, help="Exploration ID")
|
|
121
|
+
@click.option(
|
|
122
|
+
"--k-points", required=True, multiple=True, type=float, help="K-point values"
|
|
123
|
+
)
|
|
124
|
+
def create(exploration: str, k_points: List[float]):
|
|
125
|
+
"""Create a new K-point simulation"""
|
|
126
|
+
client = get_client()
|
|
127
|
+
data = {"exploration": exploration, "k_points": list(k_points)}
|
|
128
|
+
|
|
129
|
+
simulation = client.post("/api/kpoint-simulation/", data=data)
|
|
130
|
+
console.print(f"[green]Created simulation with ID: {simulation['id']}[/green]")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@kpoint_group.command()
|
|
134
|
+
@click.argument("id")
|
|
135
|
+
def delete(id: str):
|
|
136
|
+
"""Delete a K-point simulation"""
|
|
137
|
+
client = get_client()
|
|
138
|
+
client.delete(f"/api/kpoint-simulation/{id}/")
|
|
139
|
+
console.print(f"[green]Deleted simulation {id}[/green]")
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@kpoint_group.command()
|
|
143
|
+
@click.argument("id", required=False)
|
|
144
|
+
@click.option("--search", help="Search term")
|
|
145
|
+
@click.option("--ordering", help="Field to order results by")
|
|
146
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
147
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
148
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
149
|
+
def get_exploration(
|
|
150
|
+
id: Optional[str] = None,
|
|
151
|
+
search: Optional[str] = None,
|
|
152
|
+
ordering: Optional[str] = None,
|
|
153
|
+
filters: tuple = (),
|
|
154
|
+
json_output: bool = False,
|
|
155
|
+
fetch_all: bool = False,
|
|
156
|
+
):
|
|
157
|
+
"""Get K-point exploration details or list all explorations"""
|
|
158
|
+
client = get_client()
|
|
159
|
+
console = Console()
|
|
160
|
+
|
|
161
|
+
if id:
|
|
162
|
+
exploration = client.get(f"/api/kpoint-exploration/{id}/")
|
|
163
|
+
if json_output:
|
|
164
|
+
console.print_json(data=exploration)
|
|
165
|
+
return
|
|
166
|
+
|
|
167
|
+
# Format single exploration output
|
|
168
|
+
console.print(Panel(f"[bold]K-point Exploration Details[/bold]"))
|
|
169
|
+
console.print(f"ID: {exploration['id']}")
|
|
170
|
+
console.print(f"Name: {exploration.get('name', 'N/A')}")
|
|
171
|
+
console.print(f"Description: {exploration.get('description', 'N/A')}")
|
|
172
|
+
console.print(f"Created: {format_datetime(exploration.get('created_at'))}")
|
|
173
|
+
console.print(f"Updated: {format_datetime(exploration.get('updated_at'))}")
|
|
174
|
+
if exploration.get("task"):
|
|
175
|
+
console.print(
|
|
176
|
+
f"Status: {get_status_string(exploration['task'].get('status'))}"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
else:
|
|
180
|
+
params = {}
|
|
181
|
+
if search:
|
|
182
|
+
params["search"] = search
|
|
183
|
+
if ordering:
|
|
184
|
+
params["ordering"] = ordering
|
|
185
|
+
|
|
186
|
+
# Add filter parameters
|
|
187
|
+
for f in filters:
|
|
188
|
+
try:
|
|
189
|
+
field, value = f.split("=", 1)
|
|
190
|
+
params[field] = value
|
|
191
|
+
except ValueError:
|
|
192
|
+
click.echo(f"Invalid filter format: {f}. Use field=value", err=True)
|
|
193
|
+
return
|
|
194
|
+
|
|
195
|
+
if fetch_all:
|
|
196
|
+
results = client.get_all("/api/kpoint-exploration/", params=params)
|
|
197
|
+
else:
|
|
198
|
+
results = client.get("/api/kpoint-exploration/", params=params)
|
|
199
|
+
|
|
200
|
+
if json_output:
|
|
201
|
+
console.print_json(data=results)
|
|
202
|
+
return
|
|
203
|
+
|
|
204
|
+
columns = [
|
|
205
|
+
("ID", "id", None),
|
|
206
|
+
("Name", "name", None),
|
|
207
|
+
(
|
|
208
|
+
"Status",
|
|
209
|
+
"task",
|
|
210
|
+
lambda x: (
|
|
211
|
+
get_status_string(x.get("status")) if isinstance(x, dict) else None
|
|
212
|
+
),
|
|
213
|
+
),
|
|
214
|
+
("Created", "created_at", format_datetime),
|
|
215
|
+
("Updated", "updated_at", format_datetime),
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
items, footer_string = get_pagination_info(results)
|
|
219
|
+
|
|
220
|
+
if not items:
|
|
221
|
+
console.print(
|
|
222
|
+
f"[white]No explorations found with the given criteria:[/white]\n[green]{params}"
|
|
223
|
+
)
|
|
224
|
+
return
|
|
225
|
+
|
|
226
|
+
table = create_table(
|
|
227
|
+
columns=columns,
|
|
228
|
+
items=items,
|
|
229
|
+
title="K-point Explorations",
|
|
230
|
+
caption=footer_string,
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
console.print(table)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@kpoint_group.command()
|
|
237
|
+
@click.option("--name", required=True, help="Exploration name")
|
|
238
|
+
@click.option("--description", help="Exploration description")
|
|
239
|
+
def create_exploration(name: str, description: Optional[str] = None):
|
|
240
|
+
"""Create a new K-point exploration"""
|
|
241
|
+
client = get_client()
|
|
242
|
+
data = {
|
|
243
|
+
"name": name,
|
|
244
|
+
}
|
|
245
|
+
if description:
|
|
246
|
+
data["description"] = description
|
|
247
|
+
|
|
248
|
+
exploration = client.post("/api/kpoint-exploration/", data=data)
|
|
249
|
+
console.print(f"[green]Created exploration with ID: {exploration['id']}[/green]")
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@kpoint_group.command()
|
|
253
|
+
@click.argument("id")
|
|
254
|
+
def delete_exploration(id: str):
|
|
255
|
+
"""Delete a K-point exploration"""
|
|
256
|
+
client = get_client()
|
|
257
|
+
client.delete(f"/api/kpoint-exploration/{id}/")
|
|
258
|
+
console.print(f"[green]Deleted exploration {id}[/green]")
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
@kpoint_group.command()
|
|
262
|
+
@click.argument("id", required=False)
|
|
263
|
+
@click.option("--search", help="Search term")
|
|
264
|
+
@click.option("--ordering", help="Field to order results by")
|
|
265
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
266
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
267
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
268
|
+
def get_analysis(
|
|
269
|
+
id: Optional[str] = None,
|
|
270
|
+
search: Optional[str] = None,
|
|
271
|
+
ordering: Optional[str] = None,
|
|
272
|
+
filters: tuple = (),
|
|
273
|
+
json_output: bool = False,
|
|
274
|
+
fetch_all: bool = False,
|
|
275
|
+
):
|
|
276
|
+
"""Get K-point analysis details or list all analyses"""
|
|
277
|
+
client = get_client()
|
|
278
|
+
|
|
279
|
+
if id:
|
|
280
|
+
analysis = client.get(f"/api/kpoint-analysis/{id}/")
|
|
281
|
+
if json_output:
|
|
282
|
+
console.print_json(data=analysis)
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
# Format single analysis output
|
|
286
|
+
console.print(Panel(f"[bold]K-point Analysis Details[/bold]"))
|
|
287
|
+
console.print(f"ID: {analysis['id']}")
|
|
288
|
+
console.print(f"Created: {format_datetime(analysis['created_at'])}")
|
|
289
|
+
if analysis.get("exploration"):
|
|
290
|
+
console.print(
|
|
291
|
+
f"Exploration: {analysis['exploration'].get('name', 'N/A')} ({analysis['exploration']['id']})"
|
|
292
|
+
)
|
|
293
|
+
if analysis.get("task"):
|
|
294
|
+
console.print(
|
|
295
|
+
f"Status: {get_status_string(analysis['task'].get('status'))}"
|
|
296
|
+
)
|
|
297
|
+
else:
|
|
298
|
+
params = {}
|
|
299
|
+
if search:
|
|
300
|
+
params["search"] = search
|
|
301
|
+
if ordering:
|
|
302
|
+
params["ordering"] = ordering
|
|
303
|
+
|
|
304
|
+
# Add filter parameters
|
|
305
|
+
for f in filters:
|
|
306
|
+
try:
|
|
307
|
+
field, value = f.split("=", 1)
|
|
308
|
+
params[field] = value
|
|
309
|
+
except ValueError:
|
|
310
|
+
click.echo(f"Invalid filter format: {f}. Use field=value", err=True)
|
|
311
|
+
return
|
|
312
|
+
|
|
313
|
+
if fetch_all:
|
|
314
|
+
results = client.get_all("/api/kpoint-analysis/", params=params)
|
|
315
|
+
else:
|
|
316
|
+
results = client.get("/api/kpoint-analysis/", params=params)
|
|
317
|
+
|
|
318
|
+
if json_output:
|
|
319
|
+
console.print_json(data=results)
|
|
320
|
+
return
|
|
321
|
+
|
|
322
|
+
columns = [
|
|
323
|
+
("ID", "id", None),
|
|
324
|
+
(
|
|
325
|
+
"Exploration",
|
|
326
|
+
"exploration",
|
|
327
|
+
lambda x: x.get("name") if isinstance(x, dict) else None,
|
|
328
|
+
),
|
|
329
|
+
(
|
|
330
|
+
"Status",
|
|
331
|
+
"task",
|
|
332
|
+
lambda x: (
|
|
333
|
+
get_status_string(x.get("status")) if isinstance(x, dict) else None
|
|
334
|
+
),
|
|
335
|
+
),
|
|
336
|
+
("Created", "created_at", format_datetime),
|
|
337
|
+
]
|
|
338
|
+
|
|
339
|
+
items, footer_string = get_pagination_info(results)
|
|
340
|
+
|
|
341
|
+
if not items:
|
|
342
|
+
console.print(
|
|
343
|
+
f"[white]No analyses found with the given criteria:[/white]\n[green]{params}"
|
|
344
|
+
)
|
|
345
|
+
return
|
|
346
|
+
|
|
347
|
+
table = create_table(
|
|
348
|
+
columns=columns,
|
|
349
|
+
items=items,
|
|
350
|
+
title="K-point Analyses",
|
|
351
|
+
caption=footer_string,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
console.print(table)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
@kpoint_group.command()
|
|
358
|
+
@click.argument("analysis")
|
|
359
|
+
@click.option("--exploration", required=True, help="Exploration UUID")
|
|
360
|
+
def create_analysis(exploration: str, analysis: str):
|
|
361
|
+
"""Create a new K-point analysis. Takes JSON analysis data as main argument."""
|
|
362
|
+
client = get_client()
|
|
363
|
+
# TODO: what data would a user provide?
|
|
364
|
+
data = {
|
|
365
|
+
"analysis": analysis,
|
|
366
|
+
}
|
|
367
|
+
if exploration:
|
|
368
|
+
data["exploration"] = exploration
|
|
369
|
+
|
|
370
|
+
analysis = client.post("/api/kpoint-analysis/", data=data)
|
|
371
|
+
console.print(f"[green]Created analysis with ID: {analysis['id']}[/green]")
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
@kpoint_group.command()
|
|
375
|
+
@click.argument("id")
|
|
376
|
+
def delete_analysis(id: str):
|
|
377
|
+
"""Delete a K-point analysis"""
|
|
378
|
+
client = get_client()
|
|
379
|
+
client.delete(f"/api/kpoint-analysis/{id}/")
|
|
380
|
+
console.print(f"[green]Deleted analysis {id}[/green]")
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
|
|
6
|
+
from atomict.cli.commands.common import create_table
|
|
7
|
+
from atomict.cli.commands.helpers import format_datetime, get_status_string
|
|
8
|
+
from atomict.cli.core.client import get_client
|
|
9
|
+
from atomict.cli.core.utils import get_pagination_info
|
|
10
|
+
|
|
11
|
+
console = Console()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.group(name="vibes")
|
|
15
|
+
def vibes_group():
|
|
16
|
+
"""Manage VIBES simulations"""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@vibes_group.command()
|
|
21
|
+
@click.argument("id", required=False)
|
|
22
|
+
@click.option("--search", help="Search term")
|
|
23
|
+
@click.option("--ordering", help="Field to order results by")
|
|
24
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
25
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
26
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
27
|
+
def get(
|
|
28
|
+
id: Optional[str] = None,
|
|
29
|
+
search: Optional[str] = None,
|
|
30
|
+
ordering: Optional[str] = None,
|
|
31
|
+
filters: tuple = (),
|
|
32
|
+
json_output: bool = False,
|
|
33
|
+
fetch_all: bool = False,
|
|
34
|
+
):
|
|
35
|
+
"""Get simulation details or list all simulations"""
|
|
36
|
+
client = get_client()
|
|
37
|
+
|
|
38
|
+
if id:
|
|
39
|
+
simulation = client.get(f"/api/vibes-simulation/{id}/")
|
|
40
|
+
if json_output:
|
|
41
|
+
console.print_json(data=simulation)
|
|
42
|
+
return
|
|
43
|
+
# Format single simulation output
|
|
44
|
+
console.print(f"ID: {simulation['id']}")
|
|
45
|
+
console.print(f"Name: {simulation.get('name', 'N/A')}")
|
|
46
|
+
console.print(f"Created: {format_datetime(simulation['created_at'])}")
|
|
47
|
+
console.print(f"Updated: {format_datetime(simulation['updated_at'])}")
|
|
48
|
+
console.print(f"Calculator Parameters: {simulation.get('calculator_parameters', {})}")
|
|
49
|
+
console.print(f"Calculator K-points: {simulation.get('calculator_kpoints', {})}")
|
|
50
|
+
console.print(f"Calculator Basis Set: {simulation.get('calculator_basis_set', {})}")
|
|
51
|
+
if simulation.get("task"):
|
|
52
|
+
status = get_status_string(simulation["task"].get("status"))
|
|
53
|
+
console.print(f"Status: {status}")
|
|
54
|
+
if simulation.get("starting_structure"):
|
|
55
|
+
console.print(f"Starting Structure ID: {simulation['starting_structure']['id']}")
|
|
56
|
+
else:
|
|
57
|
+
params = {}
|
|
58
|
+
if search:
|
|
59
|
+
params["search"] = search
|
|
60
|
+
if ordering:
|
|
61
|
+
params["ordering"] = ordering
|
|
62
|
+
|
|
63
|
+
for f in filters:
|
|
64
|
+
try:
|
|
65
|
+
field, value = f.split("=", 1)
|
|
66
|
+
params[field] = value
|
|
67
|
+
except ValueError:
|
|
68
|
+
click.echo(f"Invalid filter format: {f}. Use field=value", err=True)
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
if fetch_all:
|
|
72
|
+
results = client.get_all("/api/vibes-simulation/", params=params)
|
|
73
|
+
else:
|
|
74
|
+
results = client.get("/api/vibes-simulation/", params=params)
|
|
75
|
+
|
|
76
|
+
if json_output:
|
|
77
|
+
console.print_json(data=results)
|
|
78
|
+
return
|
|
79
|
+
|
|
80
|
+
columns = [
|
|
81
|
+
("ID", "id", None),
|
|
82
|
+
("Name", "name", None),
|
|
83
|
+
("Status", "task", lambda x: get_status_string(x.get("status") if isinstance(x, dict) else None)),
|
|
84
|
+
("Created", "created_at", format_datetime),
|
|
85
|
+
("Updated", "updated_at", format_datetime),
|
|
86
|
+
("Starting Structure", "starting_structure", lambda x: x.get("id") if isinstance(x, dict) else None),
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
items, footer_string = get_pagination_info(results)
|
|
90
|
+
|
|
91
|
+
if not items:
|
|
92
|
+
console.print(
|
|
93
|
+
f"[white]No simulations found with the given criteria:[/white]\n[green]{params}"
|
|
94
|
+
)
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
table = create_table(
|
|
98
|
+
columns=columns,
|
|
99
|
+
items=items,
|
|
100
|
+
title="VIBES Simulations",
|
|
101
|
+
caption=footer_string,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
console.print(table)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@vibes_group.command()
|
|
108
|
+
@click.option("--name", help="Simulation name")
|
|
109
|
+
@click.option("--description", help="Simulation description")
|
|
110
|
+
@click.option("--starting-structure-id", help="ID of the starting FHI-aims structure")
|
|
111
|
+
@click.option(
|
|
112
|
+
"--xc",
|
|
113
|
+
type=str,
|
|
114
|
+
help="Phonopy.in setting: Exchange-correlation functional (e.g. 'pw-lda')",
|
|
115
|
+
)
|
|
116
|
+
@click.option(
|
|
117
|
+
"--kpoint-density",
|
|
118
|
+
type=float,
|
|
119
|
+
help="Phonopy.in setting: K-point density (e.g. 3.5)",
|
|
120
|
+
)
|
|
121
|
+
@click.option(
|
|
122
|
+
"--basis-set",
|
|
123
|
+
type=str,
|
|
124
|
+
help="Phonopy.in setting: Basis set (e.g. 'light')",
|
|
125
|
+
)
|
|
126
|
+
def create(
|
|
127
|
+
name: Optional[str],
|
|
128
|
+
description: Optional[str],
|
|
129
|
+
starting_structure_id: Optional[str],
|
|
130
|
+
xc: Optional[str],
|
|
131
|
+
kpoint_density: Optional[float],
|
|
132
|
+
basis_set: Optional[str],
|
|
133
|
+
):
|
|
134
|
+
"""Create a new VIBES simulation"""
|
|
135
|
+
client = get_client()
|
|
136
|
+
data = {}
|
|
137
|
+
|
|
138
|
+
if name:
|
|
139
|
+
data["name"] = name
|
|
140
|
+
if description:
|
|
141
|
+
data["description"] = description
|
|
142
|
+
if starting_structure_id:
|
|
143
|
+
data["starting_structure"] = starting_structure_id
|
|
144
|
+
if xc:
|
|
145
|
+
data["calculator_parameters"] = {"xc": xc}
|
|
146
|
+
if kpoint_density:
|
|
147
|
+
data["calculator_kpoints"] = {"density": kpoint_density}
|
|
148
|
+
if basis_set:
|
|
149
|
+
data["calculator_basis_set"] = {"default": basis_set}
|
|
150
|
+
|
|
151
|
+
simulation = client.post("/api/vibes-simulation/", data=data)
|
|
152
|
+
console.print(f"[green]Created simulation with ID: {simulation['id']}[/green]")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@vibes_group.command()
|
|
156
|
+
@click.argument("id")
|
|
157
|
+
def delete(id: str):
|
|
158
|
+
"""Delete a VIBES simulation"""
|
|
159
|
+
client = get_client()
|
|
160
|
+
client.delete(f"/api/vibes-simulation/{id}/")
|
|
161
|
+
console.print(f"[green]Deleted simulation {id}[/green]")
|