atomict 0.1.1__py3-none-any.whl → 0.1.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 +84 -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 +124 -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 +131 -0
- atomict/io/fhiaims.py +24 -0
- atomict/io/json.py +22 -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/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 +83 -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 +65 -0
- atomict/utils/tenacity.py +36 -0
- {atomict-0.1.1.dist-info → atomict-0.1.4.dist-info}/LICENSE +0 -0
- atomict-0.1.4.dist-info/METADATA +105 -0
- atomict-0.1.4.dist-info/RECORD +77 -0
- {atomict-0.1.1.dist-info → atomict-0.1.4.dist-info}/WHEEL +1 -1
- atomict-0.1.4.dist-info/entry_points.txt +2 -0
- {atomict-0.1.1.dist-info → atomict-0.1.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.1.dist-info/METADATA +0 -98
- atomict-0.1.1.dist-info/RECORD +0 -19
- atomict-0.1.1.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,564 @@
|
|
|
1
|
+
from typing import 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
|
+
|
|
13
|
+
@click.group(name="ea")
|
|
14
|
+
def soecexploration_group():
|
|
15
|
+
"""Manage EA / SOEC explorations and related resources"""
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@soecexploration_group.command()
|
|
20
|
+
@click.argument("id", required=False)
|
|
21
|
+
@click.option("--search", help="Search term")
|
|
22
|
+
@click.option("--ordering", help="Field to order results by")
|
|
23
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
24
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
25
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
26
|
+
def get(
|
|
27
|
+
id: Optional[str] = None,
|
|
28
|
+
search: Optional[str] = None,
|
|
29
|
+
ordering: Optional[str] = None,
|
|
30
|
+
filters: tuple = (),
|
|
31
|
+
json_output: bool = False,
|
|
32
|
+
fetch_all: bool = False,
|
|
33
|
+
):
|
|
34
|
+
"""Get EA exploration details or list all explorations"""
|
|
35
|
+
client = get_client()
|
|
36
|
+
console = Console()
|
|
37
|
+
|
|
38
|
+
if id:
|
|
39
|
+
result = client.get(f"/api/ea-exploration/{id}/")
|
|
40
|
+
if json_output:
|
|
41
|
+
console.print_json(data=result)
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
console.print(Panel.fit(f"[bold]EA Exploration Details[/bold]"))
|
|
45
|
+
console.print(f"ID: {result['id']}")
|
|
46
|
+
console.print(f"Name: {result.get('name', 'N/A')}")
|
|
47
|
+
console.print(f"Status: {get_status_string(result.get('status'))}")
|
|
48
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
49
|
+
console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
|
|
50
|
+
|
|
51
|
+
if result.get("parameters"):
|
|
52
|
+
console.print("\n[bold]Parameters[/bold]")
|
|
53
|
+
console.print_json(data=result["parameters"])
|
|
54
|
+
else:
|
|
55
|
+
params = {}
|
|
56
|
+
if search is not None:
|
|
57
|
+
params["search"] = search
|
|
58
|
+
if ordering:
|
|
59
|
+
params["ordering"] = ordering
|
|
60
|
+
|
|
61
|
+
for f in filters:
|
|
62
|
+
try:
|
|
63
|
+
field, value = f.split("=", 1)
|
|
64
|
+
params[field] = value
|
|
65
|
+
except ValueError:
|
|
66
|
+
click.echo(
|
|
67
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
68
|
+
)
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
if fetch_all:
|
|
72
|
+
results = client.get_all("/api/ea-exploration/", params=params)
|
|
73
|
+
else:
|
|
74
|
+
results = client.get("/api/ea-exploration/", 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
|
+
("Strains list", "strains_list", None),
|
|
84
|
+
("Stress algorithm", "stress_algorithm", None),
|
|
85
|
+
("Stress method", "stress_method", None),
|
|
86
|
+
("Num last samples", "num_last_samples", None),
|
|
87
|
+
("Status", "status", get_status_string),
|
|
88
|
+
("Created", "created_at", format_datetime),
|
|
89
|
+
("Updated", "updated_at", format_datetime),
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
items, footer_string = get_pagination_info(results)
|
|
93
|
+
|
|
94
|
+
if not items:
|
|
95
|
+
console.print(
|
|
96
|
+
f"[white]No EA explorations found with the given criteria:[/white]\n[green]{params}"
|
|
97
|
+
)
|
|
98
|
+
return
|
|
99
|
+
|
|
100
|
+
table = create_table(
|
|
101
|
+
columns=columns, items=items, title="EA Explorations", caption=footer_string
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
console.print(table)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@soecexploration_group.command()
|
|
108
|
+
@click.option("--name", required=True, help="Exploration name")
|
|
109
|
+
@click.option("--project", required=True, help="Project ID")
|
|
110
|
+
@click.option(
|
|
111
|
+
"--relaxed-structure-simulation", help="ID of the relaxed structure simulation"
|
|
112
|
+
)
|
|
113
|
+
@click.option("--relaxed-structure", help="ID of the relaxed structure upload")
|
|
114
|
+
@click.option("--k8s-cluster", help="K8S cluster ID (required for launch)")
|
|
115
|
+
@click.option("--launch", is_flag=True, help="Launch the exploration immediately")
|
|
116
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
117
|
+
def create(
|
|
118
|
+
name: str,
|
|
119
|
+
project: str,
|
|
120
|
+
relaxed_structure_simulation: Optional[str] = None,
|
|
121
|
+
relaxed_structure: Optional[str] = None,
|
|
122
|
+
k8s_cluster: Optional[str] = None,
|
|
123
|
+
launch: bool = False,
|
|
124
|
+
json_output: bool = False,
|
|
125
|
+
):
|
|
126
|
+
"""Create a new SOEC exploration
|
|
127
|
+
|
|
128
|
+
Either --relaxed-structure-simulation or --relaxed-structure must be provided.
|
|
129
|
+
If --launch is specified, --k8s-cluster must also be provided.
|
|
130
|
+
"""
|
|
131
|
+
client = get_client()
|
|
132
|
+
console = Console()
|
|
133
|
+
|
|
134
|
+
# Validate required fields for launch
|
|
135
|
+
if launch and not k8s_cluster:
|
|
136
|
+
console.print("[red]K8S cluster ID is required when launching[/red]")
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
# Validate relaxed structure source
|
|
140
|
+
if not (relaxed_structure_simulation or relaxed_structure):
|
|
141
|
+
console.print(
|
|
142
|
+
"[red]Either relaxed-structure-simulation or relaxed-structure must be provided[/red]"
|
|
143
|
+
)
|
|
144
|
+
return
|
|
145
|
+
|
|
146
|
+
if relaxed_structure_simulation and relaxed_structure:
|
|
147
|
+
console.print(
|
|
148
|
+
"[red]Cannot specify both relaxed-structure-simulation and relaxed-structure[/red]"
|
|
149
|
+
)
|
|
150
|
+
return
|
|
151
|
+
|
|
152
|
+
# Prepare request data
|
|
153
|
+
data = {
|
|
154
|
+
"name": name,
|
|
155
|
+
"project": project,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if relaxed_structure_simulation:
|
|
159
|
+
data["relaxed_structure_simulation"] = relaxed_structure_simulation
|
|
160
|
+
if relaxed_structure:
|
|
161
|
+
data["relaxed_structure"] = relaxed_structure
|
|
162
|
+
if k8s_cluster:
|
|
163
|
+
data["k8s_cluster"] = k8s_cluster
|
|
164
|
+
if launch:
|
|
165
|
+
data["action"] = "LAUNCH"
|
|
166
|
+
|
|
167
|
+
result = client.post("/api/ea-exploration/", data=data)
|
|
168
|
+
|
|
169
|
+
if json_output:
|
|
170
|
+
console.print_json(data=result)
|
|
171
|
+
else:
|
|
172
|
+
console.print(
|
|
173
|
+
f"[green]Created SOEC exploration '{name}' with ID: {result['id']}[/green]"
|
|
174
|
+
)
|
|
175
|
+
if launch:
|
|
176
|
+
console.print("[green]Exploration has been queued for launch[/green]")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@soecexploration_group.command()
|
|
180
|
+
@click.argument("id")
|
|
181
|
+
def delete(id: str):
|
|
182
|
+
"""Delete an EA exploration"""
|
|
183
|
+
client = get_client()
|
|
184
|
+
client.delete(f"/api/ea-exploration/{id}/")
|
|
185
|
+
console = Console()
|
|
186
|
+
console.print(f"[green]Deleted EA exploration {id}[/green]")
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
@soecexploration_group.command()
|
|
190
|
+
@click.argument("id", required=False)
|
|
191
|
+
@click.option("--search", help="Search term")
|
|
192
|
+
@click.option("--ordering", help="Field to order results by")
|
|
193
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
194
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
195
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
196
|
+
def get_sample(
|
|
197
|
+
id: Optional[str] = None,
|
|
198
|
+
search: Optional[str] = None,
|
|
199
|
+
ordering: Optional[str] = None,
|
|
200
|
+
filters: tuple = (),
|
|
201
|
+
json_output: bool = False,
|
|
202
|
+
fetch_all: bool = False,
|
|
203
|
+
):
|
|
204
|
+
"""Get SOEC exploration sample details or list all samples"""
|
|
205
|
+
client = get_client()
|
|
206
|
+
console = Console()
|
|
207
|
+
|
|
208
|
+
if id:
|
|
209
|
+
result = client.get(f"/api/ea-exploration-sample/{id}/")
|
|
210
|
+
if json_output:
|
|
211
|
+
console.print_json(data=result)
|
|
212
|
+
return
|
|
213
|
+
|
|
214
|
+
console.print(Panel.fit(f"[bold]SOEC Sample Details[/bold]"))
|
|
215
|
+
console.print(f"ID: {result['id']}")
|
|
216
|
+
console.print(
|
|
217
|
+
f"Exploration: {result['exploration'].get('name', 'N/A')} ({result['exploration']['id']})"
|
|
218
|
+
)
|
|
219
|
+
if result.get("task"):
|
|
220
|
+
console.print(f"Status: {get_status_string(result['task'].get('status'))}")
|
|
221
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
222
|
+
console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
|
|
223
|
+
|
|
224
|
+
if result.get("parameters"):
|
|
225
|
+
console.print("\n[bold]Parameters[/bold]")
|
|
226
|
+
console.print_json(data=result["parameters"])
|
|
227
|
+
else:
|
|
228
|
+
params = {}
|
|
229
|
+
if search is not None:
|
|
230
|
+
params["search"] = search
|
|
231
|
+
if ordering:
|
|
232
|
+
params["ordering"] = ordering
|
|
233
|
+
|
|
234
|
+
for f in filters:
|
|
235
|
+
try:
|
|
236
|
+
field, value = f.split("=", 1)
|
|
237
|
+
params[field] = value
|
|
238
|
+
except ValueError:
|
|
239
|
+
click.echo(
|
|
240
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
241
|
+
)
|
|
242
|
+
return
|
|
243
|
+
|
|
244
|
+
if fetch_all:
|
|
245
|
+
results = client.get_all("/api/ea-exploration-sample/", params=params)
|
|
246
|
+
else:
|
|
247
|
+
results = client.get("/api/ea-exploration-sample/", params=params)
|
|
248
|
+
|
|
249
|
+
if json_output:
|
|
250
|
+
console.print_json(data=results)
|
|
251
|
+
return
|
|
252
|
+
|
|
253
|
+
columns = [
|
|
254
|
+
("ID", "id", None),
|
|
255
|
+
(
|
|
256
|
+
"Exploration",
|
|
257
|
+
"exploration",
|
|
258
|
+
lambda x: x.get("name") if isinstance(x, dict) else None,
|
|
259
|
+
),
|
|
260
|
+
(
|
|
261
|
+
"Status",
|
|
262
|
+
"task",
|
|
263
|
+
lambda x: (
|
|
264
|
+
get_status_string(x.get("status")) if isinstance(x, dict) else None
|
|
265
|
+
),
|
|
266
|
+
),
|
|
267
|
+
("Created", "created_at", format_datetime),
|
|
268
|
+
("Updated", "updated_at", format_datetime),
|
|
269
|
+
]
|
|
270
|
+
|
|
271
|
+
items, footer_string = get_pagination_info(results)
|
|
272
|
+
|
|
273
|
+
if not items:
|
|
274
|
+
console.print(
|
|
275
|
+
f"[white]No samples found with the given criteria:[/white]\n[green]{params}"
|
|
276
|
+
)
|
|
277
|
+
return
|
|
278
|
+
|
|
279
|
+
table = create_table(
|
|
280
|
+
columns=columns, items=items, title="SOEC Samples", caption=footer_string
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
console.print(table)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@soecexploration_group.command()
|
|
287
|
+
@click.option("--exploration", required=True, help="SOEC Exploration ID")
|
|
288
|
+
@click.option("--simulation", required=True, help="Simulation ID")
|
|
289
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
290
|
+
def create_sample(exploration: str, simulation: str, json_output: bool = False):
|
|
291
|
+
"""Create a new SOEC exploration sample"""
|
|
292
|
+
client = get_client()
|
|
293
|
+
console = Console()
|
|
294
|
+
|
|
295
|
+
data = {
|
|
296
|
+
"exploration": exploration,
|
|
297
|
+
"simulation": simulation,
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
result = client.post("/api/ea-exploration-sample/", data=data)
|
|
301
|
+
|
|
302
|
+
if json_output:
|
|
303
|
+
console.print_json(data=result)
|
|
304
|
+
else:
|
|
305
|
+
console.print(
|
|
306
|
+
f"[green]Created and launched SOEC sample with ID: {result['id']}[/green]"
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
@soecexploration_group.command()
|
|
311
|
+
@click.argument("id")
|
|
312
|
+
def delete_sample(id: str):
|
|
313
|
+
"""Delete a SOEC exploration sample"""
|
|
314
|
+
client = get_client()
|
|
315
|
+
client.delete(f"/api/ea-exploration-sample/{id}/")
|
|
316
|
+
console = Console()
|
|
317
|
+
console.print(f"[green]Deleted SOEC sample {id}[/green]")
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@soecexploration_group.command()
|
|
321
|
+
@click.argument("id", required=False)
|
|
322
|
+
@click.option("--search", help="Search term (e.g. name)")
|
|
323
|
+
@click.option("--ordering", help="Field to order results by")
|
|
324
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
325
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
326
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
327
|
+
def get_analysis(
|
|
328
|
+
id: Optional[str] = None,
|
|
329
|
+
search: Optional[str] = None,
|
|
330
|
+
ordering: Optional[str] = None,
|
|
331
|
+
filters: tuple = (),
|
|
332
|
+
json_output: bool = False,
|
|
333
|
+
fetch_all: bool = False,
|
|
334
|
+
):
|
|
335
|
+
"""Get SOEC exploration analysis details or list all analyses"""
|
|
336
|
+
client = get_client()
|
|
337
|
+
console = Console()
|
|
338
|
+
|
|
339
|
+
if id:
|
|
340
|
+
result = client.get(f"/api/ea-exploration-analysis/{id}/")
|
|
341
|
+
if json_output:
|
|
342
|
+
console.print_json(data=result)
|
|
343
|
+
return
|
|
344
|
+
|
|
345
|
+
console.print(Panel.fit(f"[bold]SOEC Analysis Details[/bold]"))
|
|
346
|
+
console.print(f"ID: {result['id']}")
|
|
347
|
+
# console.print(f"Exploration: {result['exploration'].get('name', 'N/A')} ({result['exploration']['id']})")
|
|
348
|
+
console.print(f"Exploration: {result['exploration']}")
|
|
349
|
+
if result.get("task"):
|
|
350
|
+
console.print(f"Status: {get_status_string(result['task'].get('status'))}")
|
|
351
|
+
console.print(f"Progress: {result['task'].get('progress')}")
|
|
352
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
353
|
+
console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
|
|
354
|
+
else:
|
|
355
|
+
params = {}
|
|
356
|
+
if search is not None:
|
|
357
|
+
params["search"] = search
|
|
358
|
+
if ordering:
|
|
359
|
+
params["ordering"] = ordering
|
|
360
|
+
|
|
361
|
+
for f in filters:
|
|
362
|
+
try:
|
|
363
|
+
field, value = f.split("=", 1)
|
|
364
|
+
params[field] = value
|
|
365
|
+
except ValueError:
|
|
366
|
+
click.echo(
|
|
367
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
368
|
+
)
|
|
369
|
+
return
|
|
370
|
+
|
|
371
|
+
if fetch_all:
|
|
372
|
+
results = client.get_all("/api/ea-exploration-analysis/", params=params)
|
|
373
|
+
else:
|
|
374
|
+
results = client.get("/api/ea-exploration-analysis/", params=params)
|
|
375
|
+
|
|
376
|
+
if json_output:
|
|
377
|
+
console.print_json(data=results)
|
|
378
|
+
return
|
|
379
|
+
|
|
380
|
+
columns = [
|
|
381
|
+
("ID", "id", None),
|
|
382
|
+
(
|
|
383
|
+
"Exploration",
|
|
384
|
+
"exploration",
|
|
385
|
+
lambda x: x.get("name") if isinstance(x, dict) else None,
|
|
386
|
+
),
|
|
387
|
+
(
|
|
388
|
+
"Status",
|
|
389
|
+
"task",
|
|
390
|
+
lambda x: (
|
|
391
|
+
get_status_string(x.get("status")) if isinstance(x, dict) else None
|
|
392
|
+
),
|
|
393
|
+
),
|
|
394
|
+
("Created", "created_at", format_datetime),
|
|
395
|
+
("Updated", "updated_at", format_datetime),
|
|
396
|
+
]
|
|
397
|
+
|
|
398
|
+
items, footer_string = get_pagination_info(results)
|
|
399
|
+
|
|
400
|
+
if not items:
|
|
401
|
+
console.print(
|
|
402
|
+
f"[white]No analyses found with the given criteria:[/white]\n[green]{params}"
|
|
403
|
+
)
|
|
404
|
+
return
|
|
405
|
+
|
|
406
|
+
table = create_table(
|
|
407
|
+
columns=columns, items=items, title="SOEC Analyses", caption=footer_string
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
console.print(table)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
@soecexploration_group.command()
|
|
414
|
+
@click.option("--exploration", required=True, help="SOEC Exploration ID")
|
|
415
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
416
|
+
def create_analysis(exploration: str, json_output: bool = False):
|
|
417
|
+
"""Create a new SOEC exploration analysis"""
|
|
418
|
+
client = get_client()
|
|
419
|
+
console = Console()
|
|
420
|
+
|
|
421
|
+
data = {
|
|
422
|
+
"exploration": exploration,
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
result = client.post("/api/ea-exploration-analysis/", data=data)
|
|
426
|
+
|
|
427
|
+
if json_output:
|
|
428
|
+
console.print_json(data=result)
|
|
429
|
+
else:
|
|
430
|
+
console.print(
|
|
431
|
+
f"[green]Created and launched SOEC analysis with ID: {result['id']}[/green]"
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
@soecexploration_group.command()
|
|
436
|
+
@click.argument("id")
|
|
437
|
+
def delete_analysis(id: str):
|
|
438
|
+
"""Delete a SOEC exploration analysis"""
|
|
439
|
+
client = get_client()
|
|
440
|
+
client.delete(f"/api/ea-exploration-analysis/{id}/")
|
|
441
|
+
console = Console()
|
|
442
|
+
console.print(f"[green]Deleted SOEC analysis {id}[/green]")
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
@soecexploration_group.command()
|
|
446
|
+
@click.option("--analysis", required=True, help="SOEC Analysis ID")
|
|
447
|
+
@click.option("--file-id", required=True, help="Upload ID of the file")
|
|
448
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
449
|
+
def create_analysis_file(analysis: str, file_id: str, json_output: bool = False):
|
|
450
|
+
"""Create a new SOEC exploration analysis file entry"""
|
|
451
|
+
client = get_client()
|
|
452
|
+
console = Console()
|
|
453
|
+
|
|
454
|
+
data = {
|
|
455
|
+
"analysis": analysis,
|
|
456
|
+
"user_upload": file_id,
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
result = client.post("/api/ea-exploration-analysis-file/", data=data)
|
|
460
|
+
|
|
461
|
+
if json_output:
|
|
462
|
+
console.print_json(data=result)
|
|
463
|
+
else:
|
|
464
|
+
console.print(
|
|
465
|
+
f"[green]Created SOEC analysis file with ID: {result['id']}[/green]"
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
@soecexploration_group.command()
|
|
470
|
+
@click.argument("id")
|
|
471
|
+
def delete_analysis_file(id: str):
|
|
472
|
+
"""Delete a SOEC exploration analysis file"""
|
|
473
|
+
client = get_client()
|
|
474
|
+
client.delete(f"/api/ea-exploration-analysis-file/{id}/")
|
|
475
|
+
console = Console()
|
|
476
|
+
console.print(f"[green]Deleted SOEC analysis file {id}[/green]")
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
@soecexploration_group.command()
|
|
480
|
+
@click.argument("id", required=False)
|
|
481
|
+
@click.option("--analysis", help="Analysis ID to filter by")
|
|
482
|
+
@click.option("--file-id", help="Exploration ID to filter by")
|
|
483
|
+
@click.option("--ordering", help="Field to order results by")
|
|
484
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
485
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
486
|
+
def get_analysis_file(
|
|
487
|
+
id: Optional[str] = None,
|
|
488
|
+
analysis: Optional[str] = None,
|
|
489
|
+
file_id: Optional[str] = None,
|
|
490
|
+
ordering: Optional[str] = None,
|
|
491
|
+
json_output: bool = False,
|
|
492
|
+
fetch_all: bool = False,
|
|
493
|
+
):
|
|
494
|
+
"""Get SOEC exploration analysis file details or list all files
|
|
495
|
+
|
|
496
|
+
Either --analysis or --file-id must be provided when listing files.
|
|
497
|
+
"""
|
|
498
|
+
client = get_client()
|
|
499
|
+
console = Console()
|
|
500
|
+
|
|
501
|
+
if id:
|
|
502
|
+
result = client.get(f"/api/ea-exploration-analysis-file/{id}/")
|
|
503
|
+
if json_output:
|
|
504
|
+
console.print_json(data=result)
|
|
505
|
+
return
|
|
506
|
+
|
|
507
|
+
console.print(Panel.fit(f"[bold]SOEC Analysis File Details[/bold]"))
|
|
508
|
+
console.print(f"ID: {result['id']}")
|
|
509
|
+
console.print(f"Analysis: {result['analysis']}")
|
|
510
|
+
console.print(f"File: {result.get('user_upload', {}).get('id')}")
|
|
511
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
512
|
+
else:
|
|
513
|
+
if not (analysis or file_id):
|
|
514
|
+
console.print(
|
|
515
|
+
"[red]Either --analysis or --exploration must be provided[/red]"
|
|
516
|
+
)
|
|
517
|
+
return
|
|
518
|
+
|
|
519
|
+
if analysis and file_id:
|
|
520
|
+
console.print("[red]Cannot specify both --analysis and --exploration[/red]")
|
|
521
|
+
return
|
|
522
|
+
|
|
523
|
+
params = {}
|
|
524
|
+
if analysis:
|
|
525
|
+
params["analysis"] = analysis
|
|
526
|
+
if file_id:
|
|
527
|
+
params["user_upload"] = file_id
|
|
528
|
+
if ordering:
|
|
529
|
+
params["ordering"] = ordering
|
|
530
|
+
|
|
531
|
+
if fetch_all:
|
|
532
|
+
results = client.get_all(
|
|
533
|
+
"/api/soec-exploration-analysis-file/", params=params
|
|
534
|
+
)
|
|
535
|
+
else:
|
|
536
|
+
results = client.get("/api/soec-exploration-analysis-file/", params=params)
|
|
537
|
+
|
|
538
|
+
if json_output:
|
|
539
|
+
console.print_json(data=results)
|
|
540
|
+
return
|
|
541
|
+
|
|
542
|
+
columns = [
|
|
543
|
+
("ID", "id", None),
|
|
544
|
+
("Analysis", "analysis", None),
|
|
545
|
+
("File", "file", None),
|
|
546
|
+
("Created", "created_at", format_datetime),
|
|
547
|
+
]
|
|
548
|
+
|
|
549
|
+
items, footer_string = get_pagination_info(results)
|
|
550
|
+
|
|
551
|
+
if not items:
|
|
552
|
+
console.print(
|
|
553
|
+
f"[white]No analysis files found with the given criteria:[/white]\n[green]{params}"
|
|
554
|
+
)
|
|
555
|
+
return
|
|
556
|
+
|
|
557
|
+
table = create_table(
|
|
558
|
+
columns=columns,
|
|
559
|
+
items=items,
|
|
560
|
+
title="SOEC Analysis Files",
|
|
561
|
+
caption=footer_string,
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
console.print(table)
|