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

Dashboard service: with mechanism for notification of new saves #6

Closed
nikochiko opened this issue Nov 14, 2022 · 6 comments
Closed

Comments

@nikochiko
Copy link
Contributor

nikochiko commented Nov 14, 2022

It should have two endpoints:

  • A webhook that should be hit when a file is saved
    • Data should have:
      • which user performed the save
      • the filesystem path of the notebook
    • The service will then figure out how to use this information
  • An endpoint that will return which notebook was the last to be saved and when.
    • This can be polled to figure out if there has been a new change.

Webhook:

> POST /events/save
> {
>    "user": "alice",
>    "path": "/home/alice/module1-day1.ipynb",
> }
>
...
< 200 OK

Polling endpoint:

> GET /events/save/module1-day1  # /events/save/{path/to/file/after/home} ?
>
...
< 200 OK
< {
<     "timestamp": "2022-11-14T06:19:03Z",
<     "user": "alice"
< }

Jupyterhub services reference: https://jupyterhub.readthedocs.io/en/stable/reference/services.html

@anandology
Copy link
Member

Here is my suggestion for the API:

Create event:

POST /events

{
    "type": "save-notebook",
    "user": "alice",
    "filename": "module1-day1.ipynb"
    "path": "/home/alice/module1-day1.ipynb"
    "timestamp": "...""
}
---
200 OK / 201 Created

{
    "id": 4,
    "type": "save-notebook",
    "user": "alice",
    "filename": "module1-day1.ipynb"
    "path": "/home/alice/module1-day1.ipynb"
    "timestamp": "...""
}

List events:

GET /events
---
200 OK

[
  {
    "id": 4,
    "type": "save-notebook",
    "user": "alice",
    "filename": "module1-day1.ipynb"
    "path": "/home/alice/module1-day1.ipynb"
    "timestamp": "...""
  },
  ...
]

Listing events may also support filtering.

GET /events?user=alice
GET /events?user=alice&filename=day1.ipynb
GET /events?filename=day1.ipynb

@nikochiko
Copy link
Contributor Author

What would filename be for /day1/module1.ipynb vs /day2/module1.ipynb, for example?

@nikochiko
Copy link
Contributor Author

Would GET events also support order by and limit operations?

@nikochiko
Copy link
Contributor Author

nikochiko commented Nov 14, 2022

I don't think we should persist all events. It would add complexity without having a use case for us.
Maybe we could set a key from the client, and the server would update an item if the given key already exists.
So,

POST /events
{
    "type": "save-notebook",
    "key": {
        "user": "alice",
        "path": "/home/alice/module1-day1.ipynb"
     },
     "data": {
        "user": "alice",
        "path": "/home/alice/module1-day1.ipynb",
        "timestamp": "..."
        "filename": "module1-day1.ipynb"
      }
}
--- 
200 OK / 201 Created
{
    "id": ...,
    "type": ...,
    "key": ...,
    "data": ...,
}

Querying could be same as suggested.

What do you think?

@anandology
Copy link
Member

anandology commented Nov 14, 2022 via email

nikochiko added a commit that referenced this issue Nov 14, 2022
This commit adds a 'Dashboard' JupyterHub service. When deployed,
it can be viewed http://hub.example.com/services/dashboard.
This commit also adds a change to install pip during the setup
process. This is later used by the service's launch script to
install dependencies. Issue: #6
@nikochiko
Copy link
Contributor Author

Added in this commit: 8c559c2
It uses just a list for now but we can make it a database later.

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

No branches or pull requests

2 participants