Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix flipped paths in non-writable config dir warning.#18014

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:masterfromQuLogic:fix-non-writable-config
Jul 22, 2020

Conversation

QuLogic
Copy link
Member

PR Summary

Fixes#18011.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way

@QuLogicQuLogic added this to thev3.3.1 milestoneJul 22, 2020
@jklymakjklymak merged commit9fcf958 intomatplotlib:masterJul 22, 2020
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJul 22, 2020
@QuLogicQuLogic deleted the fix-non-writable-config branchJuly 22, 2020 19:54
QuLogic added a commit that referenced this pull requestJul 22, 2020
…014-on-v3.3.xBackport PR#18014 on branch v3.3.x (Fix flipped paths in non-writable config dir warning.)
@john-zenden
Copy link

john-zenden commentedAug 12, 2022
edited
Loading

Error: [WARNING]2022-08-01T20:35:34.010ZMatplotlib created a temporary config/cache directory at /tmp/matplotlib-dw7qh4b1 because the default path (/home/sbx_user1051/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.

I got this in AWS Lambda and comment here only for the benefit of those who might come across this in a Google search.

If you are using Matplotlib (or something which depends on it) in the AWS Lambda environment you have probably already run up against 250MB limit for the Zip deployment method of the AWS Lambda function. If you go to a Image deployment, your image can be up to 10GB.

Deploying the AWS Lambda function as an image offers two things to solve this error (and speed up your function). First, in the Configuration section for the function, set the Ephemeral Storage to a higher value (something like 1024). Be aware that your costs will be calculated at GB/seconds for this resource. Then, add the following to your Dockerfile after the RUN command calling pip to install your dependencies:

ENV MPLCONFIGDIR=/tmp

If you look carefully at the Ephemeral Storage setting in AWS, you'll see it refers to /tmp. You are telling Matplotlib to use /tmp as its temp storage, and configuring the max size in AWS at 1GB (1024MB). To see why this works, bring up a CLI for the Docker image. I am developing on Windows with VSCode with the AWS SAM CLI, which requires Docker be installed. So after running > 'sam build' at the Terminal CLI in VSCode, Docker starts running the image. In Docker I click the ">" button and a CLI terminal for the image appears.

Like any other Linux environment, you'll be in a user directory. CD back to the root folder. Do an ls -al and take note of the permissions for /home and /tmp. You'll see that /tmp is writable by default, but /home is not. By adding the ENV command in Dockerfile you are telling Matplotlib to use /tmp. By setting the Ephemeral Storage value in AWS you are allocating sufficient space in /tmp.

Thew warning in the logs should then disappear.

@tacaswell
Copy link
Member

One of the things that goes into the cache directory is a json file of the fonts we found. Pre-generating that file and uncluding it in your image will speed up the initial import time by avoid a (possibly expensive) file walking process.

@john-zenden
Copy link

@tacaswell Is the JSON filename always the same?

@tacaswell
Copy link
Member

Yes, but if we change the spec of the file we will change the filename. We have not changed it recently, but I suspect we will change it soon. If you need to support more than one version of mpl include both files.

def_load_fontmanager(*,try_read_cache=True):
fm_path=Path(
mpl.get_cachedir(),f"fontlist-v{FontManager.__version__}.json")
iftry_read_cache:
try:
fm=json_load(fm_path)
exceptException:
pass
else:
ifgetattr(fm,"_version",object())==FontManager.__version__:
_log.debug("Using fontManager instance from %s",fm_path)
returnfm
fm=FontManager()
json_dump(fm,fm_path)
_log.info("generated new fontManager")
returnfm

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

@tacaswelltacaswelltacaswell approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.3.1
Development

Successfully merging this pull request may close these issues.

Confusing error message when home config directory not writable
4 participants
@QuLogic@john-zenden@tacaswell@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp