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

[DNM] asap-data Fix empty ligand to_oemol() error #998

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

apayne97
Copy link
Contributor

@apayne97 apayne97 commented Apr 18, 2024

Description

fixes #990

Todos

Notable points that this PR has either accomplished or will accomplish.

  • add test to catch bug
  • enable set_SD_data to allow None (kicking the problem down the road)

Questions

  • Question 1 ..

Status

  • Ready to go

Developers certificate of origin

@apayne97 apayne97 requested a review from hmacdope April 18, 2024 21:12
@apayne97 apayne97 added small bug Something isn't working docking Related to docking parts of the package and removed bug Something isn't working docking Related to docking parts of the package labels Apr 18, 2024
def test_empty_ligand():
lig = Ligand.from_smiles("", compound_name="test_empty")
assert lig.data is None
assert lig.to_oemol() is None
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I wrong in thinking that the Ligand instance shouldn't be able to return a None for this method? This is something that we commonly want to avoid, because this can easily lead to the infamously common "NoneType is not xxxxxx" error or similar further along the pipeline, which we want to avoid. We want to fail "early".

Copy link
Contributor

@ijpulidos ijpulidos Apr 18, 2024

Choose a reason for hiding this comment

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

Or in other words, this looks like working around a deeper problem in the underlying classes, namely Ligand in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, what do you think we should be returning instead? or set a validation error for Ligand if it is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also I figured out where the change is from pre- #692 that causes the break in #990

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, in my opinion having it to fail when it's None would be better, but that would need to be tested since the behavior is already there and some tools further down the pipeline might already be using this. Now, to be fair, according to the documentation it is not supposed to return None, and that's the contract we are willing to sign. So, if we are following the documentation (and type annotations) this should be "fine".

@hmacdope hmacdope changed the title asap-data Fix empty ligand to_oemol() error [DNM] asap-data Fix empty ligand to_oemol() error Apr 26, 2024
Copy link
Collaborator

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

block for DNM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants