Skip to content

Commit

Permalink
StructureUploaderWidget: fix reading QE input files. (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Oct 28, 2021
1 parent e8f20e4 commit 8472d04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions aiidalab_widgets_base/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import datetime
import io
import tempfile
from collections import OrderedDict

# ASE imports
Expand Down Expand Up @@ -61,7 +62,7 @@ def __init__(
editors=None,
storable=True,
node_class=None,
**kwargs
**kwargs,
):
"""
Arguments:
Expand Down Expand Up @@ -389,11 +390,12 @@ def _on_file_upload(self, change=None):
if frmt == "cif":
self.structure = CifData(file=io.BytesIO(item["content"]))
else:
self.structure = self._validate_and_fix_ase_cell(
get_ase_from_file(
io.StringIO(item["content"].decode()), format=frmt
with tempfile.NamedTemporaryFile(suffix=f".{frmt}") as temp_file:
temp_file.write(item["content"])
temp_file.flush()
self.structure = self._validate_and_fix_ase_cell(
get_ase_from_file(temp_file.name)
)
)
self.file_upload.value.clear()
break

Expand Down

0 comments on commit 8472d04

Please sign in to comment.