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.
Files changed (89) 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 +89 -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 +130 -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 +138 -0
  36. atomict/io/fhiaims.py +30 -0
  37. atomict/io/json.py +28 -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/mattergen.py +20 -0
  58. atomict/simulation/mlrelax.py +83 -0
  59. atomict/simulation/phonon.py +12 -0
  60. atomict/simulation/qe.py +74 -0
  61. atomict/simulation/sqs.py +24 -0
  62. atomict/simulation/utils.py +90 -0
  63. atomict/user/__init__.py +0 -0
  64. atomict/user/files.py +31 -0
  65. atomict/user/workspace.py +112 -0
  66. atomict/utils/fhiaims/__init__.py +0 -0
  67. atomict/utils/fhiaims/geometry.py +73 -0
  68. atomict/utils/tenacity.py +36 -0
  69. {atomict-0.1.2.dist-info → atomict-0.2.4.dist-info}/LICENSE +0 -0
  70. atomict-0.2.4.dist-info/METADATA +109 -0
  71. atomict-0.2.4.dist-info/RECORD +78 -0
  72. {atomict-0.1.2.dist-info → atomict-0.2.4.dist-info}/WHEEL +1 -1
  73. atomict-0.2.4.dist-info/entry_points.txt +2 -0
  74. {atomict-0.1.2.dist-info → atomict-0.2.4.dist-info}/top_level.txt +0 -1
  75. atomict/__main__.py +0 -3
  76. atomict/cli.py +0 -59
  77. atomict/datasets/__init__.py +0 -25
  78. atomict/datasets/io.py +0 -47
  79. atomict/datasets/public.py +0 -32
  80. atomict/utils/requests.py +0 -19
  81. atomict/version.py +0 -2
  82. atomict-0.1.2.dist-info/METADATA +0 -97
  83. atomict-0.1.2.dist-info/RECORD +0 -19
  84. atomict-0.1.2.dist-info/entry_points.txt +0 -2
  85. tests/test_sdk.py +0 -16
  86. /atomict/{auth → cli}/__init__.py +0 -0
  87. /atomict/{utils → infra}/__init__.py +0 -0
  88. {tests → atomict/infra/distwork}/__init__.py +0 -0
  89. /tests/test_cli.py → /atomict/io/__init__.py +0 -0
