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,211 @@
1
+ # cli/commands/k8s.py
2
+ from typing import Optional
3
+
4
+ import click
5
+ from rich.console import Console
6
+ from rich.panel import Panel
7
+
8
+ from atomict.cli.commands.common import create_table
9
+ from atomict.cli.commands.helpers import format_datetime
10
+ from atomict.cli.core.client import get_client
11
+ from atomict.cli.core.utils import get_pagination_info
12
+
13
+ console = Console()
14
+
15
+
16
+ @click.group(name="k8s")
17
+ def k8s():
18
+ """Manage Kubernetes jobs and clusters"""
19
+ pass
20
+
21
+
22
+ @k8s.command()
23
+ @click.argument("id", required=False)
24
+ @click.option("--search", help="Search term")
25
+ @click.option("--ordering", help="Field to order results by")
26
+ @click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
27
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
28
+ @click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
29
+ def get(
30
+ id: Optional[str] = None,
31
+ search: Optional[str] = None,
32
+ ordering: Optional[str] = None,
33
+ filters: tuple = (),
34
+ json_output: bool = False,
35
+ fetch_all: bool = False,
36
+ ):
37
+ """Get cluster details or list all clusters"""
38
+ client = get_client()
39
+ console = Console()
40
+
41
+ if id:
42
+ cluster = client.get(f"/api/k8s-cluster/{id}/")
43
+ if json_output:
44
+ console.print_json(data=cluster)
45
+ return
46
+
47
+ # Format single cluster output
48
+ console.print(Panel(f"[bold]Kubernetes Cluster Details[/bold]"))
49
+ console.print(f"ID: {cluster['id']}")
50
+ console.print(f"Name: {cluster.get('name', 'N/A')}")
51
+ console.print(f"Loki URL: {cluster.get('loki_url', 'N/A')}")
52
+ console.print(f"Active: {cluster.get('active', False)}")
53
+ if cluster.get("description"):
54
+ console.print(f"Description: {cluster['description']}")
55
+ console.print(f"Created: {format_datetime(cluster.get('created_at'))}")
56
+ console.print(f"Updated: {format_datetime(cluster.get('updated_at'))}")
57
+
58
+ else:
59
+ params = {}
60
+ if search:
61
+ params["search"] = search
62
+ if ordering:
63
+ params["ordering"] = ordering
64
+
65
+ # Add filter parameters
66
+ for f in filters:
67
+ try:
68
+ field, value = f.split("=", 1)
69
+ params[field] = value
70
+ except ValueError:
71
+ click.echo(
72
+ f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
73
+ )
74
+ return
75
+
76
+ if fetch_all:
77
+ results = client.get_all("/api/k8s-cluster/", params=params)
78
+ else:
79
+ results = client.get("/api/k8s-cluster/", params=params)
80
+
81
+ if json_output:
82
+ console.print_json(data=results)
83
+ return
84
+
85
+ columns = [
86
+ ("ID", "id", None),
87
+ ("Name", "name", None),
88
+ ("Loki URL", "loki_url", None),
89
+ ("Active", "active", str),
90
+ ("Created", "created_at", format_datetime),
91
+ ("Updated", "updated_at", format_datetime),
92
+ ]
93
+
94
+ items, footer_string = get_pagination_info(results)
95
+
96
+ if not items:
97
+ console.print(
98
+ f"[white]No clusters found with the given criteria:[/white]\n[green]{params}"
99
+ )
100
+ return
101
+
102
+ table = create_table(
103
+ columns=columns,
104
+ items=items,
105
+ title="Kubernetes Clusters",
106
+ caption=footer_string,
107
+ )
108
+
109
+ console.print(table)
110
+
111
+
112
+ @k8s.command()
113
+ @click.argument("id", required=False)
114
+ @click.option("--search", help="Search term")
115
+ @click.option("--ordering", help="Field to order results by")
116
+ @click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
117
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
118
+ @click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
119
+ def get_job(
120
+ id: Optional[str] = None,
121
+ search: Optional[str] = None,
122
+ ordering: Optional[str] = None,
123
+ filters: tuple = (),
124
+ json_output: bool = False,
125
+ fetch_all: bool = False,
126
+ ):
127
+ """Get K8s job details or list all jobs"""
128
+ client = get_client()
129
+ console = Console()
130
+
131
+ if id:
132
+ job = client.get(f"/api/k8s-job/{id}/")
133
+ if json_output:
134
+ console.print_json(data=job)
135
+ return
136
+
137
+ # Format single job output
138
+ console.print(Panel(f"[bold]K8s Job Details[/bold]"))
139
+ console.print(f"ID: {job['id']}")
140
+ console.print(f"Name: {job.get('name', 'N/A')}")
141
+ console.print(f"Status: {job.get('status', 'N/A')}")
142
+ console.print(f"CPU Request: {job.get('cpu_request', 'N/A')}")
143
+ console.print(f"CPU Limit: {job.get('cpu_limit', 'N/A')}")
144
+ console.print(f"Memory Request: {job.get('memory_request', 'N/A')}")
145
+ console.print(f"Memory Limit: {job.get('memory_limit', 'N/A')}")
146
+
147
+ else:
148
+ params = {}
149
+ if search:
150
+ params["search"] = search
151
+ if ordering:
152
+ params["ordering"] = ordering
153
+
154
+ # Add filter parameters
155
+ for f in filters:
156
+ try:
157
+ field, value = f.split("=", 1)
158
+ params[field] = value
159
+ except ValueError:
160
+ click.echo(
161
+ f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
162
+ )
163
+ return
164
+
165
+ if fetch_all:
166
+ results = client.get_all("/api/k8s-job/", params=params)
167
+ else:
168
+ results = client.get("/api/k8s-job/", params=params)
169
+
170
+ if json_output:
171
+ console.print_json(data=results)
172
+ return
173
+
174
+ columns = [
175
+ ("ID", "id", None),
176
+ ("Name", "name", None),
177
+ ("Status", "status", None),
178
+ ("CPU Req", "cpu_request", None),
179
+ ("CPU Limit", "cpu_limit", None),
180
+ ("Mem Req", "memory_request", None),
181
+ ("Mem Limit", "memory_limit", None),
182
+ ]
183
+
184
+ items, footer_string = get_pagination_info(results)
185
+
186
+ if not items:
187
+ console.print(
188
+ f"[white]No jobs found with the given criteria:[/white]\n[green]{params}"
189
+ )
190
+ return
191
+
192
+ table = create_table(
193
+ columns=columns, items=items, title="Kubernetes Jobs", caption=footer_string
194
+ )
195
+
196
+ console.print(table)
197
+
198
+
199
+ # TBD: not supported
200
+ # @k8s.command()
201
+ @click.argument("id")
202
+ def logs(id: str):
203
+ """Stream logs from a K8s job"""
204
+ client = get_client()
205
+
206
+ try:
207
+ # TODO:
208
+ for log_line in client.stream(f"/api/k8s-job/{id}/logs/"):
209
+ console.print(log_line.get("message", ""))
210
+ except KeyboardInterrupt:
211
+ console.print("\n[yellow]Stopped log streaming[/yellow]")
@@ -0,0 +1,34 @@
1
+ import sys
2
+
3
+ import click
4
+ from rich.console import Console
5
+
6
+ from ..core.client import APIClient
7
+ from ..core.config import Config, CONFIG_FILE
8
+
9
+
10
+ @click.command(name="login",
11
+ help=f"""Log in to your account and store an authentication token to {CONFIG_FILE}.
12
+ Previous tokens will be overwritten.""")
13
+ @click.option("--username", prompt=True)
14
+ @click.option("--password", prompt=True, hide_input=True)
15
+ def _login(username: str, password: str):
16
+ client = APIClient()
17
+ response = client.auth(username, password)
18
+ token = response.get("token")
19
+ redirect = response.get("redirect")
20
+
21
+ if redirect in ['terms', 'verify_email']:
22
+ Console().print(
23
+ f"[yellow]Terms and account verification need to be accepted. Please use a browser to login: {client.base_url}/login[/yellow]"
24
+ )
25
+ sys.exit(1)
26
+
27
+ if token:
28
+ Config().save_token(token)
29
+ Console().print("[green]✓ Successfully logged in![/green]")
30
+ else:
31
+ Console(stderr=True).print(
32
+ "[red]✗ Failed to authenticate. Please check your credentials and/or environment variables.[/red]"
33
+ )
34
+ sys.exit(1)
@@ -0,0 +1,76 @@
1
+ # cli/commands/organization.py
2
+ import json
3
+ import logging
4
+ from typing import Optional
5
+
6
+ import click
7
+ from rich.console import Console
8
+ from rich.panel import Panel
9
+ from rich.table import Table
10
+
11
+ console = Console()
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ @click.group(name="org")
16
+ def org_group():
17
+ """Manage organizations"""
18
+ pass
19
+
20
+
21
+ @org_group.command()
22
+ @click.argument("id", required=False)
23
+ @click.option("--json-output", is_flag=True, help="Output in JSON format")
24
+ def get(id: Optional[str] = None, json_output: bool = False):
25
+ """Get organization details or list all organizations"""
26
+ # WIP
27
+ from atomict.cli.core.client import get_client
28
+
29
+ client = get_client()
30
+
31
+ if id:
32
+ result = client.get(f"/api/organisation/{id}/")
33
+ if json_output:
34
+ click.echo(json.dumps(result, indent=2))
35
+ return
36
+
37
+ console.print(Panel(f"[bold]Organization Details[/bold]"))
38
+ console.print(f"ID: {result['id']}")
39
+ console.print(f"Name: {result.get('name', 'N/A')}")
40
+
41
+ # Show users if present
42
+ if "users" in result:
43
+ console.print("\n[bold]Users[/bold]")
44
+ user_table = Table(show_header=True)
45
+ user_table.add_column("ID")
46
+ user_table.add_column("Username")
47
+ user_table.add_column("Role")
48
+
49
+ for user in result["users"]:
50
+ user_table.add_row(
51
+ str(user["id"]),
52
+ user.get("username", "N/A"),
53
+ user.get("role", "N/A"),
54
+ )
55
+ console.print(user_table)
56
+ else:
57
+ results = client.get_all("/api/organisation/")
58
+ if json_output:
59
+ click.echo(json.dumps(results, indent=2))
60
+ return
61
+
62
+ table = Table(show_header=True)
63
+ table.add_column("ID")
64
+ table.add_column("Name")
65
+ table.add_column("Users")
66
+
67
+ for org in results:
68
+ table.add_row(
69
+ str(org["id"]), org.get("name", "N/A"), str(len(org.get("users", [])))
70
+ )
71
+ console.print(table)
72
+
73
+
74
+ # Add other org commands...
75
+
76
+ org = org_group