Skip to content

Small updates#3

Open
PeterSomkuti wants to merge 4 commits intoUS-GHG-Center:chuckwondo/julia/retrievaltoolkit-dockerfrom
PeterSomkuti:small_updates
Open

Small updates#3
PeterSomkuti wants to merge 4 commits intoUS-GHG-Center:chuckwondo/julia/retrievaltoolkit-dockerfrom
PeterSomkuti:small_updates

Conversation

@PeterSomkuti
Copy link
Copy Markdown

I've added/modified the following:

  • minimal notebook file to make the precompile/build step within Jupyter (not sure why it's needed, but it is)
  • I made the two repos public now and they are added here
  • download the JulioMono font, which makes some text renderings in plots much nicer

Again - tested this in my local machine, but not yet on the hub.

Dockerfile Outdated
RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/US-GHG-Center/RetrievalToolbox.jl");'

# Add the demo notebook
RUN git clone https://github.com/US-GHG-Center/IWGGMS21-Demo ~/IWGGMS21-Demo
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Recall that we cannot put thing into the home dir. That's part of the issue we're having to deal with. Nothing placed into the home directory shows up in the hub sessions.

Does this demo repo need to be in the home dir? If so, then you simply need to clone it after your initial hub session starts.

Anything you place in your home directory during a hub session will remain in your home directory from session to session. We simply cannot populate the home directory during building of the image.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The idea for this image is that users at the conference can dig straight in, there should be no additional user commands needed to get into the notebook and execute the cells in the demo.
The location of the repo (I think) is not important; ideally the users thrown into this will see the opened notebook already. I'll investigate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@PeterSomkuti we're going to achieve that through Binderhub launch link, not via the docker configuration. The Docker just needs the right environment. If the notebook repo is now public we should move this dockerfile into that repo and test with Binder.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@wildintellect I can move the Dockerfile (and the additional files needed) to the IWGGMS21-Demo repo. Does the Binder environment keep the AWS credentials as present in the "other" environment? The demo currently pulls the 3 big files from the S3 bucket right at the start.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes bucket access should work.

Dockerfile Outdated
Comment on lines +103 to +109
RUN <<EOT
curl -OL https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz
mkdir ~/.fonts
cd ~/.fonts
tar -xvzf ~/JuliaMono-ttf.tar.gz
rm ~/JuliaMono-ttf.tar.gz
EOT
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Again, we cannot place anything in the home dir. I suggest determining where else you can install fonts in the system so that they can be discovered. This may also require moving this block before the line USER ${NB_USER}, as I suspect installing fonts in some recognized system location may require root permissions.


# Run the precompile/build within Jupyter (somehow that is necessary)
COPY precompile_build.ipynb ./
RUN jupyter execute precompile_build.ipynb && rm precompile_build.ipynb
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do you need a notebook file to do this? Won't the following work?

RUN julia -e 'using Pkg; Pkg.precompile(); Pkg.build();'

That's similar to what I added only a few lines above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I couldn't find out the reason why this is needed, but I'm not the only one seeing this link. The tiny notebook seems to solve the problem, though. Without this, another precompilation is triggered when users load any modules from a fresh session, so this cuts down the initial runtime of the whole demo notebook quite significantly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm trying to see this impact, but can't. We can keep this for now, but I would like to explore this a bit more later, because I suspect there's a better way to address this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this file is necessary. See my comment in the Dockerfile about adding the command there.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This step is required: one can easily test this by spawning a new session with custom image from chuckwondo/julia/retrievaltoolkit-docker and then typing using Plots in a notebook (not from the REPL!). One is greeted with an error related to "world age", that must be fixed through re-compilation within a notebook (though I do not know why), and this little notebook takes care of that.

Dockerfile Outdated
Comment on lines +35 to +36
# Comment Peter: this is no longer necessary, I fixed my repo
# git -C xrtm reset --hard b3aeace
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice to see you fixed your repo. You can remove these comment lines.

Suggested change
# Comment Peter: this is no longer necessary, I fixed my repo
# git -C xrtm reset --hard b3aeace

@PeterSomkuti
Copy link
Copy Markdown
Author

PeterSomkuti commented May 20, 2025

@chuckwondo
Made some updates that move the git clone operation and the fonts into /opt; and while the image builds successfully, the NOTEBOOK_ARGS environment variable does not seem to work as intended (it does on a local run).
The idea is that for this image, the work directory will be /opt/IWGGMS21-Demo so that users only see the one notebook file when they run this. Is this achievable with the US-GHG-Center configuration at all?

Dockerfile Outdated
EOT

# Add the RetrivalToolbox package
RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/US-GHG-Center/RetrievalToolbox.jl");'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's just add Pkg.add(url="https://github.com/US-GHG-Center/RetrievalToolbox.jl"); to the preceding julia command. No need to use 2 separate julia commands. Combining with the other will also avoid needlessly adding another layer to the Docker image.

Dockerfile Outdated
Comment on lines +105 to +107
# Add the demo notebook into /opt/IWGGMS21-Demo
USER root
RUN git clone https://github.com/US-GHG-Center/IWGGMS21-Demo /opt/IWGGMS21-Demo && chown -R jovyan /opt/IWGGMS21-Demo
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to switch back to root again. Simply move this git clone command up in the file, right after the block dealing with xrtm, before switching to NB_USER, since the root user will already be the current user.

Also, use ${NB_USER} instead of hard-coding jovyan.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can also use git clone --depth 1 ... to reduce space requirements, unless you expect users to commit changes to the repo.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And the same can be done on the clone of the xrtm repo as well.

Dockerfile Outdated
RUN git clone https://github.com/US-GHG-Center/IWGGMS21-Demo /opt/IWGGMS21-Demo && chown -R jovyan /opt/IWGGMS21-Demo

# Run the precompile/build within Jupyter (somehow that is necessary)
USER ${NB_USER}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to switch back to NB_USER once you remove the preceeding USER root line, based upon my preceding comment.


# Run the precompile/build within Jupyter (somehow that is necessary)
COPY precompile_build.ipynb ./
RUN jupyter execute precompile_build.ipynb && rm precompile_build.ipynb
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm trying to see this impact, but can't. We can keep this for now, but I would like to explore this a bit more later, because I suspect there's a better way to address this.

Dockerfile Outdated
ENV NOTEBOOK_ARGS=/opt/IWGGMS21-Demo/IWGGMS-demonstration.ipynb

# Clean up conda cache to reduce image size a little bit
RUN conda clean --all -f -y
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No sense in adding another layer to the image. Please just add this conda command up into the RUN block near the top of the file, where the other conda command is. Reducing the number of layers also helps reduce image size.

Dockerfile Outdated
# NOTEBOOK_ARGS set to this path will cause the Jupyter Lab environment
# to start in this folder, so users will see only this Notebook and thus
# know which one to use.
ENV NOTEBOOK_ARGS=/opt/IWGGMS21-Demo/IWGGMS-demonstration.ipynb
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's move this up where the rest of the ENV directives are at the top of the file.

Comment on lines +19 to +26
# Download and install JuliaMono font for good rendering of plotting text
RUN <<EOT
curl -OL https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz
cd /usr/share/fonts
tar -xvzf /opt/JuliaMono-ttf.tar.gz
rm /opt/JuliaMono-ttf.tar.gz
chmod ugo+r /usr/share/fonts/*
EOT
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Download and install JuliaMono font for good rendering of plotting text
RUN <<EOT
curl -OL https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz
cd /usr/share/fonts
tar -xvzf /opt/JuliaMono-ttf.tar.gz
rm /opt/JuliaMono-ttf.tar.gz
chmod ugo+r /usr/share/fonts/*
EOT
# Download and install JuliaMono font for good rendering of plotting text
RUN <<EOT
#!/bin/bash
set -e
fonts_dir=/usr/share/fonts/truetype/julia
curl -OLs https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz
mkdir -p "${fonts_dir}"
tar -xzf JuliaMono-ttf.tar.gz -C "${fonts_dir}"
rm JuliaMono-ttf.tar.gz
EOT

@PeterSomkuti
Copy link
Copy Markdown
Author

Re-shuffled the Dockerfile, not tested in the US-GHG-Center jhub environment which seems to be different enough that the NOTEBOOK_ARGS env variable does not do what it's supposed to. Any ideas to sort this out?

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