Skip to content

Commit 1606798

Browse files
authored
Merge pull request #255 from Exabyte-io/feature/SOF-7779
update: fix formats + mol
2 parents 76cf906 + ee3a791 commit 1606798

3 files changed

Lines changed: 15 additions & 48 deletions

File tree

config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ default:
3131
- uncertainties==3.1.6
3232
- jinja2
3333
- pymatgen-analysis-defects<=2024.4.23
34-
- mat3ra-made==2025.11.24.post0
34+
- mat3ra-made==2025.12.16.post0
3535
# packages below are used when made is installed from GH wheel (made should be installed from below)
3636
# - https://exabyte-io.github.io/made/mat3ra_made-0.1.dev1+ge64d360b8-py3-none-any.whl
3737
# - mat3ra-code
@@ -66,3 +66,4 @@ notebooks:
6666
packages_common:
6767
- mat3ra-standata
6868
- exabyte-api-client
69+
- requests

other/generate_gifs/gif_processing.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
"metadata": {},
185185
"cell_type": "code",
186186
"source": [
187-
"from other.media_generation.utils.font_manager import FontManager\n",
187+
"from other.generate_gifs.utils.font_manager import FontManager\n",
188188
"\n",
189189
"# Initialize font manager and list available fonts\n",
190190
"font_manager = FontManager()\n",
@@ -243,7 +243,7 @@
243243
"metadata": {},
244244
"cell_type": "code",
245245
"source": [
246-
"from other.media_generation.utils.gif_processor import GIFProcessor\n",
246+
"from other.generate_gifs.utils.gif_processor import GIFProcessor\n",
247247
"\n",
248248
"\n",
249249
"def process_all_gifs():\n",

other/materials_designer/import_materials_from_files.ipynb

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"FOLDER_PATH = \"./uploads\"\n",
4747
"\n",
4848
"# By default, format will be guessed from file extension\n",
49-
"# If set to specific format, notebook will only read that format\n",
50-
"ENFORCED_FORMATS = None # e.g. [\"cif\", \"espresso-in\"]\n",
49+
"# If set to specific format, or array of formats, notebook will only read that format\n",
50+
"ENFORCED_FORMATS = None # e.g. \"cif\" or [\"cif\", \"espresso-in\"]\n",
5151
"\n",
5252
"# If set to true, the file extension will be included in the resulting material name\n",
5353
"USE_FILE_NAME_NO_EXTENSION = False\n",
@@ -72,11 +72,14 @@
7272
"outputs": [],
7373
"source": [
7474
"import sys\n",
75+
"\n",
7576
"if sys.platform == \"emscripten\":\n",
7677
" import micropip\n",
78+
"\n",
7779
" await micropip.install(\"mat3ra-api-examples\", deps=False)\n",
7880
" await micropip.install('mat3ra-utils')\n",
7981
" from mat3ra.utils.jupyterlite.packages import install_packages\n",
82+
"\n",
8083
" await install_packages(\"import_materials_from_files.ipynb\")"
8184
]
8285
},
@@ -101,18 +104,18 @@
101104
"from pathlib import Path\n",
102105
"from ase.io import read\n",
103106
"\n",
104-
"ase_atoms, readable_file_names, unreadable_file_names = [], [], []\n",
107+
"ase_atoms_list, readable_file_names, unreadable_file_names = [], [], []\n",
105108
"file_names = os.listdir(FOLDER_PATH)\n",
106109
"\n",
107110
"for file_name in file_names:\n",
108111
" file_path = os.path.join(FOLDER_PATH, file_name)\n",
109-
" formats = ENFORCED_FORMATS or [None]\n",
112+
" formats = [ENFORCED_FORMATS] if isinstance(ENFORCED_FORMATS, str) else ENFORCED_FORMATS or [None]\n",
110113
"\n",
111114
" for fmt in formats:\n",
112115
" try:\n",
113116
" atoms = read(file_path, format=fmt)\n",
114117
" atoms.info[\"file_name\"] = Path(file_name).stem if USE_FILE_NAME_NO_EXTENSION else file_name\n",
115-
" ase_atoms.append(atoms)\n",
118+
" ase_atoms_list.append(atoms)\n",
116119
" readable_file_names.append(file_name)\n",
117120
" print(\"Successfully read:\", atoms.info[\"file_name\"], \"using format:\", fmt)\n",
118121
" break\n",
@@ -138,7 +141,7 @@
138141
"metadata": {},
139142
"outputs": [],
140143
"source": [
141-
"print(f\"Successfully read {len(ase_atoms)} files: {readable_file_names}. \")\n",
144+
"print(f\"Successfully read {len(ase_atoms_list)} files: {readable_file_names}. \")\n",
142145
"print(f\"Unreadable files: {unreadable_file_names}. \")"
143146
]
144147
},
@@ -182,46 +185,9 @@
182185
"metadata": {},
183186
"outputs": [],
184187
"source": [
185-
"import io\n",
186-
"from ase import Atoms\n",
187-
"from ase.io import write\n",
188-
"from express import ExPrESS\n",
189-
"\n",
190-
"def ase_to_poscar(atoms: Atoms):\n",
191-
" output = io.StringIO()\n",
192-
" try:\n",
193-
" write(output, atoms, format=\"vasp\")\n",
194-
" content = output.getvalue()\n",
195-
" except Exception as e:\n",
196-
" print(f\"Error converting ASE atoms to POSCAR: {e}\")\n",
197-
" content = None\n",
198-
" finally:\n",
199-
" output.close()\n",
200-
"\n",
201-
" return content\n",
202-
"\n",
203-
"def convert_ase_entry_to_esse(ase_entry):\n",
204-
" try:\n",
205-
" poscar = ase_to_poscar(ase_entry)\n",
206-
" if poscar is None:\n",
207-
" raise ValueError(\"Failed to generate POSCAR string\")\n",
208-
"\n",
209-
" kwargs = {\n",
210-
" \"structure_string\": poscar,\n",
211-
" \"structure_format\": \"poscar\"\n",
212-
" }\n",
213-
"\n",
214-
" handler = ExPrESS(\"structure\", **kwargs)\n",
215-
" esse = handler.property(\"material\", **kwargs)\n",
216-
"\n",
217-
" esse[\"name\"] = ase_entry.info.get(\"file_name\", \"Unknown\")\n",
218-
"\n",
219-
" return esse\n",
220-
" except Exception as e:\n",
221-
" print(f\"Error processing ASE entry: {e}\")\n",
222-
" return None\n",
188+
"from mat3ra.made.tools.convert import from_ase\n",
223189
"\n",
224-
"esse_entries = [entry for entry in map(convert_ase_entry_to_esse, ase_atoms) if entry is not None]"
190+
"esse_entries = [from_ase(ase_atoms) for ase_atoms in ase_atoms_list]"
225191
]
226192
},
227193
{

0 commit comments

Comments
 (0)