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.
- 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.2.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.2.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.2.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.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,876 @@
|
|
|
1
|
+
# cli/commands/project.py
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from rich.panel import Panel
|
|
7
|
+
from rich.tree import Tree
|
|
8
|
+
|
|
9
|
+
from atomict.cli.commands.common import create_table
|
|
10
|
+
from atomict.cli.commands.helpers import format_datetime, get_status_string
|
|
11
|
+
from atomict.cli.core.client import get_client
|
|
12
|
+
from atomict.cli.core.utils import get_pagination_info
|
|
13
|
+
|
|
14
|
+
console = Console()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.group(name="project")
|
|
18
|
+
def project():
|
|
19
|
+
"""Manage projects and their related resources"""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@project.command()
|
|
24
|
+
@click.argument("id", required=False)
|
|
25
|
+
@click.option("--search", help="Search term")
|
|
26
|
+
@click.option("--ordering", help="Field to order results by")
|
|
27
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
28
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
29
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
30
|
+
def get(
|
|
31
|
+
id: Optional[str] = None,
|
|
32
|
+
search: Optional[str] = None,
|
|
33
|
+
ordering: Optional[str] = None,
|
|
34
|
+
filters: tuple = (),
|
|
35
|
+
json_output: bool = False,
|
|
36
|
+
fetch_all: bool = False,
|
|
37
|
+
):
|
|
38
|
+
"""Get project details or list all projects"""
|
|
39
|
+
client = get_client()
|
|
40
|
+
console = Console()
|
|
41
|
+
|
|
42
|
+
if id:
|
|
43
|
+
result = client.get(f"/api/project/{id}/")
|
|
44
|
+
if json_output:
|
|
45
|
+
console.print_json(data=result)
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
# Single project detailed view
|
|
49
|
+
console.print(Panel(f"[bold]Project Details[/bold]"))
|
|
50
|
+
console.print(f"ID: {result['id']}")
|
|
51
|
+
console.print(f"Name: {result.get('name', 'N/A')}")
|
|
52
|
+
console.print(f"Smiles: {result.get('thumbnail_smiles', 'N/A')}")
|
|
53
|
+
console.print(f"Created: {format_datetime(result.get('created_at', 'N/A'))}")
|
|
54
|
+
console.print(f"Updated: {format_datetime(result.get('updated_at', 'N/A'))}")
|
|
55
|
+
if result.get("description_html"):
|
|
56
|
+
console.print("\n[bold]Description[/bold]")
|
|
57
|
+
console.print(result["description_html"])
|
|
58
|
+
console.print()
|
|
59
|
+
|
|
60
|
+
# Related simulations table
|
|
61
|
+
if result.get("simulations"):
|
|
62
|
+
console.print("[bold]Related Simulations[/bold]")
|
|
63
|
+
sim_columns = [
|
|
64
|
+
("ID", "id", None),
|
|
65
|
+
("Name", "name", None),
|
|
66
|
+
("Status", "status", get_status_string),
|
|
67
|
+
]
|
|
68
|
+
sim_table = create_table(
|
|
69
|
+
columns=sim_columns, items=result["simulations"], title="Simulations"
|
|
70
|
+
)
|
|
71
|
+
console.print(sim_table)
|
|
72
|
+
console.print()
|
|
73
|
+
|
|
74
|
+
# Project notes table
|
|
75
|
+
if result.get("notes"):
|
|
76
|
+
console.print("[bold]Project Notes[/bold]")
|
|
77
|
+
notes_columns = [
|
|
78
|
+
("ID", "id", None),
|
|
79
|
+
("Title", "title", None),
|
|
80
|
+
("Created", "created_at", format_datetime),
|
|
81
|
+
]
|
|
82
|
+
notes_table = create_table(
|
|
83
|
+
columns=notes_columns, items=result["notes"], title="Notes"
|
|
84
|
+
)
|
|
85
|
+
console.print(notes_table)
|
|
86
|
+
|
|
87
|
+
# Show tags as a tree
|
|
88
|
+
if result.get("tags"):
|
|
89
|
+
tag_tree = Tree("[bold]Project Tags[/bold]")
|
|
90
|
+
for tag in result["tags"]:
|
|
91
|
+
tag_tree.add(
|
|
92
|
+
f"[{tag.get('color', 'white')}]{tag.get('tag', 'N/A')}[/{tag.get('color', 'white')}]"
|
|
93
|
+
)
|
|
94
|
+
console.print(tag_tree)
|
|
95
|
+
|
|
96
|
+
else:
|
|
97
|
+
params = {}
|
|
98
|
+
if search:
|
|
99
|
+
params["search"] = search
|
|
100
|
+
if ordering:
|
|
101
|
+
params["ordering"] = ordering
|
|
102
|
+
|
|
103
|
+
# Add filter parameters
|
|
104
|
+
for f in filters:
|
|
105
|
+
try:
|
|
106
|
+
field, value = f.split("=", 1)
|
|
107
|
+
params[field] = value
|
|
108
|
+
except ValueError:
|
|
109
|
+
click.echo(
|
|
110
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
111
|
+
)
|
|
112
|
+
return
|
|
113
|
+
|
|
114
|
+
if fetch_all:
|
|
115
|
+
results = client.get_all("/api/project/", params=params)
|
|
116
|
+
else:
|
|
117
|
+
results = client.get("/api/project/", params=params)
|
|
118
|
+
|
|
119
|
+
if json_output:
|
|
120
|
+
console.print_json(data=results)
|
|
121
|
+
return
|
|
122
|
+
|
|
123
|
+
columns = [
|
|
124
|
+
("ID", "id", None),
|
|
125
|
+
("Name", "name", None),
|
|
126
|
+
("Smiles", "thumbnail_smiles", None),
|
|
127
|
+
("Created", "created_at", format_datetime),
|
|
128
|
+
("Updated", "updated_at", format_datetime),
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
items, footer_string = get_pagination_info(results)
|
|
132
|
+
|
|
133
|
+
if not items:
|
|
134
|
+
console.print(
|
|
135
|
+
f"[white]No projects found with the given criteria:[/white]\n[green]{params}"
|
|
136
|
+
)
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
table = create_table(
|
|
140
|
+
columns=columns, items=items, title="Projects", caption=footer_string
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
console.print(table)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@project.command()
|
|
147
|
+
@click.option("--name", required=True, help="Project name")
|
|
148
|
+
@click.option("--description", help="Project description")
|
|
149
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
150
|
+
def create(name: str, description: Optional[str] = None, json_output: bool = False):
|
|
151
|
+
"""Create a new project"""
|
|
152
|
+
client = get_client()
|
|
153
|
+
console = Console()
|
|
154
|
+
|
|
155
|
+
data = {
|
|
156
|
+
"name": name,
|
|
157
|
+
}
|
|
158
|
+
if description:
|
|
159
|
+
data["description"] = description
|
|
160
|
+
|
|
161
|
+
result = client.post("/api/project/", data=data)
|
|
162
|
+
|
|
163
|
+
if json_output:
|
|
164
|
+
console.print_json(data=result)
|
|
165
|
+
else:
|
|
166
|
+
console.print(f"Created project with ID: {result['id']}")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@project.command()
|
|
170
|
+
@click.argument("id")
|
|
171
|
+
def delete(id: str):
|
|
172
|
+
"""Delete a project"""
|
|
173
|
+
client = get_client()
|
|
174
|
+
client.delete(f"/api/project/{id}/")
|
|
175
|
+
console = Console()
|
|
176
|
+
console.print(f"[green]Deleted project {id}[/green]")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@project.command()
|
|
180
|
+
@click.argument("id", required=False)
|
|
181
|
+
@click.option("--search", help="Search term")
|
|
182
|
+
@click.option("--ordering", help="Field to order results by")
|
|
183
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
184
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
185
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
186
|
+
def get_note(
|
|
187
|
+
id: Optional[str] = None,
|
|
188
|
+
search: Optional[str] = None,
|
|
189
|
+
ordering: Optional[str] = None,
|
|
190
|
+
filters: tuple = (),
|
|
191
|
+
json_output: bool = False,
|
|
192
|
+
fetch_all: bool = False,
|
|
193
|
+
):
|
|
194
|
+
"""Get project note details or list all notes"""
|
|
195
|
+
client = get_client()
|
|
196
|
+
console = Console()
|
|
197
|
+
|
|
198
|
+
if id:
|
|
199
|
+
result = client.get(f"/api/project-note/{id}/")
|
|
200
|
+
if json_output:
|
|
201
|
+
console.print_json(data=result)
|
|
202
|
+
return
|
|
203
|
+
|
|
204
|
+
console.print(Panel(f"[bold]Project Note Details[/bold]"))
|
|
205
|
+
console.print(f"ID: {result['id']}")
|
|
206
|
+
console.print(f"Title: {result.get('title', 'N/A')}")
|
|
207
|
+
console.print(f"Project: {result.get('project', 'N/A')}")
|
|
208
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
209
|
+
console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
|
|
210
|
+
if result.get("content"):
|
|
211
|
+
console.print("\n[bold]Content[/bold]")
|
|
212
|
+
console.print(result["content"])
|
|
213
|
+
else:
|
|
214
|
+
params = {}
|
|
215
|
+
if search is not None:
|
|
216
|
+
params["search"] = search
|
|
217
|
+
if ordering:
|
|
218
|
+
params["ordering"] = ordering
|
|
219
|
+
|
|
220
|
+
for f in filters:
|
|
221
|
+
try:
|
|
222
|
+
field, value = f.split("=", 1)
|
|
223
|
+
params[field] = value
|
|
224
|
+
except ValueError:
|
|
225
|
+
click.echo(
|
|
226
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
227
|
+
)
|
|
228
|
+
return
|
|
229
|
+
|
|
230
|
+
if fetch_all:
|
|
231
|
+
results = client.get_all("/api/project-note/", params=params)
|
|
232
|
+
else:
|
|
233
|
+
results = client.get("/api/project-note/", params=params)
|
|
234
|
+
|
|
235
|
+
if json_output:
|
|
236
|
+
console.print_json(data=results)
|
|
237
|
+
return
|
|
238
|
+
|
|
239
|
+
columns = [
|
|
240
|
+
("ID", "id", None),
|
|
241
|
+
("Title", "title", None),
|
|
242
|
+
("Project", "project", None),
|
|
243
|
+
("Created", "created_at", format_datetime),
|
|
244
|
+
("Updated", "updated_at", format_datetime),
|
|
245
|
+
]
|
|
246
|
+
|
|
247
|
+
items, footer_string = get_pagination_info(results)
|
|
248
|
+
|
|
249
|
+
if not items:
|
|
250
|
+
console.print(
|
|
251
|
+
f"[white]No notes found with the given criteria:[/white]\n[green]{params}"
|
|
252
|
+
)
|
|
253
|
+
return
|
|
254
|
+
|
|
255
|
+
table = create_table(
|
|
256
|
+
columns=columns, items=items, title="Project Notes", caption=footer_string
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
console.print(table)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
@project.command()
|
|
263
|
+
@click.option("--project", required=True, help="Project ID")
|
|
264
|
+
@click.option("--title", required=True, help="Note title")
|
|
265
|
+
@click.option("--content", help="Note content")
|
|
266
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
267
|
+
def create_note(
|
|
268
|
+
project: str, title: str, content: Optional[str] = None, json_output: bool = False
|
|
269
|
+
):
|
|
270
|
+
"""Create a new project note"""
|
|
271
|
+
client = get_client()
|
|
272
|
+
console = Console()
|
|
273
|
+
|
|
274
|
+
data = {
|
|
275
|
+
"project": project,
|
|
276
|
+
"title": title,
|
|
277
|
+
}
|
|
278
|
+
if content:
|
|
279
|
+
data["content"] = content
|
|
280
|
+
|
|
281
|
+
result = client.post("/api/project-note/", data=data)
|
|
282
|
+
|
|
283
|
+
if json_output:
|
|
284
|
+
console.print_json(data=result)
|
|
285
|
+
else:
|
|
286
|
+
console.print(f"[green]Created note with ID: {result['id']}[/green]")
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@project.command()
|
|
290
|
+
@click.argument("id")
|
|
291
|
+
def delete_note(id: str):
|
|
292
|
+
"""Delete a project note"""
|
|
293
|
+
client = get_client()
|
|
294
|
+
client.delete(f"/api/project-note/{id}/")
|
|
295
|
+
console = Console()
|
|
296
|
+
console.print(f"[green]Deleted note {id}[/green]")
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@project.command()
|
|
300
|
+
@click.argument("id", required=False)
|
|
301
|
+
@click.option("--search", help="Search term")
|
|
302
|
+
@click.option("--ordering", help="Field to order results by")
|
|
303
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
304
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
305
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
306
|
+
def get_star(
|
|
307
|
+
id: Optional[str] = None,
|
|
308
|
+
search: Optional[str] = None,
|
|
309
|
+
ordering: Optional[str] = None,
|
|
310
|
+
filters: tuple = (),
|
|
311
|
+
json_output: bool = False,
|
|
312
|
+
fetch_all: bool = False,
|
|
313
|
+
):
|
|
314
|
+
"""Get project star details or list all starred projects"""
|
|
315
|
+
client = get_client()
|
|
316
|
+
console = Console()
|
|
317
|
+
|
|
318
|
+
if id:
|
|
319
|
+
result = client.get(f"/api/project-star/{id}/")
|
|
320
|
+
if json_output:
|
|
321
|
+
console.print_json(data=result)
|
|
322
|
+
return
|
|
323
|
+
|
|
324
|
+
console.print(Panel(f"[bold]Project Star Details[/bold]"))
|
|
325
|
+
console.print(f"ID: {result['id']}")
|
|
326
|
+
console.print(
|
|
327
|
+
f"Project: {result['project'].get('name', 'N/A')} ({result['project']['id']})"
|
|
328
|
+
)
|
|
329
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
330
|
+
else:
|
|
331
|
+
params = {}
|
|
332
|
+
if search is not None:
|
|
333
|
+
params["search"] = search
|
|
334
|
+
if ordering:
|
|
335
|
+
params["ordering"] = ordering
|
|
336
|
+
|
|
337
|
+
for f in filters:
|
|
338
|
+
try:
|
|
339
|
+
field, value = f.split("=", 1)
|
|
340
|
+
params[field] = value
|
|
341
|
+
except ValueError:
|
|
342
|
+
click.echo(
|
|
343
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
344
|
+
)
|
|
345
|
+
return
|
|
346
|
+
|
|
347
|
+
if fetch_all:
|
|
348
|
+
results = client.get_all("/api/project-star/", params=params)
|
|
349
|
+
else:
|
|
350
|
+
results = client.get("/api/project-star/", params=params)
|
|
351
|
+
|
|
352
|
+
if json_output:
|
|
353
|
+
console.print_json(data=results)
|
|
354
|
+
return
|
|
355
|
+
|
|
356
|
+
columns = [
|
|
357
|
+
("ID", "id", None),
|
|
358
|
+
# TODO: when serializers have a depth configured, use project.name
|
|
359
|
+
("Project", "project", None),
|
|
360
|
+
("Created", "created_at", format_datetime),
|
|
361
|
+
]
|
|
362
|
+
|
|
363
|
+
items, footer_string = get_pagination_info(results)
|
|
364
|
+
|
|
365
|
+
if not items:
|
|
366
|
+
console.print(
|
|
367
|
+
f"[white]No starred projects found with the given criteria:[/white]\n[green]{params}"
|
|
368
|
+
)
|
|
369
|
+
return
|
|
370
|
+
|
|
371
|
+
table = create_table(
|
|
372
|
+
columns=columns,
|
|
373
|
+
items=items,
|
|
374
|
+
title="Starred Projects",
|
|
375
|
+
caption=footer_string,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
console.print(table)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
@project.command()
|
|
382
|
+
@click.option("--project", required=True, help="Project ID to star")
|
|
383
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
384
|
+
def create_star(project: str, json_output: bool = False):
|
|
385
|
+
"""Star a project"""
|
|
386
|
+
client = get_client()
|
|
387
|
+
console = Console()
|
|
388
|
+
data = {
|
|
389
|
+
"project": project,
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
result = client.post("/api/project-star/", data=data)
|
|
393
|
+
|
|
394
|
+
if json_output:
|
|
395
|
+
console.print_json(data=result)
|
|
396
|
+
else:
|
|
397
|
+
console.print(f"[green]Starred project {project}[/green]")
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
@project.command()
|
|
401
|
+
@click.argument("id")
|
|
402
|
+
def delete_star(id: str):
|
|
403
|
+
"""Unstar a project"""
|
|
404
|
+
client = get_client()
|
|
405
|
+
client.delete(f"/api/project-star/{id}/")
|
|
406
|
+
console = Console()
|
|
407
|
+
console.print(f"[green]Unstarred project {id}[/green]")
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
@project.command()
|
|
411
|
+
@click.argument("id", required=False)
|
|
412
|
+
@click.option("--search", help="Search term")
|
|
413
|
+
@click.option("--ordering", help="Field to order results by")
|
|
414
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
415
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
416
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
417
|
+
def get_tag(
|
|
418
|
+
id: Optional[str] = None,
|
|
419
|
+
search: Optional[str] = None,
|
|
420
|
+
ordering: Optional[str] = None,
|
|
421
|
+
filters: tuple = (),
|
|
422
|
+
json_output: bool = False,
|
|
423
|
+
fetch_all: bool = False,
|
|
424
|
+
):
|
|
425
|
+
"""Get project tag details or list all tags"""
|
|
426
|
+
client = get_client()
|
|
427
|
+
console = Console()
|
|
428
|
+
|
|
429
|
+
if id:
|
|
430
|
+
result = client.get(f"/api/project-tag/{id}/")
|
|
431
|
+
if json_output:
|
|
432
|
+
console.print_json(data=result)
|
|
433
|
+
return
|
|
434
|
+
|
|
435
|
+
console.print(Panel(f"[bold]Project Tag Details[/bold]"))
|
|
436
|
+
console.print(f"ID: {result['id']}")
|
|
437
|
+
console.print(
|
|
438
|
+
f"Tag: [{result.get('color', 'white')}]{result.get('tag', 'N/A')}[/{result.get('color', 'white')}]"
|
|
439
|
+
)
|
|
440
|
+
console.print(f"Color: {result.get('color', 'N/A')}")
|
|
441
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
442
|
+
else:
|
|
443
|
+
params = {}
|
|
444
|
+
if search is not None:
|
|
445
|
+
params["search"] = search
|
|
446
|
+
if ordering:
|
|
447
|
+
params["ordering"] = ordering
|
|
448
|
+
|
|
449
|
+
for f in filters:
|
|
450
|
+
try:
|
|
451
|
+
field, value = f.split("=", 1)
|
|
452
|
+
params[field] = value
|
|
453
|
+
except ValueError:
|
|
454
|
+
click.echo(
|
|
455
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
456
|
+
)
|
|
457
|
+
return
|
|
458
|
+
|
|
459
|
+
if fetch_all:
|
|
460
|
+
results = client.get_all("/api/project-tag/", params=params)
|
|
461
|
+
else:
|
|
462
|
+
results = client.get("/api/project-tag/", params=params)
|
|
463
|
+
|
|
464
|
+
if json_output:
|
|
465
|
+
console.print_json(data=results)
|
|
466
|
+
return
|
|
467
|
+
|
|
468
|
+
columns = [
|
|
469
|
+
("ID", "id", None),
|
|
470
|
+
("Tag", "tag", None),
|
|
471
|
+
("Color", "color", None),
|
|
472
|
+
("Created", "created_at", format_datetime),
|
|
473
|
+
]
|
|
474
|
+
|
|
475
|
+
items, footer_string = get_pagination_info(results)
|
|
476
|
+
|
|
477
|
+
if not items:
|
|
478
|
+
console.print(
|
|
479
|
+
f"[white]No tags found with the given criteria:[/white]\n[green]{params}"
|
|
480
|
+
)
|
|
481
|
+
return
|
|
482
|
+
|
|
483
|
+
table = create_table(
|
|
484
|
+
columns=columns, items=items, title="Project Tags", caption=footer_string
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
console.print(table)
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
@project.command()
|
|
491
|
+
@click.option("--tag", required=True, help="Tag name")
|
|
492
|
+
@click.option("--color", default="white", help="Tag color")
|
|
493
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
494
|
+
def create_tag(tag: str, color: str = "white", json_output: bool = False):
|
|
495
|
+
"""Create a new project tag"""
|
|
496
|
+
client = get_client()
|
|
497
|
+
console = Console()
|
|
498
|
+
|
|
499
|
+
data = {
|
|
500
|
+
"tag": tag,
|
|
501
|
+
"color": color,
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
result = client.post("/api/project-tag/", data=data)
|
|
505
|
+
|
|
506
|
+
if json_output:
|
|
507
|
+
console.print_json(data=result)
|
|
508
|
+
else:
|
|
509
|
+
console.print(
|
|
510
|
+
f"[green]Created tag [{color}]{tag}[/{color}] with ID: {result['id']}[/green]"
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
@project.command()
|
|
515
|
+
@click.argument("id")
|
|
516
|
+
def delete_tag(id: str):
|
|
517
|
+
"""Delete a project tag"""
|
|
518
|
+
client = get_client()
|
|
519
|
+
client.delete(f"/api/project-tag/{id}/")
|
|
520
|
+
console = Console()
|
|
521
|
+
console.print(f"[green]Deleted tag {id}[/green]")
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
@project.command()
|
|
525
|
+
@click.argument("id", required=False)
|
|
526
|
+
@click.option("--search", help="Search term")
|
|
527
|
+
@click.option("--ordering", help="Field to order results by")
|
|
528
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
529
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
530
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
531
|
+
def get_tag_project(
|
|
532
|
+
id: Optional[str] = None,
|
|
533
|
+
search: Optional[str] = None,
|
|
534
|
+
ordering: Optional[str] = None,
|
|
535
|
+
filters: tuple = (),
|
|
536
|
+
json_output: bool = False,
|
|
537
|
+
fetch_all: bool = False,
|
|
538
|
+
):
|
|
539
|
+
"""Get project tag assignment details or list all assignments"""
|
|
540
|
+
client = get_client()
|
|
541
|
+
console = Console()
|
|
542
|
+
|
|
543
|
+
if id:
|
|
544
|
+
result = client.get(f"/api/project-tag-project/{id}/")
|
|
545
|
+
if json_output:
|
|
546
|
+
console.print_json(data=result)
|
|
547
|
+
return
|
|
548
|
+
|
|
549
|
+
console.print(Panel(f"[bold]Project Tag Assignment Details[/bold]"))
|
|
550
|
+
console.print(f"ID: {result['id']}")
|
|
551
|
+
console.print(
|
|
552
|
+
f"Project: {result['project'].get('name', 'N/A')} ({result['project']['id']})"
|
|
553
|
+
)
|
|
554
|
+
console.print(
|
|
555
|
+
f"Tag: [{result['tag'].get('color', 'white')}]{result['tag'].get('tag', 'N/A')}[/{result['tag'].get('color', 'white')}]"
|
|
556
|
+
)
|
|
557
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
558
|
+
else:
|
|
559
|
+
params = {}
|
|
560
|
+
if search is not None:
|
|
561
|
+
params["search"] = search
|
|
562
|
+
if ordering:
|
|
563
|
+
params["ordering"] = ordering
|
|
564
|
+
|
|
565
|
+
for f in filters:
|
|
566
|
+
try:
|
|
567
|
+
field, value = f.split("=", 1)
|
|
568
|
+
params[field] = value
|
|
569
|
+
except ValueError:
|
|
570
|
+
click.echo(
|
|
571
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
572
|
+
)
|
|
573
|
+
return
|
|
574
|
+
|
|
575
|
+
if fetch_all:
|
|
576
|
+
results = client.get_all("/api/project-tag-project/", params=params)
|
|
577
|
+
else:
|
|
578
|
+
results = client.get("/api/project-tag-project/", params=params)
|
|
579
|
+
|
|
580
|
+
if json_output:
|
|
581
|
+
console.print_json(data=results)
|
|
582
|
+
return
|
|
583
|
+
|
|
584
|
+
columns = [
|
|
585
|
+
("ID", "id", None),
|
|
586
|
+
(
|
|
587
|
+
"Project",
|
|
588
|
+
"project",
|
|
589
|
+
lambda x: x.get("name") if isinstance(x, dict) else None,
|
|
590
|
+
),
|
|
591
|
+
("Tag", "tag", lambda x: x.get("tag") if isinstance(x, dict) else None),
|
|
592
|
+
("Created", "created_at", format_datetime),
|
|
593
|
+
]
|
|
594
|
+
|
|
595
|
+
items, footer_string = get_pagination_info(results)
|
|
596
|
+
|
|
597
|
+
if not items:
|
|
598
|
+
console.print(
|
|
599
|
+
f"[white]No tag assignments found with the given criteria:[/white]\n[green]{params}"
|
|
600
|
+
)
|
|
601
|
+
return
|
|
602
|
+
|
|
603
|
+
table = create_table(
|
|
604
|
+
columns=columns,
|
|
605
|
+
items=items,
|
|
606
|
+
title="Project Tag Assignments",
|
|
607
|
+
caption=footer_string,
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
console.print(table)
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
@project.command()
|
|
614
|
+
@click.option("--project", required=True, help="Project ID")
|
|
615
|
+
@click.option("--tag", required=True, help="Tag ID")
|
|
616
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
617
|
+
def create_tag_project(project: str, tag: str, json_output: bool = False):
|
|
618
|
+
"""Assign a tag to a project"""
|
|
619
|
+
client = get_client()
|
|
620
|
+
console = Console()
|
|
621
|
+
|
|
622
|
+
data = {
|
|
623
|
+
"project": project,
|
|
624
|
+
"project_tag": tag,
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
result = client.post("/api/project-tag-project/", data=data)
|
|
628
|
+
|
|
629
|
+
if json_output:
|
|
630
|
+
console.print_json(data=result)
|
|
631
|
+
else:
|
|
632
|
+
console.print(f"[green]Assigned tag {tag} to project {project}[/green]")
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
@project.command()
|
|
636
|
+
@click.argument("id")
|
|
637
|
+
def delete_tag_project(id: str):
|
|
638
|
+
"""Remove a tag assignment from a project"""
|
|
639
|
+
client = get_client()
|
|
640
|
+
client.delete(f"/api/project-tag-project/{id}/")
|
|
641
|
+
console = Console()
|
|
642
|
+
console.print(f"[green]Removed tag assignment {id}[/green]")
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
# These methods seem to be web frontend specifc
|
|
646
|
+
|
|
647
|
+
# @project.command()
|
|
648
|
+
# @click.argument('id', required=False)
|
|
649
|
+
# @click.option('--search', help='Search term')
|
|
650
|
+
# @click.option('--ordering', help='Field to order results by')
|
|
651
|
+
# @click.option('--filter', 'filters', multiple=True, help='Filter in format field=value')
|
|
652
|
+
# @click.option('--json-output', is_flag=True, help='Output in JSON format')
|
|
653
|
+
# @click.option('--all', 'fetch_all', is_flag=True, help='Fetch all results')
|
|
654
|
+
# def get_workbench_layout(id: Optional[str] = None, search: Optional[str] = None,
|
|
655
|
+
# ordering: Optional[str] = None, filters: tuple = (),
|
|
656
|
+
# json_output: bool = False, fetch_all: bool = False):
|
|
657
|
+
# """Get project workbench layout details or list all layouts"""
|
|
658
|
+
# client = get_client()
|
|
659
|
+
# console = Console()
|
|
660
|
+
|
|
661
|
+
# if id:
|
|
662
|
+
# result = client.get(f'/api/project-workbench-layout/{id}/')
|
|
663
|
+
# if json_output:
|
|
664
|
+
# console.print_json(data=result)
|
|
665
|
+
# return
|
|
666
|
+
|
|
667
|
+
# console.print(Panel(f"[bold]Project Workbench Layout Details[/bold]"))
|
|
668
|
+
# console.print(f"ID: {result['id']}")
|
|
669
|
+
# console.print(f"Project: {result['project'].get('name', 'N/A')} ({result['project']['id']})")
|
|
670
|
+
# console.print(f"Name: {result.get('name', 'N/A')}")
|
|
671
|
+
# console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
672
|
+
# console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
|
|
673
|
+
# if result.get('layout'):
|
|
674
|
+
# console.print("\n[bold]Layout Data[/bold]")
|
|
675
|
+
# console.print_json(data=result['layout'])
|
|
676
|
+
# else:
|
|
677
|
+
# params = {}
|
|
678
|
+
# if search is not None:
|
|
679
|
+
# params['search'] = search
|
|
680
|
+
# if ordering:
|
|
681
|
+
# params['ordering'] = ordering
|
|
682
|
+
|
|
683
|
+
# for f in filters:
|
|
684
|
+
# try:
|
|
685
|
+
# field, value = f.split('=', 1)
|
|
686
|
+
# params[field] = value
|
|
687
|
+
# except ValueError:
|
|
688
|
+
# console.print(f"[red]Invalid filter format: {f}. Use field=value[/red]")
|
|
689
|
+
# return
|
|
690
|
+
|
|
691
|
+
# if fetch_all:
|
|
692
|
+
# results = client.get_all('/api/project-workbench-layout/', params=params)
|
|
693
|
+
# else:
|
|
694
|
+
# results = client.get('/api/project-workbench-layout/', params=params)
|
|
695
|
+
|
|
696
|
+
# if json_output:
|
|
697
|
+
# console.print_json(data=results)
|
|
698
|
+
# return
|
|
699
|
+
|
|
700
|
+
# columns = [
|
|
701
|
+
# ("ID", "id", None),
|
|
702
|
+
# ("Project", "project", lambda x: x.get('name') if isinstance(x, dict) else None),
|
|
703
|
+
# ("Name", "name", None),
|
|
704
|
+
# ("Created", "created_at", format_datetime),
|
|
705
|
+
# ("Updated", "updated_at", format_datetime),
|
|
706
|
+
# ]
|
|
707
|
+
|
|
708
|
+
# items, footer_string = get_pagination_info(results)
|
|
709
|
+
|
|
710
|
+
# if not items:
|
|
711
|
+
# console.print(f"[white]No layouts found with the given criteria:[/white]\n[green]{params}")
|
|
712
|
+
# return
|
|
713
|
+
|
|
714
|
+
# table = create_table(
|
|
715
|
+
# columns=columns,
|
|
716
|
+
# items=items,
|
|
717
|
+
# title="Project Workbench Layouts",
|
|
718
|
+
# caption=footer_string
|
|
719
|
+
# )
|
|
720
|
+
|
|
721
|
+
# console.print(table)
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
# @project.command()
|
|
725
|
+
# @click.option('--project', required=True, help='Project ID')
|
|
726
|
+
# @click.option('--name', required=True, help='Layout name')
|
|
727
|
+
# @click.option('--layout', required=True, help='Layout data (JSON string)')
|
|
728
|
+
# @click.option('--json-output', is_flag=True, help='Output in JSON format')
|
|
729
|
+
# def create_workbench_layout(project: str, name: str, layout: str, json_output: bool = False):
|
|
730
|
+
# """Create a new project workbench layout"""
|
|
731
|
+
# client = get_client()
|
|
732
|
+
# console = Console()
|
|
733
|
+
|
|
734
|
+
# try:
|
|
735
|
+
# layout_data = json.loads(layout)
|
|
736
|
+
# except json.JSONDecodeError:
|
|
737
|
+
# console.print("[red]Invalid JSON format for layout data[/red]")
|
|
738
|
+
# return
|
|
739
|
+
|
|
740
|
+
# data = {
|
|
741
|
+
# 'project': project,
|
|
742
|
+
# 'name': name,
|
|
743
|
+
# 'layout': layout_data
|
|
744
|
+
# }
|
|
745
|
+
|
|
746
|
+
# result = client.post('/api/project-workbench-layout/', data=data)
|
|
747
|
+
|
|
748
|
+
# if json_output:
|
|
749
|
+
# console.print_json(data=result)
|
|
750
|
+
# else:
|
|
751
|
+
# console.print(f"[green]Created workbench layout '{name}' for project {project}[/green]")
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
# @project.command()
|
|
755
|
+
# @click.argument('id')
|
|
756
|
+
# def delete_workbench_layout(id: str):
|
|
757
|
+
# """Delete a project workbench layout"""
|
|
758
|
+
# client = get_client()
|
|
759
|
+
# client.delete(f'/api/project-workbench-layout/{id}/')
|
|
760
|
+
# console = Console()
|
|
761
|
+
# console.print(f"[green]Deleted workbench layout {id}[/green]")
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
@project.command()
|
|
765
|
+
@click.argument("id", required=False)
|
|
766
|
+
@click.option("--search", help="Search term")
|
|
767
|
+
@click.option("--ordering", help="Field to order results by")
|
|
768
|
+
@click.option("--filter", "filters", multiple=True, help="Filter in format field=value")
|
|
769
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
770
|
+
@click.option("--all", "fetch_all", is_flag=True, help="Fetch all results")
|
|
771
|
+
def get_molecule(
|
|
772
|
+
id: Optional[str] = None,
|
|
773
|
+
search: Optional[str] = None,
|
|
774
|
+
ordering: Optional[str] = None,
|
|
775
|
+
filters: tuple = (),
|
|
776
|
+
json_output: bool = False,
|
|
777
|
+
fetch_all: bool = False,
|
|
778
|
+
):
|
|
779
|
+
"""Get project molecule details or list all molecules"""
|
|
780
|
+
client = get_client()
|
|
781
|
+
console = Console()
|
|
782
|
+
|
|
783
|
+
if id:
|
|
784
|
+
result = client.get(f"/api/project-molecule/{id}/")
|
|
785
|
+
if json_output:
|
|
786
|
+
console.print_json(data=result)
|
|
787
|
+
return
|
|
788
|
+
|
|
789
|
+
console.print(Panel(f"[bold]Project Molecule Details[/bold]"))
|
|
790
|
+
console.print(f"ID: {result['id']}")
|
|
791
|
+
console.print(f"Heading: {result.get('heading', 'N/A')}")
|
|
792
|
+
console.print(f"Project: {result['project']}")
|
|
793
|
+
console.print(f"Created: {format_datetime(result.get('created_at'))}")
|
|
794
|
+
else:
|
|
795
|
+
params = {}
|
|
796
|
+
if search is not None:
|
|
797
|
+
params["search"] = search
|
|
798
|
+
if ordering:
|
|
799
|
+
params["ordering"] = ordering
|
|
800
|
+
|
|
801
|
+
for f in filters:
|
|
802
|
+
try:
|
|
803
|
+
field, value = f.split("=", 1)
|
|
804
|
+
params[field] = value
|
|
805
|
+
except ValueError:
|
|
806
|
+
click.echo(
|
|
807
|
+
f"[red]Invalid filter format: {f}. Use field=value[/red]", err=True
|
|
808
|
+
)
|
|
809
|
+
return
|
|
810
|
+
|
|
811
|
+
if fetch_all:
|
|
812
|
+
results = client.get_all("/api/project-molecule/", params=params)
|
|
813
|
+
else:
|
|
814
|
+
results = client.get("/api/project-molecule/", params=params)
|
|
815
|
+
|
|
816
|
+
if json_output:
|
|
817
|
+
console.print_json(data=results)
|
|
818
|
+
return
|
|
819
|
+
|
|
820
|
+
columns = [
|
|
821
|
+
("ID", "id", None),
|
|
822
|
+
("Heading", "heading", None),
|
|
823
|
+
(
|
|
824
|
+
"Project",
|
|
825
|
+
"project",
|
|
826
|
+
lambda x: x.get("name") if isinstance(x, dict) else None,
|
|
827
|
+
),
|
|
828
|
+
("Created", "created_at", format_datetime),
|
|
829
|
+
]
|
|
830
|
+
|
|
831
|
+
items, footer_string = get_pagination_info(results)
|
|
832
|
+
|
|
833
|
+
if not items:
|
|
834
|
+
console.print(
|
|
835
|
+
f"[white]No molecules found with the given criteria:[/white]\n[green]{params}"
|
|
836
|
+
)
|
|
837
|
+
return
|
|
838
|
+
|
|
839
|
+
table = create_table(
|
|
840
|
+
columns=columns,
|
|
841
|
+
items=items,
|
|
842
|
+
title="Project Molecules",
|
|
843
|
+
caption=footer_string,
|
|
844
|
+
)
|
|
845
|
+
|
|
846
|
+
console.print(table)
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
@project.command()
|
|
850
|
+
@click.option("--project", required=True, help="Project ID")
|
|
851
|
+
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
852
|
+
def create_molecule(project: str, json_output: bool = False):
|
|
853
|
+
"""Add a molecule to a project"""
|
|
854
|
+
client = get_client()
|
|
855
|
+
console = Console()
|
|
856
|
+
|
|
857
|
+
data = {
|
|
858
|
+
"project": project,
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
result = client.post("/api/project-molecule/", data=data)
|
|
862
|
+
|
|
863
|
+
if json_output:
|
|
864
|
+
console.print_json(data=result)
|
|
865
|
+
else:
|
|
866
|
+
console.print(f"[green]Added project-molecule {project}[/green]")
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
@project.command()
|
|
870
|
+
@click.argument("id")
|
|
871
|
+
def delete_molecule(id: str):
|
|
872
|
+
"""Remove a molecule from a project"""
|
|
873
|
+
client = get_client()
|
|
874
|
+
client.delete(f"/api/project-molecule/{id}/")
|
|
875
|
+
console = Console()
|
|
876
|
+
console.print(f"[green]Removed molecule {id} from project[/green]")
|