Skip to content

Add a constants file for python modules #1621

Open

Description

@ekluzek

This came up in discussing #1461 with @negin513. We wondered if it would be helpful to have a small python file with a list of constants that could be shared. A small utility file could keep a list of constants that could be shared between modules. NATPFT and MXPFT and MONTHS_PER_YEAR are all things that could go into this list.

I'm not sure if this is the best way to do this. But, it seems like it would be the simplest way to have those constants shared between several python modules. In Python 3.8, you can use the Final module and "Final" qualifier to give warnings if something is redefined. Another way that constants are handled to be really sure they don't change is to make them functions so you can't redefine them. But, likely a simple file would be sufficient.

Activity

  1. added
    code healthimproving internal code structure to make easier to maintain (sustainability)
    on Jan 29, 2022
  2. changed the title [-]Add a constants file for python/[/-] [+]Add a constants file for python modules[/+] on Jan 29, 2022
  3. michellejtan commented on Nov 1, 2026

    @michellejtan

    Hi! I'd like to take this one as a first contribution. My plan: add a small shared Python constants module (starting with NATPFT, MXPFT and MONTHS_PER_YEAR), then switch the existing python modules that define those values over to it. I'll check back here on the exact file location and naming before I open a PR. I expect to have a draft within about a week or two. If someone is already working on this, or you'd prefer a different approach, please let me know.

  4. added
    enhancementnew capability or improved behavior of existing capability
    b4bbit-for-bit
    on Nov 1, 2026
  5. added this to the ctsm7.0.0 milestone on Nov 1, 2026
  6. ekluzek commented on Nov 1, 2026

    @ekluzek
    ContributorAuthor

    6. Hi! I'd like to take this one as a first contribution. My plan: add a small shared Python constants module (starting with NATPFT, MXPFT and MONTHS_PER_YEAR), then switch the existing python modules that define those values over to it. I'll check back here on the exact file location and naming before I open a PR. I expect to have a draft within about a week or two. If someone is already working on this, or you'd prefer a different approach, please let me know.

    Hi @michellejtan thanks so much for volunteering to take this on. We really appreciate it. This sounds great.

    Base your branch and PR off the b4b-dev branch. The contributing guidelines should help. We haven't finalized our guidelines for using AI, but use the PR in #4286 to guide your AI contributions. Looking forward to seeing your contribution. Take care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    b4bbit-for-bitcode healthimproving internal code structure to make easier to maintain (sustainability)enhancementnew capability or improved behavior of existing capabilitygood first issuesimple; good for first-time contributors

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions