atomict 1.2.6__py3-none-any.whl → 1.2.8__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/__version__.py +1 -1
- atomict/api.py +3 -3
- atomict/ase/atatoms.py +715 -0
- atomict/cli/commands/adsorbate.py +5 -5
- atomict/cli/commands/k8s.py +3 -3
- atomict/cli/commands/project.py +19 -19
- atomict/cli/commands/task.py +5 -5
- atomict/cli/commands/upload.py +2 -2
- atomict/cli/ext/custom_classes.py +34 -0
- atomict/cli/main.py +133 -35
- atomict/infra/logging.py +206 -1
- atomict/io/msgpack.py +499 -0
- atomict/io/trajectory.py +437 -0
- atomict/simulation/mlrelax.py +1 -5
- atomict/simulation/models.py +4 -0
- atomict/simulation/phonon.py +84 -5
- atomict/simulation/utils.py +11 -3
- {atomict-1.2.6.dist-info → atomict-1.2.8.dist-info}/METADATA +8 -1
- {atomict-1.2.6.dist-info → atomict-1.2.8.dist-info}/RECORD +23 -19
- atomict/io/json.py +0 -28
- {atomict-1.2.6.dist-info → atomict-1.2.8.dist-info}/WHEEL +0 -0
- {atomict-1.2.6.dist-info → atomict-1.2.8.dist-info}/entry_points.txt +0 -0
- {atomict-1.2.6.dist-info → atomict-1.2.8.dist-info}/licenses/LICENSE +0 -0
- {atomict-1.2.6.dist-info → atomict-1.2.8.dist-info}/top_level.txt +0 -0
|
@@ -13,12 +13,12 @@ console = Console()
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
@click.group(name="adsorbate")
|
|
16
|
-
def
|
|
16
|
+
def adsorbate_group():
|
|
17
17
|
"""Manage adsorbates"""
|
|
18
18
|
pass
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
@
|
|
21
|
+
@adsorbate_group.command()
|
|
22
22
|
@click.argument("id", required=False)
|
|
23
23
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
24
24
|
@click.option("--search", help="Search term")
|
|
@@ -96,7 +96,7 @@ def get(
|
|
|
96
96
|
console.print(table)
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
@
|
|
99
|
+
@adsorbate_group.command()
|
|
100
100
|
@click.option("--ase-atoms", required=True, help="ASE atoms string representation")
|
|
101
101
|
@click.option("--smiles", help="SMILES string representation of the molecule")
|
|
102
102
|
@click.option(
|
|
@@ -133,7 +133,7 @@ def create(
|
|
|
133
133
|
console.print(f"[green]Created adsorbate {result['id']}[/green]")
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
@
|
|
136
|
+
@adsorbate_group.command()
|
|
137
137
|
@click.argument("id")
|
|
138
138
|
@click.option("--ase-atoms", help="ASE atoms string representation")
|
|
139
139
|
@click.option("--smiles", help="SMILES string representation of the molecule")
|
|
@@ -173,7 +173,7 @@ def update(
|
|
|
173
173
|
console.print(f"[green]Updated adsorbate {result['id']}[/green]")
|
|
174
174
|
|
|
175
175
|
|
|
176
|
-
@
|
|
176
|
+
@adsorbate_group.command()
|
|
177
177
|
@click.argument("id")
|
|
178
178
|
def delete(id: str):
|
|
179
179
|
"""Delete an adsorbate"""
|
atomict/cli/commands/k8s.py
CHANGED
|
@@ -14,12 +14,12 @@ console = Console()
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
@click.group(name="k8s")
|
|
17
|
-
def
|
|
17
|
+
def k8s_group():
|
|
18
18
|
"""Manage Kubernetes jobs and clusters"""
|
|
19
19
|
pass
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
@
|
|
22
|
+
@k8s_group.command()
|
|
23
23
|
@click.argument("id", required=False)
|
|
24
24
|
@click.option("--search", help="Search term")
|
|
25
25
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -109,7 +109,7 @@ def get(
|
|
|
109
109
|
console.print(table)
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
@
|
|
112
|
+
@k8s_group.command()
|
|
113
113
|
@click.argument("id", required=False)
|
|
114
114
|
@click.option("--search", help="Search term")
|
|
115
115
|
@click.option("--ordering", help="Field to order results by")
|
atomict/cli/commands/project.py
CHANGED
|
@@ -15,12 +15,12 @@ console = Console()
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@click.group(name="project")
|
|
18
|
-
def
|
|
18
|
+
def project_group():
|
|
19
19
|
"""Manage projects and their related resources"""
|
|
20
20
|
pass
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@
|
|
23
|
+
@project_group.command()
|
|
24
24
|
@click.argument("id", required=False)
|
|
25
25
|
@click.option("--search", help="Search term")
|
|
26
26
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -143,7 +143,7 @@ def get(
|
|
|
143
143
|
console.print(table)
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
@
|
|
146
|
+
@project_group.command()
|
|
147
147
|
@click.option("--name", required=True, help="Project name")
|
|
148
148
|
@click.option("--description", help="Project description")
|
|
149
149
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
@@ -166,7 +166,7 @@ def create(name: str, description: Optional[str] = None, json_output: bool = Fal
|
|
|
166
166
|
console.print(f"Created project with ID: {result['id']}")
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
@
|
|
169
|
+
@project_group.command()
|
|
170
170
|
@click.argument("id")
|
|
171
171
|
def delete(id: str):
|
|
172
172
|
"""Delete a project"""
|
|
@@ -176,7 +176,7 @@ def delete(id: str):
|
|
|
176
176
|
console.print(f"[green]Deleted project {id}[/green]")
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
@
|
|
179
|
+
@project_group.command()
|
|
180
180
|
@click.argument("id", required=False)
|
|
181
181
|
@click.option("--search", help="Search term")
|
|
182
182
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -259,7 +259,7 @@ def get_note(
|
|
|
259
259
|
console.print(table)
|
|
260
260
|
|
|
261
261
|
|
|
262
|
-
@
|
|
262
|
+
@project_group.command()
|
|
263
263
|
@click.option("--project", required=True, help="Project ID")
|
|
264
264
|
@click.option("--title", required=True, help="Note title")
|
|
265
265
|
@click.option("--content", help="Note content")
|
|
@@ -286,7 +286,7 @@ def create_note(
|
|
|
286
286
|
console.print(f"[green]Created note with ID: {result['id']}[/green]")
|
|
287
287
|
|
|
288
288
|
|
|
289
|
-
@
|
|
289
|
+
@project_group.command()
|
|
290
290
|
@click.argument("id")
|
|
291
291
|
def delete_note(id: str):
|
|
292
292
|
"""Delete a project note"""
|
|
@@ -296,7 +296,7 @@ def delete_note(id: str):
|
|
|
296
296
|
console.print(f"[green]Deleted note {id}[/green]")
|
|
297
297
|
|
|
298
298
|
|
|
299
|
-
@
|
|
299
|
+
@project_group.command()
|
|
300
300
|
@click.argument("id", required=False)
|
|
301
301
|
@click.option("--search", help="Search term")
|
|
302
302
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -378,7 +378,7 @@ def get_star(
|
|
|
378
378
|
console.print(table)
|
|
379
379
|
|
|
380
380
|
|
|
381
|
-
@
|
|
381
|
+
@project_group.command()
|
|
382
382
|
@click.option("--project", required=True, help="Project ID to star")
|
|
383
383
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
384
384
|
def create_star(project: str, json_output: bool = False):
|
|
@@ -397,7 +397,7 @@ def create_star(project: str, json_output: bool = False):
|
|
|
397
397
|
console.print(f"[green]Starred project {project}[/green]")
|
|
398
398
|
|
|
399
399
|
|
|
400
|
-
@
|
|
400
|
+
@project_group.command()
|
|
401
401
|
@click.argument("id")
|
|
402
402
|
def delete_star(id: str):
|
|
403
403
|
"""Unstar a project"""
|
|
@@ -407,7 +407,7 @@ def delete_star(id: str):
|
|
|
407
407
|
console.print(f"[green]Unstarred project {id}[/green]")
|
|
408
408
|
|
|
409
409
|
|
|
410
|
-
@
|
|
410
|
+
@project_group.command()
|
|
411
411
|
@click.argument("id", required=False)
|
|
412
412
|
@click.option("--search", help="Search term")
|
|
413
413
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -487,7 +487,7 @@ def get_tag(
|
|
|
487
487
|
console.print(table)
|
|
488
488
|
|
|
489
489
|
|
|
490
|
-
@
|
|
490
|
+
@project_group.command()
|
|
491
491
|
@click.option("--tag", required=True, help="Tag name")
|
|
492
492
|
@click.option("--color", default="white", help="Tag color")
|
|
493
493
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
@@ -511,7 +511,7 @@ def create_tag(tag: str, color: str = "white", json_output: bool = False):
|
|
|
511
511
|
)
|
|
512
512
|
|
|
513
513
|
|
|
514
|
-
@
|
|
514
|
+
@project_group.command()
|
|
515
515
|
@click.argument("id")
|
|
516
516
|
def delete_tag(id: str):
|
|
517
517
|
"""Delete a project tag"""
|
|
@@ -521,7 +521,7 @@ def delete_tag(id: str):
|
|
|
521
521
|
console.print(f"[green]Deleted tag {id}[/green]")
|
|
522
522
|
|
|
523
523
|
|
|
524
|
-
@
|
|
524
|
+
@project_group.command()
|
|
525
525
|
@click.argument("id", required=False)
|
|
526
526
|
@click.option("--search", help="Search term")
|
|
527
527
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -610,7 +610,7 @@ def get_tag_project(
|
|
|
610
610
|
console.print(table)
|
|
611
611
|
|
|
612
612
|
|
|
613
|
-
@
|
|
613
|
+
@project_group.command()
|
|
614
614
|
@click.option("--project", required=True, help="Project ID")
|
|
615
615
|
@click.option("--tag", required=True, help="Tag ID")
|
|
616
616
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
@@ -632,7 +632,7 @@ def create_tag_project(project: str, tag: str, json_output: bool = False):
|
|
|
632
632
|
console.print(f"[green]Assigned tag {tag} to project {project}[/green]")
|
|
633
633
|
|
|
634
634
|
|
|
635
|
-
@
|
|
635
|
+
@project_group.command()
|
|
636
636
|
@click.argument("id")
|
|
637
637
|
def delete_tag_project(id: str):
|
|
638
638
|
"""Remove a tag assignment from a project"""
|
|
@@ -761,7 +761,7 @@ def delete_tag_project(id: str):
|
|
|
761
761
|
# console.print(f"[green]Deleted workbench layout {id}[/green]")
|
|
762
762
|
|
|
763
763
|
|
|
764
|
-
@
|
|
764
|
+
@project_group.command()
|
|
765
765
|
@click.argument("id", required=False)
|
|
766
766
|
@click.option("--search", help="Search term")
|
|
767
767
|
@click.option("--ordering", help="Field to order results by")
|
|
@@ -846,7 +846,7 @@ def get_molecule(
|
|
|
846
846
|
console.print(table)
|
|
847
847
|
|
|
848
848
|
|
|
849
|
-
@
|
|
849
|
+
@project_group.command()
|
|
850
850
|
@click.option("--project", required=True, help="Project ID")
|
|
851
851
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
852
852
|
def create_molecule(project: str, json_output: bool = False):
|
|
@@ -866,7 +866,7 @@ def create_molecule(project: str, json_output: bool = False):
|
|
|
866
866
|
console.print(f"[green]Added project-molecule {project}[/green]")
|
|
867
867
|
|
|
868
868
|
|
|
869
|
-
@
|
|
869
|
+
@project_group.command()
|
|
870
870
|
@click.argument("id")
|
|
871
871
|
def delete_molecule(id: str):
|
|
872
872
|
"""Remove a molecule from a project"""
|
atomict/cli/commands/task.py
CHANGED
|
@@ -24,12 +24,12 @@ STATUS_MAP = {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
@click.group(name="task")
|
|
27
|
-
def
|
|
27
|
+
def task_group():
|
|
28
28
|
"""Manage tasks and their status"""
|
|
29
29
|
pass
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@
|
|
32
|
+
@task_group.command()
|
|
33
33
|
@click.argument("id")
|
|
34
34
|
def cancel(id: str):
|
|
35
35
|
"""Cancel a running task"""
|
|
@@ -41,7 +41,7 @@ def cancel(id: str):
|
|
|
41
41
|
console.print(f"[green]Task {id} has been cancelled[/green]")
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
@
|
|
44
|
+
@task_group.command()
|
|
45
45
|
@click.argument("id", required=False)
|
|
46
46
|
@click.option("--search", help="Search tasks by ID, type, status, or error message")
|
|
47
47
|
@click.option(
|
|
@@ -133,7 +133,7 @@ def get(
|
|
|
133
133
|
console.print(table)
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
@
|
|
136
|
+
@task_group.command()
|
|
137
137
|
@click.argument("task_id")
|
|
138
138
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
139
139
|
def get_status_history(task_id: str, json_output: bool = False):
|
|
@@ -166,7 +166,7 @@ def get_status_history(task_id: str, json_output: bool = False):
|
|
|
166
166
|
console.print(table)
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
@
|
|
169
|
+
@task_group.command(hidden=True)
|
|
170
170
|
@click.argument("id")
|
|
171
171
|
@click.argument(
|
|
172
172
|
"status",
|
atomict/cli/commands/upload.py
CHANGED
|
@@ -13,7 +13,7 @@ console = Console()
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
@click.group(name="upload")
|
|
16
|
-
def
|
|
16
|
+
def upload_group():
|
|
17
17
|
"""Manage file uploads"""
|
|
18
18
|
pass
|
|
19
19
|
|
|
@@ -49,7 +49,7 @@ def upload():
|
|
|
49
49
|
# console.print(f"Upload ID: {result['id']}")
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
@
|
|
52
|
+
@upload_group.command()
|
|
53
53
|
@click.option("--limit", type=int, help="Number of results to return")
|
|
54
54
|
@click.option("--type", "file_type", help="Filter by file type")
|
|
55
55
|
@click.option("--json-output", is_flag=True, help="Output in JSON format")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class DefaultCommandGroup(click.Group):
|
|
5
|
+
"""Allow a default command for a group.
|
|
6
|
+
|
|
7
|
+
This class extends Click's Group to support a default command that gets executed
|
|
8
|
+
when no subcommand is specified or when arguments don't match any known command.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def command(self, *args, **kwargs):
|
|
12
|
+
default_command = kwargs.pop('default_command', False)
|
|
13
|
+
if default_command and not args:
|
|
14
|
+
kwargs['name'] = kwargs.get('name', ' ')
|
|
15
|
+
decorator = super(DefaultCommandGroup, self).command(*args, **kwargs)
|
|
16
|
+
|
|
17
|
+
if default_command:
|
|
18
|
+
def new_decorator(f):
|
|
19
|
+
cmd = decorator(f)
|
|
20
|
+
self.default_command = cmd.name
|
|
21
|
+
return cmd
|
|
22
|
+
|
|
23
|
+
return new_decorator
|
|
24
|
+
|
|
25
|
+
return decorator
|
|
26
|
+
|
|
27
|
+
def resolve_command(self, ctx, args):
|
|
28
|
+
try:
|
|
29
|
+
# test if the command parses
|
|
30
|
+
return super(DefaultCommandGroup, self).resolve_command(ctx, args)
|
|
31
|
+
except click.UsageError:
|
|
32
|
+
# command did not parse, assume it is the default command
|
|
33
|
+
args.insert(0, self.default_command)
|
|
34
|
+
return super(DefaultCommandGroup, self).resolve_command(ctx, args)
|
atomict/cli/main.py
CHANGED
|
@@ -8,11 +8,15 @@ from rich.console import Console
|
|
|
8
8
|
|
|
9
9
|
from atomict.__version__ import __version__
|
|
10
10
|
from atomict.cli.commands import login, user
|
|
11
|
+
from atomict.cli.ext.custom_classes import DefaultCommandGroup
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from .commands import adsorbate, catalysis, k8s, project, task, traj, upload
|
|
15
|
+
from .commands.exploration import soec, sqs
|
|
16
|
+
from .commands.simulation import fhiaims, kpoint, vibes
|
|
17
|
+
except ImportError:
|
|
18
|
+
sys.exit(1)
|
|
11
19
|
|
|
12
|
-
# Import command groups
|
|
13
|
-
from .commands import adsorbate, catalysis, k8s, project, task, traj, upload
|
|
14
|
-
from .commands.exploration import soec, sqs
|
|
15
|
-
from .commands.simulation import fhiaims, kpoint, vibes
|
|
16
20
|
|
|
17
21
|
console = Console()
|
|
18
22
|
|
|
@@ -20,39 +24,148 @@ console = Console()
|
|
|
20
24
|
def setup_logging(verbose: bool):
|
|
21
25
|
"""Configure logging based on verbose flag and AT_DEBUG env var"""
|
|
22
26
|
if os.getenv("AT_DEBUG") == "enabled":
|
|
23
|
-
# Most verbose logging when AT_DEBUG is set
|
|
24
27
|
logging.basicConfig(
|
|
25
28
|
level=logging.DEBUG,
|
|
26
29
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
27
30
|
handlers=[logging.StreamHandler(), logging.FileHandler("atomict.log")],
|
|
28
31
|
)
|
|
29
|
-
# Also enable HTTP library debugging
|
|
30
32
|
logging.getLogger("httpx").setLevel(logging.DEBUG)
|
|
31
33
|
logging.getLogger("httpcore").setLevel(logging.DEBUG)
|
|
32
|
-
|
|
33
|
-
# Log some debug info
|
|
34
34
|
logging.debug("Debug mode enabled via AT_DEBUG")
|
|
35
35
|
logging.debug(f'Python path: {os.getenv("PYTHONPATH")}')
|
|
36
36
|
logging.debug(f"Working directory: {os.getcwd()}")
|
|
37
37
|
else:
|
|
38
|
-
# Normal logging based on verbose flag
|
|
39
38
|
level = logging.DEBUG if verbose else logging.ERROR
|
|
40
39
|
logging.basicConfig(
|
|
41
40
|
level=level, format="%(asctime)s - %(levelname)s - %(message)s"
|
|
42
41
|
)
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
@click.group()
|
|
44
|
+
@click.group(cls=DefaultCommandGroup, invoke_without_command=True)
|
|
46
45
|
@click.option(
|
|
47
46
|
"-v", "--verbose", is_flag=True, default=False, help="Enable verbose output"
|
|
48
47
|
)
|
|
49
48
|
@click.version_option(prog_name="tess", version=__version__)
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
@click.pass_context
|
|
50
|
+
def cli(ctx, verbose: bool):
|
|
51
|
+
"""Atomic Tessellator CLI - Manage simulations and computational resources
|
|
52
|
+
|
|
53
|
+
Default behavior: when called with two file arguments, converts between file formats.
|
|
54
|
+
"""
|
|
52
55
|
setup_logging(verbose)
|
|
53
56
|
|
|
57
|
+
if ctx.invoked_subcommand is None and len(sys.argv) <= 1:
|
|
58
|
+
click.echo(ctx.get_help())
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@cli.command(default_command=True)
|
|
62
|
+
@click.argument("input_file", required=True)
|
|
63
|
+
@click.argument("output_file", required=True)
|
|
64
|
+
@click.option("--strict-map-keys", is_flag=True, default=False, help="Enable strict map keys in msgpack files (sets strict_map_key=True)")
|
|
65
|
+
def convert(input_file, output_file, strict_map_keys):
|
|
66
|
+
"""Convert between atomic structure file formats using ASE
|
|
67
|
+
|
|
68
|
+
Supports all formats that ASE can read/write, with special handling for .atm and .atraj files.
|
|
69
|
+
Usage examples:
|
|
70
|
+
tess input.cif output.xyz
|
|
71
|
+
tess input.xyz output.atm
|
|
72
|
+
tess input.traj output.atraj
|
|
73
|
+
|
|
74
|
+
Options:
|
|
75
|
+
--strict-map-keys Enable strict map keys in msgpack files (default: False)
|
|
76
|
+
"""
|
|
77
|
+
try:
|
|
78
|
+
import os.path
|
|
79
|
+
from ase.io import read, write
|
|
80
|
+
from ase.io.formats import UnknownFileTypeError
|
|
81
|
+
from atomict.io.msgpack import save_msgpack, save_msgpack_trajectory, load_msgpack, load_msgpack_trajectory
|
|
82
|
+
except ImportError:
|
|
83
|
+
console.print("[red]Error: ASE (Atomic Simulation Environment) is required for file conversion.[/red]")
|
|
84
|
+
console.print("[yellow]Install it with: pip install ase[/yellow]")
|
|
85
|
+
return
|
|
86
|
+
|
|
87
|
+
RW_FORMATS = [
|
|
88
|
+
'abinit-in', 'aims', 'bundletrajectory', 'castep-cell', 'castep-geom',
|
|
89
|
+
'castep-md', 'cfg', 'cif', 'crystal', 'cube', 'db', 'dftb', 'dlp4',
|
|
90
|
+
'dmol-arc', 'dmol-car', 'dmol-incoor', 'eon', 'espresso-in', 'extxyz',
|
|
91
|
+
'gaussian-in', 'gen', 'gpumd', 'gromacs', 'gromos', 'json', 'jsv',
|
|
92
|
+
'lammps-data', 'magres', 'mustem', 'mysql', 'netcdftrajectory', 'nwchem-in',
|
|
93
|
+
'onetep-in', 'postgresql', 'prismatic', 'proteindatabank', 'res',
|
|
94
|
+
'rmc6f', 'struct', 'sys', 'traj', 'turbomole', 'v-sim', 'vasp',
|
|
95
|
+
'vasp-xdatcar', 'xsd', 'xsf', 'xtd', 'xyz'
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
input_ext = os.path.splitext(input_file)[1].lower()[1:]
|
|
100
|
+
output_ext = os.path.splitext(output_file)[1].lower()[1:]
|
|
101
|
+
|
|
102
|
+
if not os.path.exists(input_file):
|
|
103
|
+
console.print(f"[red]Error: Input file '{input_file}' not found.[/red]")
|
|
104
|
+
return
|
|
105
|
+
|
|
106
|
+
msgpack_formats = ["atm"]
|
|
107
|
+
traj_msgpack_formats = ["atraj"]
|
|
108
|
+
|
|
109
|
+
if input_ext not in RW_FORMATS and input_ext not in msgpack_formats and input_ext not in traj_msgpack_formats:
|
|
110
|
+
console.print(f"[red]Error: Format '{input_ext}' is not supported for reading.[/red]")
|
|
111
|
+
console.print("[yellow]Supported read/write formats include:[/yellow]")
|
|
112
|
+
for i in range(0, len(RW_FORMATS), 5):
|
|
113
|
+
console.print("[yellow] " + ", ".join(RW_FORMATS[i:i+5]) + "[/yellow]")
|
|
114
|
+
console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory)[/yellow]")
|
|
115
|
+
return
|
|
116
|
+
|
|
117
|
+
if output_ext not in RW_FORMATS and output_ext not in msgpack_formats and output_ext not in traj_msgpack_formats:
|
|
118
|
+
console.print(f"[red]Error: Format '{output_ext}' is not supported for writing.[/red]")
|
|
119
|
+
console.print("[yellow]Supported read/write formats include:[/yellow]")
|
|
120
|
+
for i in range(0, len(RW_FORMATS), 5):
|
|
121
|
+
console.print("[yellow] " + ", ".join(RW_FORMATS[i:i+5]) + "[/yellow]")
|
|
122
|
+
console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory)[/yellow]")
|
|
123
|
+
return
|
|
124
|
+
|
|
125
|
+
try:
|
|
126
|
+
if input_ext in msgpack_formats:
|
|
127
|
+
atoms = load_msgpack(input_file, strict_map_key=strict_map_keys)
|
|
128
|
+
elif input_ext in traj_msgpack_formats:
|
|
129
|
+
atoms, _ = load_msgpack_trajectory(input_file, strict_map_key=strict_map_keys)
|
|
130
|
+
else:
|
|
131
|
+
atoms = read(input_file)
|
|
132
|
+
except UnknownFileTypeError:
|
|
133
|
+
console.print(f"[red]Error: Unknown file type for input file '{input_file}'[/red]")
|
|
134
|
+
console.print(f"[yellow]The file extension '{input_ext}' is not recognized.[/yellow]")
|
|
135
|
+
console.print("[yellow]Make sure the file has the correct extension for its format.[/yellow]")
|
|
136
|
+
return
|
|
137
|
+
except Exception as e:
|
|
138
|
+
console.print(f"[red]Error reading input file '{input_file}': {str(e)}.[/red]")
|
|
139
|
+
console.print(f"[yellow]Make sure '{input_ext}' is a valid format and the file is not corrupted.[/yellow]")
|
|
140
|
+
return
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
if output_ext in msgpack_formats:
|
|
144
|
+
save_msgpack(atoms, output_file)
|
|
145
|
+
console.print(f"[green]Successfully converted {input_file} to {output_file} (MSGPACK format)[/green]")
|
|
146
|
+
elif output_ext in traj_msgpack_formats:
|
|
147
|
+
save_msgpack_trajectory(atoms, output_file)
|
|
148
|
+
console.print(f"[green]Successfully converted {input_file} to {output_file} (MSGPACK trajectory format)[/green]")
|
|
149
|
+
else:
|
|
150
|
+
write(output_file, atoms)
|
|
151
|
+
console.print(f"[green]Successfully converted {input_file} to {output_file}[/green]")
|
|
152
|
+
|
|
153
|
+
except UnknownFileTypeError:
|
|
154
|
+
console.print(f"[red]Error: Unknown file type for output file '{output_file}'[/red]")
|
|
155
|
+
console.print(f"[yellow]The file extension '{output_ext}' is not recognized.[/yellow]")
|
|
156
|
+
console.print("[yellow]Make sure the file has the correct extension for its format.[/yellow]")
|
|
157
|
+
return
|
|
158
|
+
except Exception as e:
|
|
159
|
+
console.print(f"[red]Error writing output file '{output_file}': {str(e)}[/red]")
|
|
160
|
+
console.print(f"[yellow]Make sure '{output_ext}' is a valid format and you have write permissions.[/yellow]")
|
|
161
|
+
return
|
|
162
|
+
|
|
163
|
+
except Exception as e:
|
|
164
|
+
logging.debug(f"Conversion failed with error: {str(e)}", exc_info=True)
|
|
165
|
+
console.print(f"[red]Error during conversion: {str(e)}[/red]")
|
|
166
|
+
console.print("[yellow]Try running with --verbose for more detailed error information.[/yellow]")
|
|
167
|
+
|
|
54
168
|
|
|
55
|
-
# Add a completion command
|
|
56
169
|
@cli.command(hidden=True)
|
|
57
170
|
@click.argument("shell", type=click.Choice(["bash", "zsh", "fish"]), required=False)
|
|
58
171
|
def completion(shell):
|
|
@@ -61,7 +174,7 @@ def completion(shell):
|
|
|
61
174
|
shell = os.environ.get("SHELL", "")
|
|
62
175
|
shell = shell.split("/")[-1]
|
|
63
176
|
if shell not in ["bash", "zsh", "fish"]:
|
|
64
|
-
shell = "bash"
|
|
177
|
+
shell = "bash"
|
|
65
178
|
|
|
66
179
|
completion_script = None
|
|
67
180
|
if shell == "bash":
|
|
@@ -93,35 +206,20 @@ end
|
|
|
93
206
|
|
|
94
207
|
|
|
95
208
|
cli.add_command(completion)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
cli.add_command(
|
|
99
|
-
cli.add_command(
|
|
100
|
-
cli.add_command(
|
|
101
|
-
cli.add_command(k8s.k8s)
|
|
102
|
-
cli.add_command(adsorbate.adsorbate)
|
|
103
|
-
|
|
104
|
-
# raise commands to top-level
|
|
209
|
+
cli.add_command(task.task_group)
|
|
210
|
+
cli.add_command(upload.upload_group)
|
|
211
|
+
cli.add_command(project.project_group)
|
|
212
|
+
cli.add_command(k8s.k8s_group)
|
|
213
|
+
cli.add_command(adsorbate.adsorbate_group)
|
|
105
214
|
cli.add_command(fhiaims.fhiaims_group)
|
|
106
215
|
cli.add_command(kpoint.kpoint_group)
|
|
107
|
-
cli.add_command(catalysis.catalysis_group)
|
|
216
|
+
cli.add_command(catalysis.catalysis_group)
|
|
108
217
|
cli.add_command(sqs.sqs_group)
|
|
109
218
|
cli.add_command(soec.soecexploration_group)
|
|
110
219
|
cli.add_command(traj.traj)
|
|
111
220
|
cli.add_command(user.user_group)
|
|
112
221
|
cli.add_command(login._login)
|
|
113
222
|
cli.add_command(vibes.vibes_group)
|
|
114
|
-
# from .commands.exploration import exploration_group
|
|
115
|
-
# cli.add_command(exploration.exploration) # move this
|
|
116
|
-
# TBD: decide on how to group or put all commands at top level
|
|
117
|
-
# standardize this later
|
|
118
|
-
# cli.add_command(exploration_group)
|
|
119
|
-
|
|
120
|
-
# we could do `at [exploration/simulation/project/user/etc] [get/create/delete] [id]`
|
|
121
|
-
# OR
|
|
122
|
-
# `at [get/create/delete] [exploration/simulation/project/user/etc] [id]`
|
|
123
|
-
# OR
|
|
124
|
-
# some other grouping that reflects a user's workflow
|
|
125
223
|
|
|
126
224
|
|
|
127
225
|
def main():
|