Custom project extension

Dear community,

I am working on an extension to support the concept of “project” in jupyterlab, then
I have one extension to handle the contents on the filemanager that is able to give the next json
{"name": "Test", "path": "SWAN_projects/Test", "last_modified": "2020-11-02T09:54:52.128792Z", "created": "2020-11-02T09:54:52.136792Z", ]"content":... "format": "json", "mimetype": null, "size": 4096, "writable": true, "type": "project"}
you can see that the type is “type”: “project”.

The filebrowser in jupyterlab ofcourse is not able to open this folder as a directory, becuase type project does not means nonthing yet.

I need to write another lab extension to support this type “project”, where “project” is basically a folder with a hidden file .swanproject.

My question is how can I tell to jupyterlab that type project is a folder?

In the next image, you can see:

  1. (left) filebrowser where those folders type “project” looks like files ex: Test, Tes2 etc…
  2. (right) when I am clicking I am getting the error “SWAN_projects/Test is a project, not a file”

The url produced in the in API is

where for some reason type is file and not project.

Any advise to handle this?

Thanks in advance!

Could you please explain what a swan project is? Is it something generated by a tool, or something you’ve created?
What are you trying to achieve with this? Do you want to display a specific interface using the content of the Swan project folder?

I think you could ‘bypass’ the folder issue by packaging your project. So instead of having a folder, the filebrowser would see a .tar for example. Maybe you’ll have to rename it to your own extension so it doesn’t clash with existing renderers.
You would have to create a mime renderer extension, so clicking on the package from the file explorer would make Jupyter Lab start it and allow you to run some code.

Another way of dealing with this could be to create a brand new extension, sitting in the sidebar on the left, used to only navigate swan projects (so a file explorer for swan projects only).

Hello Remborg,

thank you for your reply :smiley:

  1. The SWAN project is just a folder with a hidden file .swanproject,
    in the .swanproject file, we save some configuration for the user, for example, the software stack and kernels available for that software stack.
    Why? in CERN we need to provide software for different experiments like CMS, Atlas, Alice, …
    every experiment requires a different environment, then when the user is creating a new project we are saving the parameters to display the right information in the launcher.
  2. We already have the launcher that supports two profiles
  • in the image on the left, our launcher outside of a project
  • in the image on the right, our launcher inside a project displaying the kernels

related to tar file, the user project is not a file and we would like to have it like a “special folder”.

The thing is, we need to know when we are inside the project, for that our extension SwanContents is returning the JSON file in the API.

`{"name": "Test",  "path": "SWAN_projects/Test",  "last_modified": 
"2020-11-02T09:54:52.128792Z",  "created": 
"2020-11-02T09:54:52.136792Z",  ]"content":...  "format": "json",  
"mimetype": null,  "size": 4096,  "writable": true,  "type": "project"}`

with type = project instead of a directory, but we need to let know to jupyterlab that project is a directory and you can access it in the file browser.

do you think then we need to create our file browser? or can we use the current one just passing some extra parameters in some specific extensions, to let it know that project is a directory?

1 Like

Thanks for the details. I don’t really understand what should happen when you open a project directory from the filebrowser, but I understand that you need to see the content of the project and so a tar file won’t work.
I don’t know if that’s possible to add new type to the filebrowser and be seen as a directory, but I doubt it.

Maybe you could return "type":"directory" instead? The API could return a slightly modified JSON with another attribute so you know when it’s a Swan project. It’s not ideal since you would have a JSON response that’s not normalised anymore so maybe you could use a custom mimetype (be careful though, I’m not aware of the side effects this could have, I personally wouldn’t use it).
I know it’s all very hacky…

If you need to trigger an action when opening the folder, then maybe in your launcher extension you could listen to the filtebrowser changes (I don’t know if that’s possible, maybe with the core tokens?).

I think your best option would be a custom filebrowser (or a fork of the original one).

Hi Remborg,

we decide to take your suggestion, the type will be directory and we are going to add a new key in the JSON.

Thank you so much for your help,
Best Regards

I think @Remborg has some very good suggestions.

Looking at the rest api (, another longer-term approach that would help the community might be to work on adding a separate metadata field to file/directory responses that provides a place for file or directory-specific metadata. This metadata could come from the server and just be threaded through the system to be available to whoever needed it. It would mirror how filesystems can store lots of metadata about a file besides the content of the file.