atomict 0.1.2__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.
Files changed (88) hide show
  1. atomict/__init__.py +1 -1
  2. atomict/__version__.py +1 -0
  3. atomict/api.py +182 -0
  4. atomict/auth.py +47 -0
  5. atomict/cli/commands/adsorbate.py +183 -0
  6. atomict/cli/commands/ai_assist.py +111 -0
  7. atomict/cli/commands/catalysis.py +171 -0
  8. atomict/cli/commands/common.py +57 -0
  9. atomict/cli/commands/exploration/__init__.py +7 -0
  10. atomict/cli/commands/exploration/soec.py +564 -0
  11. atomict/cli/commands/exploration/sqs.py +440 -0
  12. atomict/cli/commands/helpers.py +74 -0
  13. atomict/cli/commands/k8s.py +211 -0
  14. atomict/cli/commands/login.py +34 -0
  15. atomict/cli/commands/organization.py +76 -0
  16. atomict/cli/commands/project.py +876 -0
  17. atomict/cli/commands/simulation/__init__.py +20 -0
  18. atomict/cli/commands/simulation/catalysis.py +223 -0
  19. atomict/cli/commands/simulation/fhiaims.py +279 -0
  20. atomict/cli/commands/simulation/kpoint.py +380 -0
  21. atomict/cli/commands/simulation/vibes.py +161 -0
  22. atomict/cli/commands/simulation.py +176 -0
  23. atomict/cli/commands/task.py +181 -0
  24. atomict/cli/commands/upload.py +84 -0
  25. atomict/cli/commands/user.py +201 -0
  26. atomict/cli/core/client.py +202 -0
  27. atomict/cli/core/config.py +43 -0
  28. atomict/cli/core/utils.py +32 -0
  29. atomict/cli/main.py +124 -0
  30. atomict/env.py +79 -0
  31. atomict/exceptions.py +12 -0
  32. atomict/infra/distwork/environment.py +26 -0
  33. atomict/infra/distwork/task.py +49 -0
  34. atomict/infra/logging.py +22 -0
  35. atomict/io/cif.py +131 -0
  36. atomict/io/fhiaims.py +24 -0
  37. atomict/io/json.py +22 -0
  38. atomict/io/utils.py +11 -0
  39. atomict/ml/__init__.py +0 -0
  40. atomict/ml/model.py +13 -0
  41. atomict/project/__init__.py +1 -0
  42. atomict/project/link.py +26 -0
  43. atomict/project/note.py +18 -0
  44. atomict/project/project.py +32 -0
  45. atomict/project/tags.py +48 -0
  46. atomict/project/workbench.py +6 -0
  47. atomict/reality/__init__.py +0 -0
  48. atomict/reality/oqmd.py +5 -0
  49. atomict/reality/slabs.py +5 -0
  50. atomict/simulation/__init__.py +0 -0
  51. atomict/simulation/cantera.py +35 -0
  52. atomict/simulation/catalysis.py +20 -0
  53. atomict/simulation/counterfactual.py +28 -0
  54. atomict/simulation/ea.py +64 -0
  55. atomict/simulation/fhi_aims.py +72 -0
  56. atomict/simulation/kpoint.py +74 -0
  57. atomict/simulation/mlrelax.py +83 -0
  58. atomict/simulation/phonon.py +12 -0
  59. atomict/simulation/qe.py +74 -0
  60. atomict/simulation/sqs.py +24 -0
  61. atomict/simulation/utils.py +83 -0
  62. atomict/user/__init__.py +0 -0
  63. atomict/user/files.py +31 -0
  64. atomict/user/workspace.py +112 -0
  65. atomict/utils/fhiaims/__init__.py +0 -0
  66. atomict/utils/fhiaims/geometry.py +65 -0
  67. atomict/utils/tenacity.py +36 -0
  68. {atomict-0.1.2.dist-info → atomict-0.1.4.dist-info}/LICENSE +0 -0
  69. atomict-0.1.4.dist-info/METADATA +105 -0
  70. atomict-0.1.4.dist-info/RECORD +77 -0
  71. {atomict-0.1.2.dist-info → atomict-0.1.4.dist-info}/WHEEL +1 -1
  72. atomict-0.1.4.dist-info/entry_points.txt +2 -0
  73. {atomict-0.1.2.dist-info → atomict-0.1.4.dist-info}/top_level.txt +0 -1
  74. atomict/__main__.py +0 -3
  75. atomict/cli.py +0 -59
  76. atomict/datasets/__init__.py +0 -25
  77. atomict/datasets/io.py +0 -47
  78. atomict/datasets/public.py +0 -32
  79. atomict/utils/requests.py +0 -19
  80. atomict/version.py +0 -2
  81. atomict-0.1.2.dist-info/METADATA +0 -97
  82. atomict-0.1.2.dist-info/RECORD +0 -19
  83. atomict-0.1.2.dist-info/entry_points.txt +0 -2
  84. tests/test_sdk.py +0 -16
  85. /atomict/{auth → cli}/__init__.py +0 -0
  86. /atomict/{utils → infra}/__init__.py +0 -0
  87. {tests → atomict/infra/distwork}/__init__.py +0 -0
  88. /tests/test_cli.py → /atomict/io/__init__.py +0 -0
