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

Sourcegen CLib edge cases #1846

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

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Feb 3, 2025

Changes proposed in this pull request

Address several edge cases encountered in CLib

  • Extend auto-generation of CLib APIs to variables (not just functions)
  • Use ReactionPathDiagram as an example (also, C++ API is updated to match Python API)
  • Expose Cantera constants to CLib
  • Implement CLib loggers

If applicable, fill in the issue number this pull request is fixing

Addresses Cantera/enhancements#220

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@ischoegl ischoegl added the clib label Feb 3, 2025
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 60.41667% with 19 lines in your changes missing coverage. Please review.

Project coverage is 74.39%. Comparing base (e6f3e9d) to head (fc7926b).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/kinetics/ReactionPath.cpp 59.45% 12 Missing and 3 partials ⚠️
interfaces/cython/cantera/reactionpath.pyx 63.63% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1846      +/-   ##
==========================================
- Coverage   74.41%   74.39%   -0.02%     
==========================================
  Files         386      386              
  Lines       53628    53651      +23     
  Branches     9063     9071       +8     
==========================================
+ Hits        39905    39913       +8     
- Misses      10652    10663      +11     
- Partials     3071     3075       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ischoegl ischoegl force-pushed the sourcegen-clib-edge branch 2 times, most recently from 3a2e8ec to 1597b38 Compare February 3, 2025 20:25
@ischoegl ischoegl marked this pull request as ready for review February 3, 2025 20:51
@ischoegl ischoegl requested a review from a team February 3, 2025 20:51
@ischoegl ischoegl force-pushed the sourcegen-clib-edge branch from 1597b38 to dfec1b3 Compare February 3, 2025 21:30
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

Thanks, @ischoegl. This generally looks good to me. Just a few minor suggestions.

Comment on lines 404 to 411
* Create a reaction path diagram for the fluxes of the Element @c element
* according the the net reaction rates determined by the Kinetics object @c kin.
* @param kin Shared pointer to kinetics object.
* @param element Element used for the calculation of net reaction rates.
* @return shared_ptr<ReactionPathDiagram>
Copy link
Member

Choose a reason for hiding this comment

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

The @param and @return notations here add nothing beyond what's either stated in the prose description above or explicitly given by the argument/return types. I would suggest removing them.

Copy link
Member Author

@ischoegl ischoegl Feb 15, 2025

Choose a reason for hiding this comment

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

For the current CLib code generation, we only care about the @brief description, as well as @param and @return. From that perspective, the extended docstring is secondary. I updated both docstrings so they are less redundant. In the future, sourcegen may pick up more information; for the time being, I am trying to make sure that the most relevant docstrings are in place.

Comment on lines +356 to +360
shared_ptr<ReactionPathBuilder> m_builder; //!< Shared pointer to ReactionPathBuilder
std::stringstream m_log; //!< Logging stream.
Copy link
Member

Choose a reason for hiding this comment

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

Not a recommendation for this PR, but I'm getting the impression that ReactionPathBuilder should just be merged with ReactionPathDiagram. They seem to be intricately connected and I'm not sure there's any benefit of having the former as a separate class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. For this PR, my main concern was to streamline the API; the ReactionPathDiagram code base definitely needs another look, perhaps with Cantera/enhancements#173? The logging is likewise no longer consistent with our current approaches.

@ischoegl ischoegl force-pushed the sourcegen-clib-edge branch from bb81255 to fc7926b Compare February 15, 2025 02:16
@ischoegl
Copy link
Member Author

@speth ... thanks for the review. The PR should be ready to merge.

@ischoegl ischoegl requested a review from speth February 16, 2025 02:42
@ischoegl
Copy link
Member Author

ischoegl commented Mar 9, 2025

@speth ... this should be done/ready.

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

Successfully merging this pull request may close these issues.

2 participants