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

matplotlib Warning About Temporary Files in /tmp #13

Open
jamboNum5 opened this issue Nov 14, 2022 · 2 comments
Open

matplotlib Warning About Temporary Files in /tmp #13

jamboNum5 opened this issue Nov 14, 2022 · 2 comments

Comments

@jamboNum5
Copy link

We have been playing with jobinabox, everything has been going well so far, so a big thanks!

We had a minor issue with matplotlib complaining about the tmp location:

Matplotlib created a temporary config/cache directory at /tmp/matplotlib-79ubm2uq because the default path (/home/jobe00/.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 dropped into the docker container and added /home/jobe00 and set it as writable for the user jobe00 which did resolve the warning message. When a questions get processed, it does create some tmp files as expected. I'm guessing this isn't the optimal solution here as we ideally want each runguard job to run without any cached files.

I thought I might be able to set export MPLCONFIGDIR=/tmp in bashrc or profile.d but this doesn't get picked when the runguard user jobe00 processes the job.

Any guidance would be great, cheers!

@jamboNum5 jamboNum5 changed the title matplotlib warning about /tmp matplotlib Warning About Temporary Files in /tmp Nov 14, 2022
@trampgeek
Copy link
Owner

trampgeek commented Nov 14, 2022

Are you using jobeinabox with CodeRunner or in some other context? If the latter, I'd be interested to know about it.

Creating a permanently writable directory for matplotlib is one workaround but would open a security hole (students could share info via that directory) and would need a housekeeping task to clean up the contents after each run.

Our standard workaround for this problem within CodeRunner is the following prefix code (after importing os):

    if 'MPLCONFIGDIR' not in os.environ or os.environ['MPLCONFIGDIR'].startswith('/home'):
        import tempfile
        os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()

Our template executes that code prior to an exec of the student answer. I possibly should consider moving this code into Jobe somehow. As you've discovered it's a bit tricky to configure environment variables on Jobe, as the runguard program I use to execute code cleans the environment before the run to plug various potential security holes.

@jamboNum5
Copy link
Author

Hi Richard, we'll take a look at the fix you mentioned.

We have been testing jobeinabox with Coderunner on Moodle. Just some small customisations to get additional python modules into the container.

Thanks for the suggestion,
James

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

No branches or pull requests

2 participants