Ask Your Question
3

temporary html files location in Sage 9.7

asked 2022-09-27 01:54:35 +0100

richardquint gravatar image

With Ubuntu now using a snap version of Firefox there is a a problem with using the ThreeJS viewer with Firefox or Chrome in recent versions of Sage. Firefox can't access folders outside of a user's home folders nor even in hidden folders within the user's home folders. For Sage 9.6 it was possible to work around this by setting the environment variable DOT_SAGE to be a non-hidden folder, e.g., export DOT_SAGE="~/Sage/sage-9.6/dotsage" (on my PC Sage is installed in ~/Sage/sage-9.6). If you use a non snap browser this isn't necessary, but I prefer to use the default browser with Ubuntu.

With Sage 9.7 just setting DOT_SAGE no longer works, since the output from show(viewer="threejs") is now saved to /tmp/tmp<something>/<something>.html. The html file is fine, just not accessible by Firefox. I've looked in the the Sage documentation and haven't found a way to set the output path for the html files. (I may just have not found it, but any guidance would be appreciated.)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2022-09-27 21:06:09 +0100

You should be able to set the environment variable TMPDIR to manage this. You can test by running this within Sage:

sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/var/folders/00/zrss7sdj3bzd23f2_gnspy2h0000gp/T/tmpojijqa_h'>

That is the result if I don't set TMPDIR. If I first do export TMPDIR=/Users/jpalmier/Desktop/temporary/ before starting Sage, then I see

sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/Users/jpalmier/Desktop/temporary/tmph25k47mi'>

I think this will only work if the directory already exists.

edit flag offensive delete link more

Comments

Just checked that this solution works for threejs graphics: in a Sage 9.7 console, running

sage: sphere()

creates a html file under TMP_DIR_FILENAME_BASE.

eric_g gravatar imageeric_g ( 2022-09-27 21:12:56 +0100 )edit

Thank you John.

richardquint gravatar imagerichardquint ( 2022-09-27 23:37:44 +0100 )edit

Thank you for the good question, and the solution should be documented somewhere. This is now being tracked at https://trac.sagemath.org/ticket/34593.

John Palmieri gravatar imageJohn Palmieri ( 2022-09-27 23:42:49 +0100 )edit
0

answered 2023-10-19 04:19:41 +0100

The answer that comes back is the same in all cases:

ImportError
Traceback (most recent call last) <ipython-input-5-0562399c9de5> in <module> ----> 1 from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE

ImportError: cannot import name 'TMP_DIR_FILENAME_BASE' from 'sage.misc.temporary_file' (/usr/lib/python3/dist-packages/sage/misc/temporary_file.py)

edit flag offensive delete link more

Comments

The answer that comes back from what? What version of Sage are you using, and what platform?

John Palmieri gravatar imageJohn Palmieri ( 2023-10-19 18:34:40 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-09-27 01:54:35 +0100

Seen: 283 times

Last updated: Sep 27 '22