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,83 @@
|
|
|
1
|
+
from atomict.api import get, post
|
|
2
|
+
|
|
3
|
+
COMPUTATION_TYPE_RELAXATION = 0
|
|
4
|
+
COMPUTATION_TYPE_SINGLE_POINT = 1
|
|
5
|
+
|
|
6
|
+
MODEL_ORB_D3_V2 = 0
|
|
7
|
+
MODEL_MATTERSIM_1_0_0_5M = 1
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_mlrelax(id: str):
|
|
11
|
+
"""
|
|
12
|
+
Get MLRelaxation
|
|
13
|
+
"""
|
|
14
|
+
result = get(f"api/mlrelax/{id}/")
|
|
15
|
+
return result
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def associate_user_upload_with_mlrelaxation(user_upload_id: str, mlrelax_id: str):
|
|
19
|
+
"""
|
|
20
|
+
Associate a user upload with a MLRelaxation
|
|
21
|
+
"""
|
|
22
|
+
result = post(
|
|
23
|
+
"api/mlrelax-file/",
|
|
24
|
+
payload={"user_upload_id": user_upload_id, "mlrelax_id": mlrelax_id},
|
|
25
|
+
)
|
|
26
|
+
return result
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def create_mlrelaxation(
|
|
30
|
+
project_id: str,
|
|
31
|
+
source_geometry_id: str,
|
|
32
|
+
action: str,
|
|
33
|
+
name: str = None,
|
|
34
|
+
description: str = None,
|
|
35
|
+
computation_type: int = COMPUTATION_TYPE_RELAXATION,
|
|
36
|
+
f_max: float = None,
|
|
37
|
+
model: int = MODEL_ORB_D3_V2,
|
|
38
|
+
extra_simulation_kwargs: dict = None,
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Create a MLRelaxation
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
if action not in ["DRAFT", "LAUNCH"]:
|
|
45
|
+
raise ValueError("Action must be 'DRAFT' or 'LAUNCH'")
|
|
46
|
+
|
|
47
|
+
if computation_type not in [
|
|
48
|
+
COMPUTATION_TYPE_RELAXATION,
|
|
49
|
+
COMPUTATION_TYPE_SINGLE_POINT,
|
|
50
|
+
]:
|
|
51
|
+
raise ValueError(
|
|
52
|
+
"Invalid computation type. Please use COMPUTATION_TYPE_RELAXATION (0) or COMPUTATION_TYPE_SINGLE_POINT (1)."
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
if model not in [MODEL_ORB_D3_V2, MODEL_MATTERSIM_1_0_0_5M]:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
"Invalid model. Please use MODEL_ORB_D3_V2 (0) or MODEL_MATTERSIM_1_0_0_5M (1)."
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
payload = {
|
|
61
|
+
"project": project_id,
|
|
62
|
+
"source_geometry_id": source_geometry_id,
|
|
63
|
+
"action": action,
|
|
64
|
+
"name": name,
|
|
65
|
+
"description": description,
|
|
66
|
+
"computation_type": computation_type,
|
|
67
|
+
"f_max": f_max,
|
|
68
|
+
"model": model,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if extra_simulation_kwargs:
|
|
72
|
+
payload.update(extra_simulation_kwargs)
|
|
73
|
+
|
|
74
|
+
result = post("api/mlrelax/", payload)
|
|
75
|
+
return result
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def get_mlrelax_files(mlrelax_id: str):
|
|
79
|
+
"""
|
|
80
|
+
Get the files associated with a MLRelaxation
|
|
81
|
+
"""
|
|
82
|
+
result = get(f"api/mlrelax-file/?mlrelax__id={mlrelax_id}")
|
|
83
|
+
return result
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from atomict.api import post
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def associate_user_upload_with_phonon_analysis(user_upload_id: str, pa_id: str):
|
|
5
|
+
"""
|
|
6
|
+
Associate a user upload with a Phonon Analysis
|
|
7
|
+
"""
|
|
8
|
+
result = post(
|
|
9
|
+
"api/phonon-analysis-file/",
|
|
10
|
+
payload={"user_upload_id": user_upload_id, "analysis_id": pa_id},
|
|
11
|
+
)
|
|
12
|
+
return result
|
atomict/simulation/qe.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from atomict.api import delete, get, post
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def create_simulation(
|
|
5
|
+
project_id: str,
|
|
6
|
+
input_file: str,
|
|
7
|
+
action: str,
|
|
8
|
+
name: str = None,
|
|
9
|
+
description: str = None,
|
|
10
|
+
**kwargs,
|
|
11
|
+
) -> dict:
|
|
12
|
+
|
|
13
|
+
if action not in ["DRAFT", "LAUNCH"]:
|
|
14
|
+
raise ValueError("Action must be 'DRAFT' or 'LAUNCH'")
|
|
15
|
+
|
|
16
|
+
payload = {
|
|
17
|
+
"project": project_id,
|
|
18
|
+
"input_file": input_file,
|
|
19
|
+
"action": action,
|
|
20
|
+
"name": name,
|
|
21
|
+
"description": description,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
payload.update(kwargs)
|
|
25
|
+
|
|
26
|
+
result = post(
|
|
27
|
+
"api/qe-simulation/",
|
|
28
|
+
payload,
|
|
29
|
+
extra_headers={"Content-Type": "application/json"},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return result
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_simulation_by_name(name: str) -> dict:
|
|
36
|
+
result = get(f"api/qe-simulation/?name={name}")
|
|
37
|
+
return result["results"][0]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_simulation(simulation_id: str):
|
|
41
|
+
"""
|
|
42
|
+
Get a Quantum Espresso simulation
|
|
43
|
+
"""
|
|
44
|
+
result = get(f"api/qe-simulation/{simulation_id}/")
|
|
45
|
+
return result
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def delete_simulation(simulation_id):
|
|
49
|
+
"""
|
|
50
|
+
Delete a Quantum Espresso simulation
|
|
51
|
+
"""
|
|
52
|
+
result = delete(f"api/qe-simulation/{simulation_id}/")
|
|
53
|
+
return result
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def associate_user_upload_with_qe_simulation(
|
|
57
|
+
user_upload_id: str, qe_simulation_id: str
|
|
58
|
+
):
|
|
59
|
+
"""
|
|
60
|
+
Associate a user upload with a Quantum Espresso simulation
|
|
61
|
+
"""
|
|
62
|
+
result = post(
|
|
63
|
+
"api/qe-simulation-file/",
|
|
64
|
+
payload={"user_upload_id": user_upload_id, "simulation_id": qe_simulation_id},
|
|
65
|
+
)
|
|
66
|
+
return result
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_simulation_files(simulation_id: str):
|
|
70
|
+
"""
|
|
71
|
+
Get the files associated with a Quantum Espresso simulation
|
|
72
|
+
"""
|
|
73
|
+
result = get(f"api/qe-simulation-file/?simulation_uuid={simulation_id}")
|
|
74
|
+
return result
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from atomict.api import get, post
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_simulation(simulation_id: str, full: bool = False):
|
|
5
|
+
"""
|
|
6
|
+
Get a SQS simulation
|
|
7
|
+
"""
|
|
8
|
+
if full:
|
|
9
|
+
result = get(f"api/sqs-exploration/{simulation_id}/?full=true")
|
|
10
|
+
else:
|
|
11
|
+
result = get(f"api/sqs-exploration/{simulation_id}/")
|
|
12
|
+
|
|
13
|
+
return result
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def associate_user_upload_with_sqs_simulation(user_upload_id: str, exploration_id: str):
|
|
17
|
+
"""
|
|
18
|
+
Associate a user upload with a SQS simulation
|
|
19
|
+
"""
|
|
20
|
+
result = post(
|
|
21
|
+
"api/sqs-simulation-file/",
|
|
22
|
+
payload={"user_upload_id": user_upload_id, "exploration_id": exploration_id},
|
|
23
|
+
)
|
|
24
|
+
return result
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from ase import Atoms
|
|
2
|
+
from ase.io import read
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from atomict.io.fhiaims import read_aims_output
|
|
7
|
+
from atomict.io.utils import human_filesize
|
|
8
|
+
from atomict.simulation.mlrelax import get_mlrelax, get_mlrelax_files
|
|
9
|
+
from atomict.simulation.fhi_aims import get_simulation as fhi_get_simulation
|
|
10
|
+
from atomict.simulation.fhi_aims import get_simulation_files as fhi_get_simulation_files
|
|
11
|
+
from atomict.user.files import download_file
|
|
12
|
+
from atomict.user.workspace import download_workspace
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def fetch_relaxed_geometry(sim: dict, workbench_dir: str) -> Atoms:
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
Fetch the relaxed geometry from the simulation
|
|
19
|
+
sim can be any of these: FHIAimsSimulation, MLRelaxation, UserUpload
|
|
20
|
+
|
|
21
|
+
returns: Atoms object
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
if sim["starting_structure"]:
|
|
25
|
+
previous_simulation = fhi_get_simulation(sim["starting_structure"]["id"])
|
|
26
|
+
logging.info(f"Previous simulation: {previous_simulation['id']}")
|
|
27
|
+
files = fhi_get_simulation_files(previous_simulation["id"])
|
|
28
|
+
|
|
29
|
+
total_size = 0
|
|
30
|
+
for file in files["results"]:
|
|
31
|
+
total_size += file["user_upload"]["size"]
|
|
32
|
+
|
|
33
|
+
logging.info(
|
|
34
|
+
f"Previous simulation: Downloading {len(files['results'])} files, Total size: {human_filesize(total_size)}"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
prev_sim_dir = os.path.join(workbench_dir, "previous_simulation")
|
|
38
|
+
os.makedirs(prev_sim_dir, exist_ok=True)
|
|
39
|
+
download_workspace(files["results"], prev_sim_dir)
|
|
40
|
+
atoms = read_aims_output(
|
|
41
|
+
os.path.join(prev_sim_dir, f"{previous_simulation['id']}.out")
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return atoms[-1]
|
|
45
|
+
|
|
46
|
+
elif sim["starting_structure_mlrelax"]:
|
|
47
|
+
|
|
48
|
+
previous_mlrelax = get_mlrelax(sim["starting_structure_mlrelax"]["id"])
|
|
49
|
+
logging.info(f"Previous MLRelaxation: {previous_mlrelax['id']}")
|
|
50
|
+
files = get_mlrelax_files(previous_mlrelax["id"])
|
|
51
|
+
|
|
52
|
+
total_size = 0
|
|
53
|
+
for file in files["results"]:
|
|
54
|
+
total_size += file["user_upload"]["size"]
|
|
55
|
+
|
|
56
|
+
logging.info(
|
|
57
|
+
f"Previous MLRelaxation: Downloading {len(files['results'])} files, Total size: {human_filesize(total_size)}"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
mlrelax_dir = os.path.join(workbench_dir, "previous_mlrelax")
|
|
61
|
+
os.makedirs(mlrelax_dir, exist_ok=True)
|
|
62
|
+
download_workspace(files["results"], mlrelax_dir)
|
|
63
|
+
|
|
64
|
+
traj_file = os.path.join(mlrelax_dir, "relax.traj")
|
|
65
|
+
atoms = read(traj_file)
|
|
66
|
+
|
|
67
|
+
if isinstance(atoms, list):
|
|
68
|
+
return atoms[-1]
|
|
69
|
+
else:
|
|
70
|
+
return atoms
|
|
71
|
+
|
|
72
|
+
elif sim["starting_structure_userupload"]:
|
|
73
|
+
logging.info(f"Previous UserUpload: {sim['starting_structure_userupload']['uuid']}")
|
|
74
|
+
|
|
75
|
+
download_file(sim["starting_structure_userupload"]["uuid"], workbench_dir + "/relaxed.cif")
|
|
76
|
+
atoms = read(workbench_dir + "/relaxed.cif")
|
|
77
|
+
|
|
78
|
+
if isinstance(atoms, list):
|
|
79
|
+
return atoms[-1]
|
|
80
|
+
else:
|
|
81
|
+
return atoms
|
|
82
|
+
else:
|
|
83
|
+
raise ValueError("No relaxed structure simulation found")
|
atomict/user/__init__.py
ADDED
|
File without changes
|
atomict/user/files.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from atomict.api import get, post
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def upload_single_file(full_path: str, file_name: str, project_uuid: str = None):
|
|
7
|
+
|
|
8
|
+
payload = {
|
|
9
|
+
'users_name': file_name
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if project_uuid:
|
|
13
|
+
payload['project_uuid'] = project_uuid
|
|
14
|
+
|
|
15
|
+
with open(full_path, "rb") as f:
|
|
16
|
+
result = post("user/file_upload/", files={file_name: f}, payload=payload)
|
|
17
|
+
return result
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def download_file(user_upload_uuid: str, destination_path: str):
|
|
21
|
+
content = get(f"user/file_upload_get/{user_upload_uuid}/")
|
|
22
|
+
|
|
23
|
+
# Write the content to the destination path
|
|
24
|
+
# if there's a directory path in the destination path, create the directory
|
|
25
|
+
destination_dir = os.path.dirname(destination_path)
|
|
26
|
+
if destination_dir:
|
|
27
|
+
os.makedirs(destination_dir, exist_ok=True)
|
|
28
|
+
|
|
29
|
+
with open(destination_path, "wb") as f:
|
|
30
|
+
f.write(content)
|
|
31
|
+
return content
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import shutil
|
|
4
|
+
|
|
5
|
+
from atomict.infra.distwork.task import TaskStatus, update_task_status
|
|
6
|
+
from atomict.io.utils import human_filesize
|
|
7
|
+
from atomict.user.files import download_file, upload_single_file
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def display_name(user_upload):
|
|
11
|
+
if "users_name" in user_upload and user_upload["users_name"] not in ["", None]:
|
|
12
|
+
return user_upload["users_name"]
|
|
13
|
+
return user_upload["orig_name"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def clear_workspace(sim, base_path: str = "./workspace"):
|
|
17
|
+
|
|
18
|
+
target_dir = os.path.join(base_path, sim["id"])
|
|
19
|
+
|
|
20
|
+
if os.path.exists(target_dir):
|
|
21
|
+
logging.warning(f"Removing existing workspace folder {target_dir}")
|
|
22
|
+
shutil.rmtree(target_dir)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def download_workspace(workspace_files, target_directory: str):
|
|
26
|
+
"""Download a workspace to a target directory
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
workspace_files list of UserUpload objects: List of files to download
|
|
30
|
+
target_directory (str): The directory to download the files to
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
os.makedirs(target_directory, exist_ok=True)
|
|
34
|
+
|
|
35
|
+
total_bytes = sum([f["user_upload"]["size"] for f in workspace_files])
|
|
36
|
+
finished_bytes = 0
|
|
37
|
+
for sim_file in workspace_files:
|
|
38
|
+
logging.info(
|
|
39
|
+
f"Downloading file {display_name(sim_file['user_upload'])} ({human_filesize(sim_file['user_upload']['size'])})"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
download_file(
|
|
43
|
+
sim_file["user_upload"]["uuid"],
|
|
44
|
+
f"{target_directory}/{sim_file['user_upload']['users_name']}",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
finished_bytes += sim_file["user_upload"]["size"]
|
|
48
|
+
logging.info(
|
|
49
|
+
f"Downloaded {human_filesize(finished_bytes)} of {human_filesize(total_bytes)} ({finished_bytes/total_bytes*100:.1f}%)"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def upload_workspace(
|
|
54
|
+
sim, associate_function, workspace_folder: str, starting_percent: int = 80
|
|
55
|
+
):
|
|
56
|
+
"""
|
|
57
|
+
Uploads a workspace folder to the Atomic platform, and associates the uploaded files with the given simulation.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
sim: The simulation object to associate the uploaded files with
|
|
61
|
+
associate_function: The function to associate the uploaded files with the simulation (e.g. associate_user_upload_with_qe_simulation)
|
|
62
|
+
workspace_folder: The folder to upload
|
|
63
|
+
starting_percent: The starting percentage to use when updating the task status
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
simulation_id = sim["id"]
|
|
67
|
+
|
|
68
|
+
total_size = sum(
|
|
69
|
+
os.path.getsize(os.path.join(root, file))
|
|
70
|
+
for root, _, files in os.walk(workspace_folder)
|
|
71
|
+
for file in files
|
|
72
|
+
)
|
|
73
|
+
uploaded_size = 0
|
|
74
|
+
last_update_percent = starting_percent
|
|
75
|
+
|
|
76
|
+
update_task_status(
|
|
77
|
+
sim["task"]["id"],
|
|
78
|
+
TaskStatus.RUNNING,
|
|
79
|
+
percent=last_update_percent,
|
|
80
|
+
progress_indeterminate=False,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
for root, _, files in os.walk(workspace_folder):
|
|
84
|
+
for file in files:
|
|
85
|
+
file_path = os.path.join(root, file)
|
|
86
|
+
inner_workspace = file_path.replace(workspace_folder, "")
|
|
87
|
+
file_size = os.path.getsize(file_path)
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
result = upload_single_file(file_path, inner_workspace)
|
|
91
|
+
if result["status"] != "OK":
|
|
92
|
+
logging.error(f"Failed to upload {inner_workspace}")
|
|
93
|
+
logging.error(result)
|
|
94
|
+
raise Exception(f"Failed to upload {inner_workspace} {result}")
|
|
95
|
+
else:
|
|
96
|
+
logging.info(f"Uploaded {inner_workspace} OK")
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logging.error(f"Failed to upload {inner_workspace}")
|
|
99
|
+
logging.error(e)
|
|
100
|
+
raise
|
|
101
|
+
|
|
102
|
+
associate_function(result["UserUpload"]["id"], simulation_id)
|
|
103
|
+
|
|
104
|
+
uploaded_size += file_size
|
|
105
|
+
current_percent = 80 + int((uploaded_size / total_size) * 20)
|
|
106
|
+
|
|
107
|
+
# Update status if at least 2% has changed
|
|
108
|
+
if current_percent - last_update_percent >= 2:
|
|
109
|
+
update_task_status(
|
|
110
|
+
sim["task"]["id"], TaskStatus.RUNNING, percent=current_percent
|
|
111
|
+
)
|
|
112
|
+
last_update_percent = current_percent
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from atomict.io.fhiaims import read_aims_output
|
|
2
|
+
from ase import Atoms
|
|
3
|
+
from ase.io import read
|
|
4
|
+
from ase.io.formats import UnknownFileTypeError
|
|
5
|
+
import os
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def read_final_geometry(workspace_dir: str, simulation_id: str):
|
|
10
|
+
"""Read the starting structure from the workspace directory
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
workspace_dir (str): The workspace directory
|
|
14
|
+
"""
|
|
15
|
+
next_step_path = f"{workspace_dir}/starting_structure/geometry.in.next_step"
|
|
16
|
+
if os.path.exists(next_step_path):
|
|
17
|
+
try:
|
|
18
|
+
return read(next_step_path, foramt='aims')
|
|
19
|
+
except UnknownFileTypeError:
|
|
20
|
+
logging.warning(f"Could not read {next_step_path}, falling back to output file")
|
|
21
|
+
|
|
22
|
+
return read_aims_output(
|
|
23
|
+
f"{workspace_dir}/starting_structure/{simulation_id}.out"
|
|
24
|
+
)[-1]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def fhi_to_ase(geometry_file):
|
|
28
|
+
"""
|
|
29
|
+
Convert FHI-aims geometry.in to ASE atoms object.
|
|
30
|
+
Handles both periodic and non-periodic systems.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
geometry_file (str): Path to FHI-aims geometry.in file
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
ase.Atoms: ASE atoms object with appropriate periodicity
|
|
37
|
+
"""
|
|
38
|
+
lattice_vectors = []
|
|
39
|
+
positions = []
|
|
40
|
+
symbols = []
|
|
41
|
+
|
|
42
|
+
with open(geometry_file, 'r') as f:
|
|
43
|
+
for line in f:
|
|
44
|
+
if line.startswith('lattice_vector'):
|
|
45
|
+
vec = [float(x) for x in line.split()[1:4]]
|
|
46
|
+
lattice_vectors.append(vec)
|
|
47
|
+
elif line.startswith('atom'):
|
|
48
|
+
parts = line.split()
|
|
49
|
+
pos = [float(x) for x in parts[1:4]]
|
|
50
|
+
symbol = parts[4]
|
|
51
|
+
positions.append(pos)
|
|
52
|
+
symbols.append(symbol)
|
|
53
|
+
|
|
54
|
+
# Check if the system is periodic (has lattice vectors)
|
|
55
|
+
if lattice_vectors:
|
|
56
|
+
atoms = Atoms(symbols=symbols,
|
|
57
|
+
positions=positions,
|
|
58
|
+
cell=lattice_vectors,
|
|
59
|
+
pbc=True)
|
|
60
|
+
else:
|
|
61
|
+
atoms = Atoms(symbols=symbols,
|
|
62
|
+
positions=positions,
|
|
63
|
+
pbc=False)
|
|
64
|
+
|
|
65
|
+
return atoms
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from tenacity import _utils
|
|
5
|
+
|
|
6
|
+
if typing.TYPE_CHECKING:
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
from tenacity import RetryCallState
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def before_log(
|
|
13
|
+
logger: "logging.Logger", log_level: int
|
|
14
|
+
) -> typing.Callable[["RetryCallState"], None]:
|
|
15
|
+
"""
|
|
16
|
+
Before call strategy that logs to some logger the attempt.
|
|
17
|
+
|
|
18
|
+
This one is a copy of the tenacity.before_log function, but it doesnt log the first
|
|
19
|
+
attempt because that generates a lot of noise.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def log_it(retry_state: "RetryCallState") -> None:
|
|
23
|
+
if retry_state.fn is None:
|
|
24
|
+
# NOTE(sileht): can't really happen, but we must please mypy
|
|
25
|
+
fn_name = "<unknown>"
|
|
26
|
+
else:
|
|
27
|
+
fn_name = _utils.get_callback_name(retry_state.fn)
|
|
28
|
+
|
|
29
|
+
if retry_state.attempt_number > 1:
|
|
30
|
+
logger.log(
|
|
31
|
+
log_level,
|
|
32
|
+
f"Starting call to '{fn_name}', "
|
|
33
|
+
f"this is the {_utils.to_ordinal(retry_state.attempt_number)} time calling it.",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return log_it
|
|
File without changes
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: atomict
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: The client application for the https://atomictessellator.com/
|
|
5
|
+
Author-email: Steven Anderson <steven@atomictessellator.com>, Alain Richardt <alain@atomictessellator.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/AtomicTessellator/atomic_cli
|
|
8
|
+
Keywords: atomic,tessellator,cli,client,fhi-aims,kpoint,sqs,adsorbate
|
|
9
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: requests
|
|
21
|
+
Requires-Dist: ase>=3.23.0
|
|
22
|
+
Requires-Dist: tenacity~=9.0
|
|
23
|
+
Requires-Dist: spglib==2.5.0
|
|
24
|
+
Requires-Dist: httpx
|
|
25
|
+
Requires-Dist: click~=8.0
|
|
26
|
+
Requires-Dist: rich~=13.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest~=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: black; extra == "dev"
|
|
30
|
+
Requires-Dist: isort; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy; extra == "dev"
|
|
32
|
+
Requires-Dist: flake8; extra == "dev"
|
|
33
|
+
|
|
34
|
+
# Atomic Tessellator - CLI package
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
```
|
|
38
|
+
pip install atomict
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Installation for devs
|
|
42
|
+
```
|
|
43
|
+
pip install -e ".[dev]"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Enable verbose logging for debugging:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
export AT_DEBUG=enabled
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
# CLI Usage
|
|
53
|
+
|
|
54
|
+
## Get a list of available commands
|
|
55
|
+
|
|
56
|
+
```$ at```
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
You can get help for each command with `at <command> --help`. This will print the command-specific help and options.
|
|
61
|
+
## Log in and store authentication token
|
|
62
|
+
|
|
63
|
+
```$ at login```
|
|
64
|
+
|
|
65
|
+
This will prompt you for your username and password.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Get a list of available projects
|
|
69
|
+
|
|
70
|
+
```$ at project get```
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Get a list of adsorbates
|
|
76
|
+
|
|
77
|
+
```$ at adsorbate get```
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
## Search objects for substrings
|
|
82
|
+
|
|
83
|
+
```$ at adsorbate get --search NH3```
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
## Get a list of tasks
|
|
88
|
+
|
|
89
|
+
```$ at task get```
|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
## Get tasks with a specific status
|
|
94
|
+
|
|
95
|
+
```$ at task get --status completed```
|
|
96
|
+
|
|
97
|
+

|
|
98
|
+
|
|
99
|
+
## Configuration
|
|
100
|
+
|
|
101
|
+
Tab completion is available. Run the hidden command:
|
|
102
|
+
|
|
103
|
+
```at completion```
|
|
104
|
+
|
|
105
|
+
This will print out the instructions for enabling tab completion for your shell.
|