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

Create a default folder (for lite sessions #1518

Closed
juntyr opened this issue Nov 4, 2024 · 5 comments
Closed

Create a default folder (for lite sessions #1518

juntyr opened this issue Nov 4, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@juntyr
Copy link
Contributor

juntyr commented Nov 4, 2024

Problem

In my JupyterLite deployment, users commonly open the lab either to (a) open a new "session" (with fresh files), (b) to open existing files from a git repo (using litegitpuller) or URL (using jupyterlab-open-url-parameter). For these use cases, it is important to provide fresh sessions where old files don't clash with downloading new ones.

At the moment, I provide these fresh sessions by only using the memory storage driver, i.e. all changes are lost when the window is refreshed. However, this can of course lead to annoying losses of information.

I'm hoping to setup a lite session system that would function as follows:

  1. When a new tab is opened, the contents drive creates a fresh unique directory, e.g. /sessions/ or /sessions/
  2. The file browser UI navigates to this directory by default
  3. Any upload e.g. by the above mentioned extensions also place their contents into this directory
  4. I use persistent storage drivers so that old session directories exist even after a window reload
  5. The user is of course free to rename the session directories as they please

Proposed Solution

Would it be possible to create a fresh directory when a new browser tab with JupyterLite is opened? This is probably relatively easy since the upload extensions already hook into the contents API.

Would it be possible to create this directory before any other contents extension runs?

Would be possible for the upload extensions to use this new "default" directory?

@juntyr juntyr added the enhancement New feature or request label Nov 4, 2024
@juntyr
Copy link
Contributor Author

juntyr commented Nov 8, 2024

I experimented a bit myself and tried to implement the first part, the creation of a fresh session folder on startup. The folder creation works, though the navigation to the folder fails:

https://github.com/juntyr/a-jupyterlab-session/blob/2126808533c46c7a8a14700218ea06a639fdd359/src/index.ts#L52C5-L56C8

with the popup Could not find path: tree/<date>-<time>-<uuid> (or sometimes with a command execution error that the filebrowser:open-path command is not yet available).

Do you have any tips on how to avoid the race condition and where my bug might be?

@jtpio
Copy link
Member

jtpio commented Nov 9, 2024

Would it be possible to create a fresh directory when a new browser tab with JupyterLite is opened? This is probably relatively easy since the upload extensions already hook into the contents API.

Yes this should be doable via an extension.

Would it be possible to create this directory before any other contents extension runs?

This may be more difficult, as there may not be a hook to indicate in which phase the contents manager is currently in. Most extensions will sit at the same level.

Would be possible for the upload extensions to use this new "default" directory?

"Upload" should normally upload files to the current directory?

@jtpio
Copy link
Member

jtpio commented Nov 9, 2024

Otherwise, wondering if this could be a good use case for a custom drive? By implementing a Contents.IDrive, you could decide how your drive behaves more easily.

A while ago I started https://github.com/jupyterlab-contrib/jupyterlab-browser-storage to look into moving the default JupyterLite contents manager to a drive extension, so it's more flexible. Maybe this extension could serve as inspiration for your use case?

@juntyr
Copy link
Contributor Author

juntyr commented Nov 10, 2024

Otherwise, wondering if this could be a good use case for a custom drive? By implementing a Contents.IDrive, you could decide how your drive behaves more easily.

A while ago I started https://github.com/jupyterlab-contrib/jupyterlab-browser-storage to look into moving the default JupyterLite contents manager to a drive extension, so it's more flexible. Maybe this extension could serve as inspiration for your use case?

Would it be possible to create a fresh directory when a new browser tab with JupyterLite is opened? This is probably relatively easy since the upload extensions already hook into the contents API.

Yes this should be doable via an extension.

Would it be possible to create this directory before any other contents extension runs?

This may be more difficult, as there may not be a hook to indicate in which phase the contents manager is currently in. Most extensions will sit at the same level.

Would be possible for the upload extensions to use this new "default" directory?

"Upload" should normally upload files to the current directory?

Thank you for your help!

@juntyr
Copy link
Contributor Author

juntyr commented Nov 10, 2024

Otherwise, wondering if this could be a good use case for a custom drive? By implementing a Contents.IDrive, you could decide how your drive behaves more easily.

A while ago I started https://github.com/jupyterlab-contrib/jupyterlab-browser-storage to look into moving the default JupyterLite contents manager to a drive extension, so it's more flexible. Maybe this extension could serve as inspiration for your use case?

In the long term, du classing the JupyterLite contents drive would be the way to go. But I think I’ll wait until JupyterLite switches to this more modular approach first - right now I’m just trying to hack something together ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants