Carnets icon indicating copy to clipboard operation
Carnets copied to clipboard

"Saving As" is problematic

Open LucasSchelkes-BA opened this issue 10 months ago • 15 comments

Thank you for this amazing app!! ❤️

After reading through some other issues on the topic of saving notebooks, here are some oddities I've observed:

Opening the app for the first time brings the user to the "Carnets plus - history" file list. From there, the user intuitively clicks the "+" button at the top to create a new notebook. Saving this notebook with Menu->File->SaveAs gives a path "private/var/mobile/Library/Mobile Documents/iCloud~AsheKube~Carnets/Documents/", to which a name e.g. "test.ipynb" can be appended. This results in a Dead Kernel warning. After trying to restart the kernel, it's a mystery as to where the notebook is actually saved. When I search for it using the file manager all, I can't seem to find it "On my iPhone" or on "iCloud Drive". Also, it doesn't show up in the "Carnets plus - history" file list. When repeating this process with the same file name however, it says that the file already exists and asks whether it should overwrite it. So, there are two oddities here: where is the file saved and why is there always a dead kernel message when trying to "save as"?

The other option, when opening the app is to click on the "Browse" tab at the bottom and then either selecting "On my iPhone" or "iCloud Drive". In both cases there are 2 ways to open a new notebook: the "create document" button or the "+" button at the top, both seem to work interchangeably.

In the first case of the "iCloud Drive" the message appears "Carnets-sci does not have access to the directory around this notebook". However, the button to grant read and write access through the "unlock directory button" is not visible, which means that saving is not possible as it would result in an error. At least an "Untitled.ipynb" is created in the iCloud-Drive path and visible via the file manager, and it can be renamed from there, into e.g. "test2.ipynb". Saving any content seems to work, however when trying to save the notebook with "Save as" gives the relative path "private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/", but appending "test2.ipynb" to the end of it results in the error that writing is not permitted:

Traceback (most recent call last): File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/tornado/web.py", line 1713, in _execute result = await result ^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/tornado/gen.py", line 776, in run yielded = self.gen.throw(*exc_info) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/services/contents/handlers.py", line 240, in put yield maybe_future(self._upload(model, path)) File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/tornado/gen.py", line 769, in run value = future.result() ^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/tornado/gen.py", line 234, in wrapper yielded = ctx_run(next, result) ^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/services/contents/handlers.py", line 152, in _upload model = yield maybe_future(self.contents_manager.new(model, path)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/services/contents/manager.py", line 421, in new model = self.save(model, path) ^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/services/contents/largefilemanager.py", line 44, in save return super().save(model, path) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/services/contents/filemanager.py", line 485, in save if is_hidden(os_path, self.root_dir) and not self.allow_hidden: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/utils.py", line 194, in is_hidden if is_file_hidden(abs_path): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/containers/Bundle/Application/323631AF-23B8-45A1-BCAE-3A301BAD4148/Carnets-sci.app/Library/lib/python3.11/site-packages/notebook/utils.py", line 148, in is_file_hidden_posix stat_res = os.stat(abs_path) ^^^^^^^^^^^^^^^^^ PermissionError: [Errno 1] Operation not permitted: '/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/test2.ipynb'

Where is the button to grant access here? And why does it seem to work when simply saving the notebook and renaming it via the file manager?

In the second case of the "On my iPhone" option, when creating a new notebook the same read and write access warning appears as described above, with the same results, as the unlock button is not findable. However, when selecting the "Carnets plus" directory (btw strangely it says it contains 5 objects where there are just 2 notebook files in it.. are there maybe hidden objects?!) and then creating a new notebook inside of it, the "Save as" now gives the path "private/var/mobile/Containers/Data/Application/699C5A6D-5425-44ED-8FAE-6E17830ED75A/Documents/" and appending "test3.ipynb" to it let's the kernel die once again, but at least the file is written into the path without write access problems. So here the problem is the dying kernel. This would be my preferable way of working in notebooks (Is this also your recommendation of best-practice @holzschu?) because saving seems to work and the files are locatable. I can live with the dying kernel, even though it's annoying. Btw, the kernel also dies when selecting Menu->File->Rename. But this is not really a huge problem, as simply tapping the save button works flawlessly and does not let the kernel die - and this action is done much more often than "saving as".

Of course there are other options of "saving as" (e.g. Dropbox), but I didn't investigate these.

I'm curious if this helps anyone spot bugs or find a good and stable way to work. These are just my observations of using this fantastic app as a newbie. Thanks again for this great contribution @holzschu !!! 🚀

LucasSchelkes-BA avatar Aug 21 '23 14:08 LucasSchelkes-BA