Skip to content

Commit

Permalink
Fix parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Feb 7, 2024
1 parent 3bfa248 commit 217618b
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 26 deletions.
4 changes: 2 additions & 2 deletions examples/coulomb_blockade/tester.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"metadata": {},
"outputs": [],
"source": [
"DATA_DIR = Path(\"data\")\n",
"NPROCS = 4"
"DATA_DIR = Path(\"pentacene/data\")\n",
"NPROCS = 1"
]
},
{
Expand Down
6 changes: 6 additions & 0 deletions src/aiida_quantum_transport/calculations/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help=f"The {file} file",
)

spec.exit_code(
400,
"ERROR_ACCESSING_OUTPUT_FILE",
"an issue occurred while accessing an expected retrieved file",
)

def prepare_for_submission(self, folder: Folder) -> CalcInfo:
"""docstring"""

Expand Down
6 changes: 6 additions & 0 deletions src/aiida_quantum_transport/calculations/dmft.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help="The sigma folder",
)

spec.exit_code(
400,
"ERROR_ACCESSING_OUTPUT_FILE",
"an issue occurred while accessing an expected retrieved file",
)

def prepare_for_submission(self, folder: Folder) -> CalcInfo:
"""docstring"""

Expand Down
6 changes: 6 additions & 0 deletions src/aiida_quantum_transport/calculations/hybridize.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help="The occupancies file",
)

spec.exit_code(
400,
"ERROR_ACCESSING_OUTPUT_FILE",
"an issue occurred while accessing an expected retrieved file",
)

def prepare_for_submission(self, folder: Folder) -> CalcInfo:
"""docstring"""

Expand Down
6 changes: 6 additions & 0 deletions src/aiida_quantum_transport/calculations/localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help="The transformed hamiltonian file",
)

spec.exit_code(
400,
"ERROR_ACCESSING_OUTPUT_FILE",
"an issue occurred while accessing an expected retrieved file",
)

def prepare_for_submission(self, folder: Folder) -> CalcInfo:
"""docstring"""

Expand Down
6 changes: 6 additions & 0 deletions src/aiida_quantum_transport/calculations/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help="The transmission folder",
)

spec.exit_code(
400,
"ERROR_ACCESSING_OUTPUT_FILE",
"an issue occurred while accessing an expected retrieved file",
)

def prepare_for_submission(self, folder: Folder) -> CalcInfo:
"""docstring"""

Expand Down
11 changes: 7 additions & 4 deletions src/aiida_quantum_transport/parsers/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ class DFTParser(Parser):
def parse(self, **kwargs) -> ExitCode | None:
"""docstring"""

for label, filename in self._OUTPUT_FILE_MAPPING.items():
path = Path(self.node.get_remote_workdir()) / filename
output_label = f"{label}_file"
self.out(output_label, orm.SinglefileData(path))
try:
with self.retrieved.as_path() as retrieved_path:
for label, filename in self._OUTPUT_FILE_MAPPING.items():
path = Path(retrieved_path) / filename
self.out(f"{label}_file", orm.SinglefileData(path))
except OSError:
return self.exit_codes.ERROR_ACCESSING_OUTPUT_FILE

return None
22 changes: 14 additions & 8 deletions src/aiida_quantum_transport/parsers/dmft.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ class DMFTParser(Parser):
def parse(self, **kwargs) -> ExitCode | None:
"""docstring"""

path = Path(self.node.get_remote_workdir()) / "delta_folder"
self.out("delta_folder", orm.FolderData(tree=path))
try:
with self.retrieved.as_path() as retrieved_path:
root = Path(retrieved_path)

path = Path(self.node.get_remote_workdir()) / "sigma_folder"
self.out("sigma_folder", orm.FolderData(tree=path))
path = root / "delta_folder"
self.out("delta_folder", orm.FolderData(tree=path))

adjust_mu: orm.Bool = self.node.inputs.adjust_mu
path = root / "sigma_folder"
self.out("sigma_folder", orm.FolderData(tree=path))

if adjust_mu.value:
path = Path(self.node.get_remote_workdir()) / "mu.txt"
self.out("mu_file", orm.SinglefileData(path))
adjust_mu: orm.Bool = self.node.inputs.adjust_mu

if adjust_mu.value:
path = root / "mu.txt"
self.out("mu_file", orm.SinglefileData(path))
except OSError:
return self.exit_codes.ERROR_ACCESSING_OUTPUT_FILE

return None
15 changes: 9 additions & 6 deletions src/aiida_quantum_transport/parsers/hybridize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class HybridizationParser(Parser):
"""docstring"""

_OUTPUT_FILE_LIST = [
_OUTPUT_FILES = [
"hybridization.bin",
"energies.npy",
"hamiltonian.npy",
Expand All @@ -23,10 +23,13 @@ class HybridizationParser(Parser):
def parse(self, **kwargs) -> ExitCode | None:
"""docstring"""

for filename in self._OUTPUT_FILE_LIST:
path = Path(self.node.get_remote_workdir()) / filename
prefix = filename.split(".")[0]
output_label = f"{prefix}_file"
self.out(output_label, orm.SinglefileData(path))
try:
with self.retrieved.as_path() as retrieved_path:
for filename in self._OUTPUT_FILES:
path = Path(retrieved_path) / filename
prefix = filename.split(".")[0]
self.out(f"{prefix}_file", orm.SinglefileData(path))
except OSError:
return self.exit_codes.ERROR_ACCESSING_OUTPUT_FILE

return None
11 changes: 7 additions & 4 deletions src/aiida_quantum_transport/parsers/localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ class LocalizationParser(Parser):
def parse(self, **kwargs) -> ExitCode | None:
"""docstring"""

for label, filename in self._OUTPUT_FILE_MAPPING.items():
path = Path(self.node.get_remote_workdir()) / filename
output_label = f"{label}_file"
self.out(output_label, orm.SinglefileData(path))
try:
with self.retrieved.as_path() as retrieved_path:
for label, filename in self._OUTPUT_FILE_MAPPING.items():
path = Path(retrieved_path) / filename
self.out(f"{label}_file", orm.SinglefileData(path))
except OSError:
return self.exit_codes.ERROR_ACCESSING_OUTPUT_FILE

return None
8 changes: 6 additions & 2 deletions src/aiida_quantum_transport/parsers/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ class TransmissionParser(Parser):
def parse(self, **kwargs) -> ExitCode | None:
"""docstring"""

path = Path(self.node.get_remote_workdir()) / "transmission_folder"
self.out("transmission_folder", orm.FolderData(tree=path))
try:
with self.retrieved.as_path() as retrieved_path:
path = Path(retrieved_path) / "transmission_folder"
self.out("transmission_folder", orm.FolderData(tree=path))
except OSError:
return self.exit_codes.ERROR_ACCESSING_OUTPUT_FILE

return None

0 comments on commit 217618b

Please sign in to comment.