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

Update MinimalLib for Function Exposure: runReactants #7210

Merged
merged 6 commits into from May 9, 2024

Conversation

syedzayyan
Copy link
Contributor

This is an exposure of runReactants features to minimal lib:

  • a single function is exposed
  • results are an array of JSMolLists

It passed the simple test I coded. First-time contributor, please go easy :).

- Added Run Reactants and added JS Tests
@syedzayyan syedzayyan changed the title Update MinimalLib for Function Exposure Update MinimalLib for Function Exposure: runReactants Mar 5, 2024
@syedzayyan
Copy link
Contributor Author

Hello! @greglandrum @ptosco

A silly question. I plan to port ScaffoldNetwork to MinimalLib as well. Would I need to open a new PR for that or shall I merge that into this PR?

@ptosco
Copy link
Contributor

ptosco commented Mar 5, 2024

@syedzayyan Please submit a separate PR.
Also, I'd recommend to make building ScaffoldNetwork support optional through a CMake switch (mapping to a preprocessor macro, such as RDK_BUILD_MINIMAL_LIB_SCAFFOLDNETWORK) in order not to keep MnimalLib as minimal as it can be for non-interested users.

@syedzayyan
Copy link
Contributor Author

Thank you for your prompt response! @ptosco

I'll go ahead and submit a separate PR for the ScaffoldNetwork feature, as suggested with the CMake switch for greater flexibility.

On another note, if you find some time, I'd love to get your input on this PR :).

@greglandrum greglandrum requested a review from ptosco March 16, 2024 05:43

for (const auto &reactant : reactants.mols()) {
if (!reactant) {
std::cerr << "Error: reactant is null\n";
Copy link
Member

Choose a reason for hiding this comment

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

We don't do error reporting straight to std::cerr.
I think you need to thrown an exception here, but @ptosco should suggest what he thinks is the best approach for error handling in minilib

@ptosco
Copy link
Contributor

ptosco commented Mar 17, 2024

@syedzayyan I have submitted a PR against your branch with some suggested changes.

  1. You do not need to check d_rxn against non-nullness as JSReaction cannot be constructed with a null ChemicalReaction.
  2. @greglandrum is right about the fact that it is better to throw an exception rather than printing anything to std::cerr
  3. I would not catch upstream exceptions
  4. I would return a vector of JSMolList pointers and call it JSMolListList for consistency with StringList
  5. I would delete all C++ objects in the test; while it is not terrilbly important to leak some memory in the test, I think it is good practice to write tests which cleanly delete objects on exit as they may serve as examples to other developers.

@syedzayyan
Copy link
Contributor Author

Hello @ptosco ! Thanks very much for the suggestions. I was wondering why return a vector of JSMolList pointers instead, on point 4. The build fails when a pointer is returned and allow_raw_pointers() is not helping with the Implicitly binding raw pointers is illegal error.

Copy link
Contributor

@ptosco ptosco left a comment

Choose a reason for hiding this comment

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

I tested this locally and it looks good to me.

@greglandrum
Copy link
Member

I just (hopefully) fixed the merge conflicts. Will merge later this afternoon after the CI builds go through

@greglandrum greglandrum merged commit c2369f9 into rdkit:master May 9, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants