Skip to content

Conversation

@edan-bainglass
Copy link
Member

@edan-bainglass edan-bainglass commented Apr 1, 2025

This PR reimplemented aiidalab-timer as a core feature of AiiDAlab instead of an app.


Jupyter provides entry points to customize notebook JS and CSS (see here for old, but as far as I can tell, still valid docs). Following this approach, the PR introduces under lab/countdown/ the following:

  • custom.js - a script implementing the countdown timer, applying it consistently throughout AiiDAlab
  • custom.css - styling the countdown-related DOM as a sticky banner above the native navbar
  • config.json.template - a template with an opt-in toggle and a lifetime variable, to be read by custom.js

The PR also introduces a new script under before_notebook.d that runs on container creation and replaces config.json.template with config.json, applying the EPHEMERAL and EXPIRY environment variables, the latter computed from the opt-in LIFETIME environment variable (used by each deployment), and the former set to true if LIFETIME is present, false otherwise. This allows each deployment to opt-in and choose its own expiration.

Lastly, the PR updates the lab/Dockerfile to copy the necessary files to site-packages/notebook/static/custom/ and add the PYTHON_MINOR_VERSION environment variable required by the container-runtime script.


image

image

image

@edan-bainglass
Copy link
Member Author

Unclear as to why the test is failing. Seems unrelated, but surely I'm missing something.

@danielhollas
Copy link
Contributor

Unclear as to why the test is failing. Seems unrelated, but surely I'm missing something.

Please reopen the PR from origin, otherwise you won't have permissions to push to ghcr.io

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's wait a bit to see if there are standard way to get the remaining cull time, I asked in https://discourse.jupyter.org/t/how-to-get-the-remaining-cull-time-for-the-running-container/34244

I also not so sure this timeout should put in the aiidalab-docker-stack. Is the timeout only for qeapp? If so, probably the better solution is to set a k8s timeout there instead of using the cull time from jupyter server.
To make the container closed at exactly after it start 12h during the deployment to k8s I believe we can use activeDeadlineSeconds https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup

With that approach there is not much need to change with this PR, the JS/css still fit and can be used for deployment when the timeout is set.

I didn't review the js part (I can read but not qualified to review, and I refuse to learn js 😎 ), css part looks good.

Comment on lines +50 to +54
# Set up opt-in countdown feature
ARG PYTHON_MINOR_VERSION
ENV PYTHON_MINOR_VERSION=${PYTHON_MINOR_VERSION}
COPY --chown=${NB_UID}:${NB_GID} countdown/ ${CONDA_DIR}/lib/python${PYTHON_MINOR_VERSION}/site-packages/notebook/static/custom/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines were moved to here when we debug it together. Can you move it to where the logo.png is copied, and see if it still work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work due to the order of events I believe

@edan-bainglass
Copy link
Member Author

edan-bainglass commented Apr 1, 2025

let's wait a bit to see if there are standard way to get the remaining cull time, I asked in https://discourse.jupyter.org/t/how-to-get-the-remaining-cull-time-for-the-running-container/34244

I'm not sure I understand your concerns. Let's discuss in person.

I also not so sure this timeout should put in the aiidalab-docker-stack. Is the timeout only for qeapp? If so, probably the better solution is to set a k8s timeout there instead of using the cull time from jupyter server. To make the container closed at exactly after it start 12h during the deployment to k8s I believe we can use activeDeadlineSeconds https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup
With that approach there is not much need to change with this PR, the JS/css still fit and can be used for deployment when the timeout is set.

This is for any deployment of a temporary nature. General feature unrelated to any app.

I didn't review the js part (I can read but not qualified to review, and I refuse to learn js 😎 ), css part looks good.

The JS code is migrated mostly as is from aiidalab-timer and was already reviewed by @superstar54, who is of course welcome to give this another look 🙂

@edan-bainglass
Copy link
Member Author

edan-bainglass commented Apr 1, 2025

Relocating to #525 due to permissions

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

Successfully merging this pull request may close these issues.

3 participants