Skip to content

matplotlib use non-interactive agg backend#349

Merged
naik-aakash merged 5 commits intoJaGeo:mainfrom
DanielYang59:mpl-backend
Nov 18, 2024
Merged

matplotlib use non-interactive agg backend#349
naik-aakash merged 5 commits intoJaGeo:mainfrom
DanielYang59:mpl-backend

Conversation

@DanielYang59
Copy link
Copy Markdown
Contributor

Fix a previously added parameter as the original comment is a bit misleading, agg is the recommended non-interactive backend:

The last, Agg, is a non-interactive backend that can only write to files. It is used on Linux, if Matplotlib cannot connect to either an X display or a Wayland display.

@DanielYang59 DanielYang59 marked this pull request as draft November 13, 2024 04:59
@DanielYang59
Copy link
Copy Markdown
Contributor Author

No this is not right, as running tests locally would behave differently than through GH action, would fix this later

@DanielYang59
Copy link
Copy Markdown
Contributor Author

DanielYang59 commented Nov 13, 2024

I realized the original method might be the best I could do so far. If we were to export the env var from the test workflow config file python-package.yml, it would only be effective running on actions (not locally).

However I believe having that MPLBACKEND set is still beneficial:

pytest doesn't seem to natively support setting environment variable from pyproject.toml and there is a plugin pytest-env just for this purpose (though with the price of added an additional tests dependency):

[tool.pytest_env]
HOME = "~/tmp"
RUN_ENV = 1

dependencies = [
"pymatgen>=2024.10.22",
"numpy<3.0.0",
"typing",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess we don't need to install typing now, it's built in from 3.5:

Added in version 3.5.

@DanielYang59 DanielYang59 marked this pull request as ready for review November 13, 2024 11:27
@naik-aakash
Copy link
Copy Markdown
Collaborator

Hi @DanielYang59 , before we merge, can you please provide a bit more context on why this change is needed and what are the issues when we don't have this?

I am not that familiar with lot of what matplotlib has to offer. So just want to understand bit better 😄

And thanks in anycase for this PR

@DanielYang59
Copy link
Copy Markdown
Contributor Author

DanielYang59 commented Nov 18, 2024

can you please provide a bit more context on why this change is needed and what are the issues when we don't have this?

Absolutely, I owe you an explanation here:

@naik-aakash naik-aakash merged commit 6143273 into JaGeo:main Nov 18, 2024
@naik-aakash
Copy link
Copy Markdown
Collaborator

Thanks @DanielYang59

@DanielYang59 DanielYang59 deleted the mpl-backend branch November 18, 2024 07:21
@DanielYang59
Copy link
Copy Markdown
Contributor Author

No problem thanks for reviewing

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.

2 participants