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

Adds recursive __all__ dictionary #4040

Merged
merged 9 commits into from May 13, 2024

Conversation

arjxn-py
Copy link
Member

Description

Been proposed in #3866

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@arjxn-py arjxn-py requested a review from a team as a code owner April 23, 2024 23:58
@arjxn-py
Copy link
Member Author

Also related to #2427

Copy link

codecov bot commented Apr 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (c687134) to head (d87955b).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4040      +/-   ##
===========================================
- Coverage    99.58%   99.58%   -0.01%     
===========================================
  Files          261      287      +26     
  Lines        21454    21723     +269     
===========================================
+ Hits         21366    21632     +266     
- Misses          88       91       +3     

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

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks, @arjxn-py – overall, I believe that adding __all__ to the codebase makes a lot of sense, it's the more modern way of bringing structure to the public API, plus providing efficient tab completions for IDEs and text editors.

I wonder if doing this in a staggering manner, i.e., across multiple pybamm/module/submodule/__init__.py files makes more sense, in comparison to adding them in the same file? We have way too many changes in a single file right now, it would become difficult to keep track of where these symbols and attributes come from (some in-line comments could also be of help). Keeping everything split across files will be just a one-time change to review (though it would have to be thorough), and then adding to items to multiple __all__ lists will be simpler, too, since they will be smaller. I suppose you're using the mkinit tool right now that has come up in our previous discussions – the main issue with it was that we would have needed to ask contributors to run a command every time they modified something for the API, and we don't want that additional complexity. Splitting this across multiple files should make the structure easier to follow and then manually modify on future changes, without the use of the tool.

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks, @arjxn-py! I think this looks all good to me, unless there is something more that you plan to do here and push further changes.

pybamm/solvers/c_solvers/__init__.py Outdated Show resolved Hide resolved
arjxn-py and others added 2 commits May 2, 2024 12:39
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
@arjxn-py
Copy link
Member Author

arjxn-py commented May 2, 2024

Planned to add some directives to contribution guide as well but I believe it should be fine without that, we just have to little bit more careful on the PRs modifying method & attribute names or adding new of them.

@arjxn-py
Copy link
Member Author

arjxn-py commented May 2, 2024

Feel free to merge it after approval.

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Looks fine to me, @arjxn-py! I'll request another review from @Saransh-cpp, we can merge soon after.

Edit: could you fix the conflicts?

@kratman
Copy link
Contributor

kratman commented May 3, 2024

Is this something that needs to be updated frequently?

@agriyakhetarpal
Copy link
Member

No, as long as we're not changing the API frequently. It does need to be updated when adding new features, though.

The goal will be that once we have a stable public-private API demarcation, __all__ will reflect the public API.

@arjxn-py
Copy link
Member Author

arjxn-py commented May 9, 2024

Just a gentle ping to @Saransh-cpp to review this and go forward with it if looks fine, Thanks :)

Copy link
Member

@Saransh-cpp Saransh-cpp left a comment

Choose a reason for hiding this comment

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

Thanks, @arjxn-py! Looks good to me!

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

The coverage failure is related to an upstream change and the patch coverage is passing so approving again, thanks, @arjxn-py!

@agriyakhetarpal agriyakhetarpal merged commit b18abed into pybamm-team:develop May 13, 2024
41 of 42 checks passed
@agriyakhetarpal agriyakhetarpal deleted the add-__all__ branch May 13, 2024 18:44
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

4 participants