-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Allow deleting non-empty directory when c.FileContentsManager.delete_to_trash = False #4916
Comments
One compelling usecase from jupyterlab/jupyterlab#835 (comment)
|
I can imagine one way to resolve this is to have a force flag in the rest api, like the |
I wanted to ping about this issue again. Is this something that maintainers might be willing to consider. This has ended up being a fairly significant problem for my use case (teaching non-sophisticated users in a JupyterHub deployment using git repositories for code distribution) due to hidden files that are very difficult to manually delete for non-sophisticated users. I'm in the process of reworking the JupyterHub deployment for the next academic year, and I would really like for the users to have an ability to delete a non-empty directory. Happy to provide any more details if needed! |
Has this been solved already?? |
Additional dialog box for confirmation, is what many other web UIs do. A flag for command line when we start the notebook server, would be a good solution as well. Would it be accepted if a PR is sent? It's a relatively simple patch for the filemanager.py code. I am actually surprised it is not a bug but a design decision. |
@Dmitry1987 If you put together a pull request, I am happy to help with any testing. I think the problem is that if there is a way to send files to trash (which is what #3108 seemed to be allowing) then you can delete non-empty directories. However, there is a bug in using Docker containers that use the Overlay-FS (see #3130) that means that in a Docker container, you need to set Again, I'm very happy to help with any testing/feedback if you put together a pull request! |
thanks for your suggestion @albertmichaelj I will try that setting to see if it works. |
Unfortunately, I have no idea what functions display dialogue boxes. If I had a better understanding of the notebook code base, I'd try a PR myself. Like I said, if I can help with testing, I'd be happy to. |
I tried the flag of
|
I guess the solution in my case would be just to patch the relevant file, and rebuild the notebook, each time in our CI, before it gets deployed. We run a CI that rebuilds kernels (the data team keeps a list of kernel names and the packages they'd like to have, so when they modify these files, we rebuild and redeploy it), so it can also patch the code after "pip install ..." of the notebook. But it'll need to be maintained alongside newer versions, and it's a pain to do every time. Maybe I can use the repo as a source instead of pip package, so it'll be patched by git command, can be a longer term solution (the patch will work for newer versions until there's a conflict in same file) |
@Dmitry1987 You need to set Hope that helps, but as for this issue, I still think that we should be able to delete folders that aren't empty with a dialogue box. |
thanks @albertmichaelj , I do use the docker versions, but I am running it on linux, if I set to "True" doesn't it look for windows trash bin only in windows related parts of the code? I'll try the "True" setting today and will post results, thanks :) |
No it doesn't work :( both True/False of this setting have no effect. I'll try to patch the relevant piece of code, will share results if I have a working solution. |
@dmikushin To be honest, I'm not sure what you're talking about. I can confirm that the following Dockerfile works fine (as in I can delete non-empty directories): ARG BASE_CONTAINER=jupyter/base-notebook:8e8cbd0a0af7
FROM $BASE_CONTAINER
RUN sed -i 's/c.FileContentsManager.delete_to_trash = False/c.FileContentsManager.delete_to_trash = True/g' /etc/jupyter/jupyter_notebook_config.py While the following does not allow me to delete non-empty directories: ARG BASE_CONTAINER=jupyter/base-notebook:8e8cbd0a0af7
FROM $BASE_CONTAINER
# RUN sed -i 's/c.FileContentsManager.delete_to_trash = False/c.FileContentsManager.delete_to_trash = True/g' /etc/jupyter/jupyter_notebook_config.py I build the containers as
or
This will allow you to delete folders. What issue are you running into? |
@albertmichaelj Wrong Dmitry @Dmitry1987 |
Sorry @dmikushin! |
Thanks for sharing @albertmichaelj . The relevant part of the dockerfile is this for example
So what runs inside is a vanilla 'notebook==6.0.0'. But the dialogue of "directory not empty" error gets displayed in both cases, with True/False of 'c.FileContentsManager.delete_to_trash' :( |
I inspected the image "jupyter/base-notebook:8e8cbd0a0af7" and saw my versions of all components are a bit older but not much. Also the fact it works in the original image with that config file, gives me a place to start investigation why it doesn't work in my custom image :) . |
I ended up patching the filemanager.py :) and it works great now. Just removed the send2trash and everything windows related, it solved the issue. Maybe a bad solution but couldn't find what else is different in my docker images, it was all same python content from "pip install notebook=6.0.3" 🤷 |
just in case someone wants to patch it same way:
this will do it (UI confirmation box still exists, asks whether you want to delete the folder, seems good enough to me). |
@Dmitry1987 I am in the process of updating my JupyterHub configuration, and I discovered that my fix that I gave you wasn't actually working when deployed. The docker container that I showed in #4916 (comment) works fine for deleting folders when I'm using docker on my local machine (a Mac), but when I deployed it to a kubernetes cluster (for JupyterHub on Kubernetes), I couldn't delete folders. For some reason, the config I ended up using the notebook argument This might be an easier path forward for you instead of patching the notebook files. |
the CLI flag is a good option, thanks for sharing 👍 |
@Dmitry1987 - I ended up writing this to get round the problem... https://github.com/edina/nb_empty_trash Set seems to be working for me (docker images in a k8s cluster) (but note, this is for classic notebook, not jupyterlab - but I'm sure someone could fork & adapt :) ) |
nice work @perllaghu , I hope it helps others who find this thread, our hacks and plugins :))) |
@Dmitry1987 Just an FYI, I ended up using your patch technique because I ran into another problem with having symlinks in the home folder to other mount locations. Thanks for the patch! |
@Dmitry1987 Thanks for the patch, I am interested as well. This is the patch for which file? |
Pinging on this issue again. Can someone please fix this? The original issue started in the Jupyter Lab repo 4 years ago (jupyterlab/jupyterlab#835) |
I got the same need here, i'll look if i can find something to fix that. |
|
This issue has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/jupyterhub-not-allowing-to-delete-non-empty-directory/8539/1 |
Any updates on this from anybody? Would it help to drop the undo - support and just delete the folder recursively after user confirmation? this solutions would be better that the current state where recursive deletion is impossible |
This issue has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/jupyterhub-singleuser-and-jupyter-server/10942/1 |
It looks like the issue can now be solved by setting a new parameter in Jupyter Server: Following the @albertmichaelj's example, I used a latest jupyter/base-notebook image with the above parameter and was able to delete the non-empty folders
|
@ktaletsk is right, as long as you are using the Server backend, which I think people should be doing now. So, I'm going to go ahead and close this issue. |
Question: are notebooks still using This solution if fine for most cases, however has a problem when one starts doing clever things with mounts... |
@perllaghu I think that it is using the |
Actually, it looks like this behavior may have been fixed in a pre-release beta of |
There has been a long standing issue at the Jupyter Lab repo around the inability to delete a non-empty directory (see comments jupyterlab/jupyterlab#835 (comment) and below for recent discussion). On some platforms (Mac OS for example), a non-empty directory can be deleted easily. However, on other platforms (including the official docker container
jupyter/minimal-notebook
), non-empty directories cannot be deleted. This appears to be an intentional design decision to not allow deletion of non-empty directories (see this code here).However, there are lots of legitimate cases to delete a non-empty directory, so a much better solution would be to ask for confirmation before deleting the non-empty directory. Failing that, there should be a config parameter that allows for the deletion of non-empty directories.
Unfortunately, I'm not equipped to do development on the notebook server, so I cannot produce a pull request myself. Is this an issue that the maintainers are willing to consider?
The text was updated successfully, but these errors were encountered: