-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
Replace SAGE_TMP by the system location in the sage library #33213
Comments
comment:1
I've posted a work-in-progress branch that raises a question. The python docs, https://docs.python.org/3/library/tempfile.html state that, in regards to a named temporary file,
So in many cases, where I would have liked to have done
I have instead done something like
or
to avoid the Last 10 new commits:
|
Commit: |
This comment has been minimized.
This comment has been minimized.
Branch: u/mjo/ticket/33213 |
Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:
|
comment:4
Making #8784 a dependency because we can avoid many contortions on this branch if we don't have to keep sage-cleaner aware of where the |
Dependencies: #8784 |
This comment has been minimized.
This comment has been minimized.
comment:5
How did you solve the problems that sage-cleaner solves? It's not like I wrote it for no reason. There are many situations in practice that people hit where temp files and subprocess get left around. Make sure that at least the following works:
What happens? Are all temp files and spawned processes properly cleaned up? It's an unfortunate reality that we make Cython relatively easy to use, hence it's easy from the command line or notebook to segfault a running Sage process. Just curious. I never liked or wanted to write sage-cleaner, but I couldn't think of any better approach to make end users happy. |
comment:6
Replying to @williamstein:
For (2) to be an issue, you have to launch a standalone process that never terminates, detach it from the parent, compile a C extension, load the extension into your current session, and then cause it to segfault. I don't think cleaning up after that situation should be the responsibility of any application; but especially not of a computer algebra system. If you intend to do something like that frequently (or host a service for users who will...), there are better solutions these days -- cgroups on linux being the best example. Keeping in mind that sage-cleaner works by parsing a |
comment:7
I should also point out that it's not critical that we remove sage-cleaner at this point. The main hurdle wrt the removal of I saw this as a good time to remove it because its one crucial job -- to clean up |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:9
I believe I've fixed all of the test failures so I'm setting this to |
comment:10
testing on https://github.com/sagemath/sagetrac-mirror/actions/runs/1864348438 |
comment:11
Thanks @orlitzky for your explanation. Your responses don't necessarily apply in the context of users that got me to write the sage-cleaner in the first place, and they will probably be pretty annoyed if they ever realize what happened. Sage is different than some more less complicated computer algebra software like Magma, because Sage much more frequently spawns subprocesses. Fortunately, over the years the number of subprocesses Sage spawns has been reduced due to writing and using C library interfaces instead of pexpect, etc. Regarding /tmp, unless you specifically set something up to periodically clean up files, unless things have changed a lot, don't most Linux distros not automatically delete files from there, possibly until a reboot? You're making a huge change from "temp files get cleaned up by Sage itself quickly" to "maybe someday the system will clean them up". Maybe at this point that is the right change, but it's important to acknowledge that it is a significant change. I agree that when users are using Linux, have sufficient privileges to use containers, and also actually know how to use them, then these same problems can be solved in a more robust way. However, this is a small percentage of users of Sage. Many users use other operating systems or don't have admin permissions. CoCalc is the main platform for running Sage that I care about these days, and every individual "project" is its own container, /tmp is extremely ephemeral, etc., so everything you say applies there. That said, users of CoCalc can't use Docker or other container mechanisms themselves within projects, due to security constraints. In any case, I'm not personally worried about these changes having any adverse impact for me. However, I'm leaving this comment here so people who are impacted can maybe know they may have to revert these patches for their own install of Sage. Probably the way things will go is that this gets merged, and a year later certain environments start finding that Sage is leaving around clutter in a way that Sage didn't for the last decade, but users don't know why. Hopefully they google and find this comment. |
comment:12
Replying to @williamstein:
Systemd comes with a timer (like a cron job) to clean up On systems like mine, "leftover junk" is a fair criticism, but keep in mind the bigger picture: the python If this gets merged, we can deprecate |
comment:13
indeed, I am not at all worried about junk left at I am a bit puzzled by the need to manually keep them open using |
comment:14
Replying to @dimpase:
If you're referring to my new code (in many doctests), then this is simply a precaution for cygwin (see comment:1). I would love to simplify it if someone with a cygwin installation says that the "on Windows" warning doesn't apply there. |
comment:15
Replying to @orlitzky:
(If it DOES apply on cygwin, we could improve this in the future by updating the functions that now take a filename to also accept an open file handle; that will avoid re- |
comment:16
Cygwin is POSIX emulator, so |
comment:17
Replying to @dimpase:
You have two wishes remaining =) I'm "happy" to go back and change all of those doctests, but I'd like confirmation before I spend half a day doing it. |
comment:87
Is it still on top of #33829? |
comment:89
I haven't reviewed the changes on the ticket. The parts that I was able to review have been split out to separate tickets. |
Work Issues: Rebase on top of the dependencies |
Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:
|
Changed work issues from Rebase on top of the dependencies to none |
Changed branch from u/dimpase/ticket/33213 to |
comment:96
The branch includes a rebased version of #32716 |
Changed commit from |
comment:97
Follow-up discussion in https://groups.google.com/g/sage-devel/c/jpwUb8OCVVc |
comment:98
Follow-up ticket: #34593 |
This is a followup to sagemath#33213. Some users prefer (or need) to control where temporary files are created, and we should document this: - as described at https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir, users can set the environment variable `TMPDIR` Possible follow-up: - Also, according to https://manpages.ubuntu.com/manpages/bionic/man8/tmpreaper.8.html, at least on some systems it would be helpful to create a non-writable file `.tmpreaper` in the directory to prevent the system from doing automatic cleanup on it. URL: https://trac.sagemath.org/34593 Reported by: jhpalmieri Ticket author(s): John Palmieri Reviewer(s): Matthias Koeppe
<!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Remove code deprecated in - sagemath#32987 (2022) - sagemath#33213 (2022) - sagemath#29869 (2020) - sagemath#17815 (2020) - sagemath#29892 (2020) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37868 Reported by: Matthias Köppe Reviewer(s): Michael Orlitzky
Re: https://groups.google.com/g/sage-devel/c/zhjl_j6j_Qc
These days, using a
SAGE_TMP
that by default lives under$HOME
is overly complex and often inefficient. In this ticket we implement the first phase of its removal, to be replaced by python'stempfile
module. Specifically,SAGE_TMP
within the sage library and doctests.tmp_dir()
andtmp_filename()
to use thetempfile
defaults.SAGE_TMP
.Afterward, the custom functions
tmp_dir()
andtmp_filename()
can be deprecated in favor oftempfile.TemporaryDirectory()
andtempfile.NamedTemporaryFile()
.Moreover when #8784 is done, we'll be able to remove sage-cleaner entirely.
Depends on #33829
Depends on #33790
CC: @slel @tscrim @kiwifb
Component: misc
Author: Michael Orlitzky
Branch:
d94a1e6
Reviewer: Matthias Koeppe, Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/33213
The text was updated successfully, but these errors were encountered: