Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get to avoid KeyError on missing cmiles attribute #300

Merged
merged 14 commits into from
Oct 21, 2024
8 changes: 4 additions & 4 deletions openff/qcsubmit/results/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ def from_datasets(
"canonical_isomeric_explicit_hydrogen_mapped_smiles"
)
if not cmiles:
cmiles = entry.attributes[
cmiles = entry.attributes.get(
"canonical_isomeric_explicit_hydrogen_mapped_smiles"
]
)
if not cmiles:
print(f"MISSING CMILES! entry = {entry_name}")
Copy link
Member

@j-wags j-wags Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(blocking) Could you change this to be warnings.warn with a new warning type like MissingCMILESWarning?

continue
Expand Down Expand Up @@ -470,9 +470,9 @@ def from_datasets(
"canonical_isomeric_explicit_hydrogen_mapped_smiles"
)
if not cmiles:
cmiles = entry.attributes[
cmiles = entry.attributes.get(
"canonical_isomeric_explicit_hydrogen_mapped_smiles"
]
)
if not cmiles:
print(f"MISSING CMILES! entry = {entry_name}")
continue
Expand Down
Loading