Skip to content

Conversation

mikemhenry
Copy link
Contributor

@mikemhenry mikemhenry commented Oct 10, 2025

This will let a user disable jax at runtime. A larger refactor is needed to test this since at import time the PYMBAR_DISABLE_JAX variable is checked, so even if monkey patched the module has already been imported. This also means that once pymbar has been imported, setting PYMBAR_DISABLE_JAX will do nothing.

TODO: add docs

def test_env_values(self, monkeypatch, env_value, expected):
"""Test various environment variable values."""
monkeypatch.setenv("PYMBAR_DISABLE_JAX", env_value)
assert _setup_jax_accleration() is expected
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to specify an error message in case the assertion fails? Something like "received X but expected Y"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pytest will do that for us

Copy link
Contributor

@ijpulidos ijpulidos left a comment

Choose a reason for hiding this comment

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

This is looking great, I think this works for our purposes. Just some minor changes/comments.

In the long term I wonder if we want to make the MBAR object itself specify the backend via an argument.

mikemhenry and others added 4 commits October 15, 2025 11:20
@mikemhenry
Copy link
Contributor Author

#509 is how we will fix this long term, but this should work for now.

@mikemhenry mikemhenry requested a review from ijpulidos October 15, 2025 18:23
("yes", True),
("YES", True),
("YeS", True),
("0", True),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect 0=False and 1=True, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

duh! I was thinking about 0 being the "good" exit code and that was "true" to be BUT as soon as you mention that, it is the opposite of the convention

@mikemhenry mikemhenry requested a review from atravitz October 16, 2025 16:07
Copy link
Contributor

@ijpulidos ijpulidos left a comment

Choose a reason for hiding this comment

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

Looking great. One minor comment, but otherwise LGTM.

README.md Outdated

However, many packages released on conda-forge specify `pymbar` as a dependency, making it impossible to install the non-jax accelerated of PyMbar.
In `pymbar >= 4.2.0` JAX acceleration can be controlled with the environmental variable `PYMBAR_DISABLE_JAX`.
Setting `PYMBAR_DISABLE_JAX` to a truth-y value (`TRUE`, `YES`, `0`) will disable JAX acceleration even if the `jax` package is installed.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we mean here 1 instead of 0 as a truth-y value?

@mikemhenry mikemhenry enabled auto-merge (squash) October 16, 2025 19:45
@mikemhenry mikemhenry merged commit 1a89280 into choderalab:main Oct 16, 2025
17 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.

3 participants