@@ -0,0 +1,440 @@
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
+
13
+ @click.group(name="sqs")
14
+ def sqs_group():
15
+ """Manage Special Quasirandom Structure (SQS) explorations"""
16
+ pass
17
+
18
+
19
+ @sqs_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 SQS exploration details or list all explorations"""
35
+ client = get_client()
36
+ console = Console()
37
+
38
+ if id:
39
+ result = client.get(f"/api/sqs-exploration/{id}/")
40
+ if json_output:
41
+ console.print_json(data=result)
42
+ return
43
+
44
+ console.print(Panel.fit(f"[bold]SQS Exploration Details[/bold]"))
45
+ console.print(f"ID: {result['id']}")
46
+ console.print(f"Name: {result.get('name', 'N/A')}")
47
+ console.print(f"Description: {result.get('description', 'N/A')}")
48
+ console.print(
49
+ f"Task status: {get_status_string(result['task'].get('status', 'N/A'))}"
50
+ )
51
+ console.print(f"Created: {format_datetime(result['created_at'])}")
52
+ console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
53
+ console.print(
54
+ f"Max Size: {'Auto' if result.get('auto_max_size') else result.get('max_size', 'N/A')}"
55
+ )
56
+ console.print(
57
+ f"Atom Count Limit: {result.get('atom_count_upper_limit', 'N/A')}"
58
+ )
59
+ console.print(f"Cluster Cutoffs: {result.get('cluster_cutoffs', [])}")
60
+
61
+ if result.get("task"):
62
+ console.print(f"Status: {get_status_string(result['task'].get('status'))}")
63
+ console.print(f"Running on: {result['task'].get('running_on', 'N/A')}")
64
+ else:
65
+ params = {}
66
+ if search is not None:
67
+ params["search"] = search
68
+ if ordering:
69
+ params["ordering"] = ordering
70
+
71
+ for f in filters:
72
+ try:
73
+ field, value = f.split("=", 1)
74
+ params[field] = value
75
+ except ValueError:
76
+ console.print(f"[red]Invalid filter format: {f}. Use field=value[/red]")
77
+ return
78
+
79
+ if fetch_all:
80
+ results = client.get_all("/api/sqs-exploration/", params=params)
81
+ else:
82
+ results = client.get("/api/sqs-exploration/", params=params)
83
+
84
+ if json_output:
85
+ console.print_json(data=results)
86
+ return
87
+
88
+ columns = [
89
+ ("ID", "id", None),
90
+ ("Name", "name", None),
91
+ (
92
+ "Project",
93
+ "task",
94
+ lambda x: x.get("project", "N/A") if isinstance(x, dict) else None,
95
+ ),
96
+ ("Max Size", "auto_max_size", lambda x: "Auto" if x else None),
97
+ ("Cluster Cutoffs", "cluster_cutoffs", None),
98
+ (
99
+ "Status",
100
+ "task",
101
+ lambda x: (
102
+ get_status_string(x.get("status")) if isinstance(x, dict) else None
103
+ ),
104
+ ),
105
+ ("Created", "created_at", format_datetime),
106
+ ]
107
+
108
+ items, footer_string = get_pagination_info(results)
109
+
110
+ if not items:
111
+ console.print(
112
+ f"[white]No SQS explorations found with the given criteria:[/white]\n[green]{params}"
113
+ )
114
+ return
115
+
116
+ table = create_table(
117
+ columns=columns,
118
+ items=items,
119
+ title="SQS Explorations",
120
+ caption=footer_string,
121
+ )
122
+
123
+ console.print(table)
124
+
125
+
126
+ @sqs_group.command()
127
+ @click.option("--name", help="Exploration name")
128
+ @click.option("--description", help="Exploration description")
129
+ @click.option("--project", required=True, help="Project ID")
130
+ @click.option("--auto-max-size", is_flag=True, help="Automatically determine max size")
131
+ @click.option("--max-size", type=int, help="Maximum structure size")
132
+ @click.option("--atom-count-limit", type=int, help="Upper limit for atom count")
133
+ @click.option("--cutoffs", type=float, multiple=True, help="Cluster cutoff values")
134
+ @click.option("--starting-structure", required=True, help="FHIAims simulation ID")
135
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
136
+ def create(
137
+ name: Optional[str],
138
+ description: Optional[str],
139
+ project: str,
140
+ auto_max_size: bool = False,
141
+ max_size: Optional[int] = None,
142
+ atom_count_limit: Optional[int] = None,
143
+ cutoffs: Optional[List[float]] = None,
144
+ starting_structure: str = None,
145
+ json_output: bool = False,
146
+ ):
147
+ """Create a new SQS exploration"""
148
+ client = get_client()
149
+ console = Console()
150
+
151
+ data = {"project": project, "auto_max_size": auto_max_size}
152
+ if name:
153
+ data["name"] = name
154
+ if description:
155
+ data["description"] = description
156
+ if max_size is not None:
157
+ data["max_size"] = max_size
158
+ if atom_count_limit is not None:
159
+ data["atom_count_upper_limit"] = atom_count_limit
160
+ if cutoffs:
161
+ data["cluster_cutoffs"] = list(cutoffs)
162
+ if starting_structure:
163
+ data["starting_structure"] = starting_structure
164
+
165
+ result = client.post("/api/sqs-exploration/", data=data)
166
+
167
+ if json_output:
168
+ console.print_json(data=result)
169
+ else:
170
+ console.print(f"[green]Created SQS exploration with ID: {result['id']}[/green]")
171
+
172
+
173
+ @sqs_group.command()
174
+ @click.argument("id")
175
+ def delete(id: str):
176
+ """Delete an SQS exploration"""
177
+ client = get_client()
178
+ client.delete(f"/api/sqs-exploration/{id}/")
179
+ console = Console()
180
+ console.print(f"[green]Deleted SQS exploration {id}[/green]")
181
+
182
+
183
+ @sqs_group.command()
184
+ @click.argument("id", required=False)
185
+ @click.option("--exploration", help="SQS Exploration ID to filter by")
186
+ @click.option("--ordering", help="Field to order results by")
187
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
188
+ @click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
189
+ def get_target_concentration(
190
+ id: Optional[str] = None,
191
+ exploration: Optional[str] = None,
192
+ ordering: Optional[str] = None,
193
+ json_output: bool = False,
194
+ fetch_all: bool = False,
195
+ ):
196
+ """Get SQS target concentration details or list all concentrations
197
+
198
+ When listing concentrations, --exploration must be provided.
199
+ """
200
+ client = get_client()
201
+ console = Console()
202
+
203
+ if id:
204
+ result = client.get(f"/api/sqs-target-concentration/{id}/")
205
+ if json_output:
206
+ console.print_json(data=result)
207
+ return
208
+
209
+ console.print(Panel.fit(f"[bold]SQS Target Concentration Details[/bold]"))
210
+ console.print(f"ID: {result['id']}")
211
+ console.print(f"Exploration: {result['exploration']}")
212
+ console.print(f"Element: {result.get('element', 'N/A')}")
213
+ console.print(f"Concentration: {result.get('concentration', 'N/A')}")
214
+ console.print(f"Weight: {result.get('weight', 'N/A')}")
215
+ else:
216
+ if not exploration:
217
+ console.print(
218
+ "[red]--exploration is required when listing concentrations[/red]"
219
+ )
220
+ return
221
+
222
+ params = {"exploration": exploration}
223
+ if ordering:
224
+ params["ordering"] = ordering
225
+
226
+ if fetch_all:
227
+ results = client.get_all("/api/sqs-target-concentration/", params=params)
228
+ else:
229
+ results = client.get("/api/sqs-target-concentration/", params=params)
230
+
231
+ if json_output:
232
+ console.print_json(data=results)
233
+ return
234
+
235
+ columns = [
236
+ ("ID", "id", None),
237
+ ("Element", "element", None),
238
+ ("Concentration", "concentration", None),
239
+ ("Created", "created_at", format_datetime),
240
+ ]
241
+
242
+ items, footer_string = get_pagination_info(results)
243
+
244
+ if not items:
245
+ console.print(
246
+ f"[white]No target concentrations found with the given criteria:[/white]\n[green]{params}"
247
+ )
248
+ return
249
+
250
+ table = create_table(
251
+ columns=columns,
252
+ items=items,
253
+ title="SQS Target Concentrations",
254
+ caption=footer_string,
255
+ )
256
+
257
+ console.print(table)
258
+
259
+
260
+ @sqs_group.command()
261
+ @click.option("--exploration", required=True, help="SQS Exploration ID")
262
+ @click.option("--element", required=True, help="Element symbol")
263
+ @click.option(
264
+ "--concentration", required=True, type=float, help="Target concentration (0-1)"
265
+ )
266
+ @click.option("--weight", type=float, help="Weight for this target concentration")
267
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
268
+ def create_target_concentration(
269
+ exploration: str,
270
+ element: str,
271
+ concentration: float,
272
+ weight: float,
273
+ json_output: bool = False,
274
+ ):
275
+ """Create a new SQS target concentration entry"""
276
+ client = get_client()
277
+ console = Console()
278
+
279
+ if not 0 <= concentration <= 1:
280
+ console.print("[red]Concentration must be between 0 and 1[/red]")
281
+ return
282
+
283
+ data = {
284
+ "exploration": exploration,
285
+ "element": element,
286
+ "concentration": concentration,
287
+ "weight": weight,
288
+ }
289
+
290
+ result = client.post("/api/sqs-target-concentration/", data=data)
291
+
292
+ if json_output:
293
+ console.print_json(data=result)
294
+ else:
295
+ console.print(
296
+ f"[green]Created target concentration for {element} with ID: {result['id']}[/green]"
297
+ )
298
+
299
+
300
+ @sqs_group.command()
301
+ @click.argument("id")
302
+ def delete_target_concentration(id: str):
303
+ """Delete a SQS target concentration entry"""
304
+ client = get_client()
305
+ client.delete(f"/api/sqs-target-concentration/{id}/")
306
+ console = Console()
307
+ console.print(f"[green]Deleted target concentration {id}[/green]")
308
+
309
+
310
+ @sqs_group.command()
311
+ @click.option("--exploration", required=True, help="SQS Exploration ID")
312
+ @click.option("--user-upload", required=True, help="Upload ID of the file")
313
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
314
+ def create_simulation_file(
315
+ exploration: str, user_upload: str, json_output: bool = False
316
+ ):
317
+ """Create a new SQS simulation file entry"""
318
+ client = get_client()
319
+ console = Console()
320
+
321
+ data = {
322
+ "exploration": exploration,
323
+ "user_upload": user_upload,
324
+ }
325
+
326
+ result = client.post("/api/sqs-simulation-file/", data=data)
327
+
328
+ if json_output:
329
+ console.print_json(data=result)
330
+ else:
331
+ console.print(
332
+ f"[green]Created SQS simulation file with ID: {result['id']}[/green]"
333
+ )
334
+
335
+
336
+ @sqs_group.command()
337
+ @click.argument("id", required=False)
338
+ @click.option("--exploration", help="SQS Exploration ID to filter by")
339
+ @click.option("--ordering", help="Field to order results by")
340
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
341
+ @click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
342
+ def get_simulation_file(
343
+ id: Optional[str] = None,
344
+ exploration: Optional[str] = None,
345
+ ordering: Optional[str] = None,
346
+ json_output: bool = False,
347
+ fetch_all: bool = False,
348
+ ):
349
+ """Get SQS simulation file details or list all files
350
+
351
+ When listing files, --exploration must be provided.
352
+ """
353
+ client = get_client()
354
+ console = Console()
355
+
356
+ if id:
357
+ result = client.get(f"/api/sqs-simulation-file/{id}/")
358
+ if json_output:
359
+ console.print_json(data=result)
360
+ return
361
+
362
+ console.print(Panel.fit(f"[bold]SQS Simulation File Details[/bold]"))
363
+ console.print(f"ID: {result['id']}")
364
+ console.print(f"Exploration: {result['exploration']}")
365
+ console.print(f"Upload ID: {result['user_upload'].get('id')}")
366
+ console.print(f"File Name: {result['user_upload'].get('orig_name')}")
367
+ console.print(f"File Size: {result['user_upload'].get('size')} bytes")
368
+ console.print(
369
+ f"Uploaded: {format_datetime(result['user_upload'].get('uploaded'))}"
370
+ )
371
+ else:
372
+ if not exploration:
373
+ console.print("[red]--exploration is required when listing files[/red]")
374
+ return
375
+
376
+ params = {"exploration": exploration}
377
+ if ordering:
378
+ params["ordering"] = ordering
379
+
380
+ if fetch_all:
381
+ results = client.get_all("/api/sqs-simulation-file/", params=params)
382
+ else:
383
+ results = client.get("/api/sqs-simulation-file/", params=params)
384
+
385
+ if json_output:
386
+ console.print_json(data=results)
387
+ return
388
+
389
+ columns = [
390
+ ("ID", "id", None),
391
+ (
392
+ "Upload ID",
393
+ "user_upload",
394
+ lambda x: x["id"] if isinstance(x, dict) else None,
395
+ ),
396
+ (
397
+ "File Name",
398
+ "user_upload",
399
+ lambda x: x["orig_name"] if isinstance(x, dict) else None,
400
+ ),
401
+ (
402
+ "Size",
403
+ "user_upload",
404
+ lambda x: f"{x['size']} bytes" if isinstance(x, dict) else None,
405
+ ),
406
+ (
407
+ "Uploaded",
408
+ "user_upload",
409
+ lambda x: (
410
+ format_datetime(x["uploaded"]) if isinstance(x, dict) else None
411
+ ),
412
+ ),
413
+ ]
414
+
415
+ items, footer_string = get_pagination_info(results)
416
+
417
+ if not items:
418
+ console.print(
419
+ f"[white]No simulation files found with the given criteria:[/white]\n[green]{params}"
420
+ )
421
+ return
422
+
423
+ table = create_table(
424
+ columns=columns,
425
+ items=items,
426
+ title="SQS Simulation Files",
427
+ caption=footer_string,
428
+ )
429
+
430
+ console.print(table)
431
+
432
+
433
+ @sqs_group.command()
434
+ @click.argument("id")
435
+ def delete_simulation_file(id: str):
436
+ """Delete a SQS simulation file"""
437
+ client = get_client()
438
+ client.delete(f"/api/sqs-simulation-file/{id}/")
439
+ console = Console()
440
+ console.print(f"[green]Deleted SQS simulation file {id}[/green]")
@@ -0,0 +1,74 @@
1
+ # cli/commands/simulation/helpers.py
2
+ from datetime import datetime
3
+ from typing import Any, Dict, Optional
4
+
5
+ from rich.table import Table
6
+
7
+
8
+ # TODO: move to common?
9
+ def get_status_string(status_code: Optional[int]) -> str:
10
+ """Convert status code to human readable string"""
11
+ status_map = {
12
+ 0: "Draft",
13
+ 1: "Ready",
14
+ 2: "Running",
15
+ 3: "Completed",
16
+ 4: "Error",
17
+ 5: "Paused",
18
+ 6: "User Aborted",
19
+ }
20
+ if status_code is None:
21
+ return "N/A"
22
+ return status_map.get(status_code, "N/A")
23
+
24
+
25
+ def format_datetime(dt_str: str) -> str:
26
+ """Format datetime string for display"""
27
+ try:
28
+ dt = datetime.fromisoformat(dt_str.replace("Z", "+00:00"))
29
+ return dt.strftime("%Y-%m-%d %H:%M:%S")
30
+ except (ValueError, AttributeError):
31
+ return "N/A"
32
+
33
+
34
+ def create_detail_table(
35
+ title: str, data: Dict[str, Any], fields: Dict[str, str]
36
+ ) -> Table:
37
+ """Create a detail table with specified fields"""
38
+ table = Table(show_header=True, title=title)
39
+ table.add_column("Property")
40
+ table.add_column("Value")
41
+
42
+ for label, field in fields.items():
43
+ value = data.get(field, "N/A")
44
+ table.add_row(label, str(value))
45
+
46
+ return table
47
+
48
+
49
+ def format_task_status(task: Dict[str, Any]) -> Table:
50
+ """Format task information into a table"""
51
+ if not task:
52
+ return None
53
+
54
+ task_info = Table(show_header=True, title="Task Status")
55
+ task_info.add_column("Property")
56
+ task_info.add_column("Value")
57
+
58
+ fields = {
59
+ "Status": "status",
60
+ "Progress": lambda t: f"{t.get('progress', 0)}%",
61
+ "Running On": "running_on",
62
+ "Created": lambda t: format_datetime(t.get("created_at", "")),
63
+ "Updated": lambda t: format_datetime(t.get("updated_at", "")),
64
+ "Error": "error",
65
+ }
66
+
67
+ for label, field in fields.items():
68
+ if callable(field):
69
+ value = field(task)
70
+ else:
71
+ value = task.get(field, "N/A")
72
+ task_info.add_row(label, str(value))
73
+
74
+ return task_info