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
Add ChemicalEnvironmentParsingError
#1695
Conversation
9aad992
to
14f348d
Compare
Not sure why the docs build failed, I re-kicked it. I think this is good to go; if there was any extension it might be thinking through other cases of SMARTS parsing failures elsewhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither SMIRKSParsingError
nor SMARTSParsingError
are totally correct in this context, but given that:
- Our force fields use "smirks" in this context
- We already have a
SMIRKSParsingError
exception type
I think we should just stick with the old SMIRKSParsingError
here, and roll ValueError
into its inheritance.
These are SMARTS queries to RDKit and OEChem, not SMIRKS queries |
How about So I'm thinking we'll eventually want all of our SMARTS/SMIRKS parsing errors to become It was probably a mistake to ever expose a method called In future API-breaking releases we can remove If that makes sense to you, I'll open an issue to track this migration plan. |
If the toolkit is not meant to have SMARTS-matching facilities, maybe it should simply be removed? It's not used internally to the toolkit at all: $ grep -ri --exclude=openff/toolkit/_tests/test_toolkits.py '\.find_smarts' openff/toolkit
openff/toolkit/topology/molecule.py: matches = toolkit_registry.find_smarts_matches( # type: ignore[attr-defined] This is a bigger change than having a |
Since we're using a weird variant/subset of SMIRKS/SMARTS, I think it'll be handy to expose some utility short of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SMARTSParsingError
added by the current state of this PR adds a new exception type which is in practice redundant with SMIRKSParsingError
. To minimize unnecessary API complexity and to reduce the number of future deprecation, the SMARTSParsingError
in this PR should either:
- Be replaced by the existing
SMIRKSParsingError
- Be replaced by a new
ChemicalEnvironmentParsingError
, which inherits fromSMIRKSParsingError
ChemicalEnvironmentParsingError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Thanks @mattwthompson, please update the releasenotes before you merge.
class ChemicalEnvironmentParsingError( | ||
SMIRKSParsingError, | ||
ValueError, | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Currently, inside of either
RDKitToolkitWrapper._find_smarts_matches
orOpenEyeToolkitWrapper._find_smarts_matches
, aValueError
is raised when the SMARTS pattern of the query is not successfully parsed. This adds a more specific exception (#771) with backwards-compatibility in order for downstream tools to better parse this particular error as distinct from the (many) other ways aValueError
could be raised.