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

Use aiidalab wide logo in notebook interface #416

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions stack/lab/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ ENV NOTEBOOK_ARGS \
"--MappingKernelManager.cull_interval=300" \
"--TerminalManager.cull_inactive_timeout=600" \
"--TerminalManager.cull_interval=60"

# Set up the logo of notebook interface
COPY --chown=${NB_UID}:${NB_GID} aiidalab-wide-logo.png ${CONDA_DIR}/notebook-logo.png
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you put the logo in $CONDA_DIR? Isn't /opt/ a better place? Perhaps /opt/static/?

Copy link
Member Author

Choose a reason for hiding this comment

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

Could be, I'll use /opt, it is a temporary location, and I think it is better to use mv instead of cp.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't use /opt since I didn't run fix-permission. I use /tmp instead, so I can use mv to avoid

# the folder of logo.png is get by find "$CONDA_DIR/lib" -path "*/notebook/static/base/images/logo.png"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am very confused by this code. Why is this find necessary? Isn't the original logo always in the same path?

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't the original logo always in the same path?

Not exactly the path now is /opt/conda/lib/python3.9/site-packages/notebook/static/base/images/logo.png, thus also dependent on the python version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but we control the python version and it's value is available in the Dockerfile you only need to somehow get rid of the patch version.e.g 3.9.13 to 3.9, but I am assuming that should be possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did not manage to do it simply.

I can do:

RUN export PYTHON_VERSION_MAJOR_MINOR=$(python -c "import sys; print('python{}.{}'.format(*sys.version_info[:2]))") && \
    mv /tmp/notebook-logo.png "$CONDA_DIR/lib/$PYTHON_VERSION_MAJOR_MINOR/site-packages/notebook/static/base/images/logo.png"

But I don't think it is simple. If read from PYTHON_VERSION then the problem is it can be 3.9 or 3.9.13, so it is not easy to parse the <major>.<minor> from it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I add a comment to explain the usage of find, I assume the -exec is a common option to execute the command on the result of find command.

# copy the logo.png to the folder as logo.png
RUN find "$CONDA_DIR/lib" -path "*/notebook/static/base/images/logo.png" -exec cp ${CONDA_DIR}/notebook-logo.png {} \;
Binary file added stack/lab/aiidalab-wide-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.