@@ -0,0 +1,20 @@
1
+ # cli/commands/simulation/__init__.py
2
+ import click
3
+
4
+ from . import catalysis, fhiaims # qe,; phonon,; kpoint,
5
+
6
+
7
+ @click.group(name="simulation")
8
+ def simulation_group():
9
+ """Manage all types of simulations"""
10
+ pass
11
+
12
+
13
+ # Add simulation type subcommands
14
+ simulation_group.add_command(catalysis.catalysis)
15
+ # simulation_group.add_command(qe.qe)
16
+ simulation_group.add_command(fhiaims.fhiaims_group)
17
+ # simulation_group.add_command(phonon.phonon)
18
+ # simulation_group.add_command(kpoint.kpoint)
19
+
20
+ simulation = simulation_group
@@ -0,0 +1,223 @@
1
+ # cli/commands/simulation/catalysis.py
2
+ from typing import Any, Dict, Optional
3
+
4
+ import click
5
+ from rich.console import Console
6
+ from rich.panel import Panel
7
+ from rich.table import Table
8
+
9
+ from atomict.cli.commands.helpers import (
10
+ create_detail_table,
11
+ format_datetime,
12
+ format_task_status,
13
+ )
14
+ from atomict.cli.core.client import get_client
15
+
16
+ console = Console()
17
+
18
+
19
+ @click.group(name="catalysis")
20
+ def catalysis_group():
21
+ """Manage catalysis simulations"""
22
+ pass
23
+
24
+
25
+ def format_catalysis_table(simulations: list[Dict[str, Any]]) -> Table:
26
+ """Create a table with catalysis simulation fields"""
27
+ table = Table(show_header=True)
28
+
29
+ columns = {
30
+ "ID": lambda x: str(x["id"]),
31
+ "Name": lambda x: x.get("name", "N/A"),
32
+ "Status": lambda x: x.get("task", {}).get("status", "N/A"),
33
+ "Progress": lambda x: f"{x.get('task', {}).get('progress', 0)}%",
34
+ "Results": lambda x: x.get("num_results", "0"),
35
+ "Created": lambda x: format_datetime(x.get("created_at", "")),
36
+ }
37
+
38
+ for col_name in columns:
39
+ table.add_column(col_name)
40
+
41
+ for sim in simulations:
42
+ row = [columns[col_name](sim) for col_name in columns]
43
+ table.add_row(*row)
44
+
45
+ return table
46
+
47
+
48
+ def format_catalysis_detail(sim: Dict[str, Any]) -> None:
49
+ """Display detailed catalysis simulation information"""
50
+ # Main info panel
51
+ console.print(Panel(f"[bold]{sim.get('name', 'Unnamed Simulation')}[/bold]"))
52
+
53
+ # Basic info
54
+ basic_fields = {
55
+ "ID": "id",
56
+ "Name": "name",
57
+ "Created": "created_at",
58
+ "Edited": "edited_at",
59
+ "Bulk ID": "bulk_id",
60
+ "Slab ID": "slab_id",
61
+ "Calculator": "calculator_class",
62
+ "Max Force": "fmax",
63
+ "Steps": "steps",
64
+ }
65
+ console.print(create_detail_table("Basic Information", sim, basic_fields))
66
+
67
+ # Task status
68
+ if task_table := format_task_status(sim.get("task")):
69
+ console.print(task_table)
70
+
71
+ # Results summary
72
+ results_fields = {
73
+ "Total Results": "num_results",
74
+ "Dissociated": "num_results_dissociated",
75
+ "Desorbed": "num_results_desorbed",
76
+ "Surface Changed": "num_results_surface_changed",
77
+ "Intercalated": "num_results_intercalated",
78
+ }
79
+ console.print(create_detail_table("Results Summary", sim, results_fields))
80
+
81
+
82
+ def format_results_detail(results: Dict[str, Any]) -> None:
83
+ """Display detailed simulation results"""
84
+ # Energy and convergence info
85
+ energy_table = Table(show_header=True, title="Energy Results")
86
+ energy_table.add_column("Property")
87
+ energy_table.add_column("Value")
88
+
89
+ energy_fields = {
90
+ "Total Energy": "energy",
91
+ "ML Energy": "ml_energy",
92
+ "Min ML Energy": "min_ml_energy",
93
+ "Converged": lambda r: "✓" if r.get("converged") else "✗",
94
+ "Force Calls": "force_calls",
95
+ }
96
+
97
+ for label, field in energy_fields.items():
98
+ if callable(field):
99
+ value = field(results)
100
+ else:
101
+ value = results.get(field, "N/A")
102
+ energy_table.add_row(label, str(value))
103
+
104
+ console.print(energy_table)
105
+
106
+ # Structure information
107
+ if structure := results.get("final_structure"):
108
+ structure_table = Table(show_header=True, title="Final Structure")
109
+ structure_table.add_column("Property")
110
+ structure_table.add_column("Value")
111
+
112
+ structure_fields = {
113
+ "Atoms": "num_atoms",
114
+ "Cell": "cell",
115
+ "Positions": "positions",
116
+ "Forces": "forces",
117
+ }
118
+
119
+ for label, field in structure_fields.items():
120
+ value = structure.get(field, "N/A")
121
+ structure_table.add_row(label, str(value))
122
+
123
+ console.print(structure_table)
124
+
125
+
126
+ @catalysis_group.command()
127
+ @click.argument("id", required=False)
128
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
129
+ def get(id: Optional[str] = None, json_output: bool = False):
130
+ """Get catalysis simulation details or list all"""
131
+ # TODO: support more options, filtering, and search
132
+ client = get_client()
133
+
134
+ if id:
135
+ result = client.get(f"/api/catalysis-simulation/{id}/")
136
+ if json_output:
137
+ console.print_json(data=result)
138
+ return
139
+ format_catalysis_detail(result)
140
+ else:
141
+ results = client.get_all("/api/catalysis-simulation/")
142
+ if json_output:
143
+ console.print_json(data=results)
144
+ return
145
+
146
+ # Add pagination info
147
+ if isinstance(results, dict):
148
+ items = results.get("results", [])
149
+ count = results.get("count")
150
+ page_size = len(items)
151
+ if count and page_size:
152
+ console.print(f"\nShowing page 1 of {(count - 1) // page_size + 1}")
153
+ console.print(f"Total items: {count}")
154
+ if results.get("next"):
155
+ console.print("Use --all to fetch all results")
156
+ else:
157
+ items = results
158
+
159
+ console.print(format_catalysis_table(items)) # Make sure we print the table
160
+
161
+
162
+ @catalysis_group.group(name="results")
163
+ def results_group():
164
+ """Manage catalysis simulation results"""
165
+ pass
166
+
167
+
168
+ @results_group.command(name="get")
169
+ @click.argument("id", required=False)
170
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
171
+ @click.option("--simulation-id", help="Filter by simulation ID")
172
+ @click.option("--converged", type=bool, help="Filter by convergence status")
173
+ def results_get(
174
+ id: Optional[str] = None,
175
+ json_output: bool = False,
176
+ simulation_id: Optional[str] = None,
177
+ converged: Optional[bool] = None,
178
+ ):
179
+ """Get simulation results details or list all results"""
180
+ client = get_client()
181
+
182
+ params = {}
183
+ if simulation_id:
184
+ params["simulation"] = simulation_id
185
+ if converged is not None:
186
+ params["converged"] = converged
187
+
188
+ if id:
189
+ result = client.get(f"/api/catalysis-simulation-results/{id}/")
190
+ if json_output:
191
+ console.print_json(data=result)
192
+ return
193
+ format_results_detail(result)
194
+ else:
195
+ results = client.get_all("/api/catalysis-simulation-results/", params)
196
+ if json_output:
197
+ console.print_json(data=results)
198
+ return
199
+
200
+ table = Table(show_header=True)
201
+ table.add_column("ID")
202
+ table.add_column("Simulation")
203
+ table.add_column("Energy")
204
+ table.add_column("ML Energy")
205
+ table.add_column("Converged")
206
+ table.add_column("Created")
207
+
208
+ for res in results:
209
+ table.add_row(
210
+ str(res["id"]),
211
+ str(res.get("simulation", "N/A")),
212
+ str(res.get("energy", "N/A")),
213
+ str(res.get("ml_energy", "N/A")),
214
+ "✓" if res.get("converged") else "✗",
215
+ format_datetime(res.get("created_at", "")),
216
+ )
217
+ console.print(table)
218
+
219
+
220
+ # Add results group to catalysis group
221
+ catalysis_group.add_command(results_group)
222
+
223
+ catalysis = catalysis_group
@@ -0,0 +1,279 @@
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="fhiaims")
15
+ def fhiaims_group():
16
+ """Manage FHI-aims simulations"""
17
+ pass
18
+
19
+
20
+ @fhiaims_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
+ # filter should be enum to match DRF config
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 simulation details or list all simulations"""
37
+ client = get_client()
38
+
39
+ if id:
40
+ simulation = client.get(f"/api/fhiaims-simulation/{id}/")
41
+ if json_output:
42
+ console.print_json(data=simulation)
43
+ return
44
+ # Format single simulation output
45
+ console.print(f"ID: {simulation['id']}")
46
+ console.print(f"Name: {simulation.get('name', 'N/A')}")
47
+ console.print(f"Finite diff displacement: {simulation.get('finite_diff_displacement', 'N/A')}")
48
+ console.print(f"Created: {format_datetime(simulation['created_at'])}")
49
+ if simulation.get("task"):
50
+ status = get_status_string(simulation["task"].get("status"))
51
+ console.print(f"Status: {status}")
52
+ else:
53
+ params = {}
54
+ if search:
55
+ params["search"] = search
56
+ if ordering:
57
+ params["ordering"] = ordering
58
+
59
+ # Add filter parameters
60
+ for f in filters:
61
+ try:
62
+ field, value = f.split("=", 1)
63
+ params[field] = value
64
+ except ValueError:
65
+ click.echo(f"Invalid filter format: {f}. Use field=value", err=True)
66
+ return
67
+
68
+ # Updated this section
69
+ if fetch_all:
70
+ # list
71
+ results = client.get_all("/api/fhiaims-simulation/", params=params)
72
+ else:
73
+ # dict
74
+ results = client.get("/api/fhiaims-simulation/", params=params)
75
+
76
+ if json_output:
77
+ console.print_json(data=results)
78
+ return
79
+
80
+ # Define columns based on what's already in the table_0 setup
81
+ columns = [
82
+ ("ID", "id", None),
83
+ ("Name", "name", None),
84
+ ("Finite diff displacement", "finite_diff_displacement", None),
85
+ ("Task status", "task", lambda x: get_status_string(x.get("status"))),
86
+ ("Created", "created_at", format_datetime),
87
+ (
88
+ "Status",
89
+ "task",
90
+ lambda x: get_status_string(
91
+ x.get("status") if isinstance(x, dict) else None
92
+ ),
93
+ ),
94
+ ]
95
+
96
+ items, footer_string = get_pagination_info(results)
97
+
98
+ if not items:
99
+ console.print(
100
+ f"[white]No simulations found with the given criteria:[/white]\n[green]{params}"
101
+ )
102
+ return
103
+
104
+ table = create_table(
105
+ columns=columns,
106
+ items=items,
107
+ title="FHI-aims Simulations",
108
+ caption=footer_string,
109
+ )
110
+
111
+ console.print(table)
112
+
113
+
114
+ @fhiaims_group.command()
115
+ @click.option("--name", help="Simulation name")
116
+ @click.option("--description", help="Simulation description")
117
+ @click.option("--control-file", required=True, help="Control file content")
118
+ @click.option("--geometry-file", required=True, help="Geometry file content")
119
+ @click.option(
120
+ "--generate-finite-diff",
121
+ is_flag=True,
122
+ help="Generate finite difference displacements",
123
+ )
124
+ @click.option(
125
+ "--finite-diff-displacement",
126
+ type=float,
127
+ help="Finite difference displacement value",
128
+ )
129
+ def create(
130
+ name: Optional[str],
131
+ description: Optional[str],
132
+ control_file: str,
133
+ geometry_file: str,
134
+ generate_finite_diff: bool = False,
135
+ finite_diff_displacement: Optional[float] = None,
136
+ ):
137
+ """Create a new FHI-aims simulation"""
138
+ client = get_client()
139
+ data = {
140
+ "control_file": control_file,
141
+ "geometry_file": geometry_file,
142
+ "generate_finite_diff_displacements": generate_finite_diff,
143
+ }
144
+ if name:
145
+ data["name"] = name
146
+ if description:
147
+ data["description"] = description
148
+ if finite_diff_displacement is not None:
149
+ data["finite_diff_displacement"] = finite_diff_displacement
150
+
151
+ simulation = client.post("/api/fhiaims-simulation/", data=data)
152
+ console.print(f"[green]Created simulation with ID: {simulation['id']}[/green]")
153
+
154
+
155
+ @fhiaims_group.command()
156
+ @click.argument("id")
157
+ def delete(id: str):
158
+ """Delete a FHI-aims simulation"""
159
+ client = get_client()
160
+ client.delete(f"/api/fhiaims-simulation/{id}/")
161
+ console.print(f"[green]Deleted simulation {id}[/green]")
162
+
163
+
164
+ @fhiaims_group.command()
165
+ @click.argument("id", required=False)
166
+ @click.option("--search", help="Search term")
167
+ @click.option("--ordering", help="Field to order results by")
168
+ @click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
169
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
170
+ @click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
171
+ def get_files(
172
+ id: Optional[str] = None,
173
+ search: Optional[str] = None,
174
+ ordering: Optional[str] = None,
175
+ filters: tuple = (),
176
+ json_output: bool = False,
177
+ fetch_all: bool = False,
178
+ ):
179
+ """Get simulation file details or list all simulation files"""
180
+ client = get_client()
181
+
182
+ if id:
183
+ file = client.get(f"/api/fhiaims-simulation-file/{id}/")
184
+ if json_output:
185
+ console.print_json(data=file)
186
+ return
187
+
188
+ # Format single file output
189
+ console.print(f"ID: {file['id']}")
190
+ console.print(f"Simulation ID: {file['simulation']['id']}")
191
+ if file.get("user_upload"):
192
+ console.print(f"File Name: {file['user_upload'].get('users_name', 'N/A')}")
193
+ console.print(
194
+ f"Original Name: {file['user_upload'].get('orig_name', 'N/A')}"
195
+ )
196
+ console.print(f"Size: {file['user_upload'].get('size', 'N/A')} bytes")
197
+ console.print(
198
+ f"Uploaded: {format_datetime(file['user_upload'].get('uploaded'))}"
199
+ )
200
+ if file["user_upload"].get("users_description"):
201
+ console.print(
202
+ f"Description: {file['user_upload']['users_description']}"
203
+ )
204
+ else:
205
+ params = {}
206
+ if search:
207
+ params["search"] = search
208
+ if ordering:
209
+ params["ordering"] = ordering
210
+
211
+ # Add filter parameters
212
+ for f in filters:
213
+ try:
214
+ field, value = f.split("=", 1)
215
+ params[field] = value
216
+ except ValueError:
217
+ click.echo(f"Invalid filter format: {f}. Use field=value", err=True)
218
+ return
219
+
220
+ if fetch_all:
221
+ results = client.get_all("/api/fhiaims-simulation-file/", params=params)
222
+ else:
223
+ results = client.get("/api/fhiaims-simulation-file/", params=params)
224
+
225
+ if json_output:
226
+ console.print_json(data=results)
227
+ return
228
+
229
+ columns = [
230
+ ("ID", "id", None),
231
+ (
232
+ "Simulation",
233
+ "simulation",
234
+ lambda x: x.get("id") if isinstance(x, dict) else None,
235
+ ),
236
+ (
237
+ "File Name",
238
+ "user_upload",
239
+ lambda x: x.get("users_name") if isinstance(x, dict) else None,
240
+ ),
241
+ (
242
+ "Original Name",
243
+ "user_upload",
244
+ lambda x: x.get("orig_name") if isinstance(x, dict) else None,
245
+ ),
246
+ (
247
+ "Size (bytes)",
248
+ "user_upload",
249
+ lambda x: (
250
+ str(x.get("size"))
251
+ if isinstance(x, dict) and x.get("size") is not None
252
+ else None
253
+ ),
254
+ ),
255
+ (
256
+ "Uploaded",
257
+ "user_upload",
258
+ lambda x: (
259
+ format_datetime(x.get("uploaded")) if isinstance(x, dict) else None
260
+ ),
261
+ ),
262
+ ]
263
+
264
+ items, footer_string = get_pagination_info(results)
265
+
266
+ if not items:
267
+ console.print(
268
+ f"[white]No simulation files found with the given criteria:[/white]\n[green]{params}"
269
+ )
270
+ return
271
+
272
+ table = create_table(
273
+ columns=columns,
274
+ items=items,
275
+ title="FHI-aims Simulation Files",
276
+ caption=footer_string,
277
+ )
278
+
279
+ console.print(table)