Skip to content

chore: fix r profile#269

Open
bryanpaget wants to merge 10 commits into
betafrom
bryan-rprofile
Open

chore: fix r profile#269
bryanpaget wants to merge 10 commits into
betafrom
bryan-rprofile

Conversation

@bryanpaget
Copy link
Copy Markdown
Contributor

@bryanpaget bryanpaget commented May 12, 2026

Fixes the R Profile generation by replacing unreliable regex with robust regex.

jira: https://jirab.statcan.ca/browse/ZONE-465

@bryanpaget bryanpaget changed the title Bryan rprofile chore: fix r profile May 19, 2026
@bryanpaget bryanpaget marked this pull request as ready for review May 19, 2026 17:26
# Simple validation to prevent broken URLs
if [ -z "$R_VERSION" ] || [ -z "$UBUNTU_CODENAME" ]; then
echo "Error: Failed to detect environment variables for R profile."
exit 1
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 a little bit concerned about doing an exit 1 here when it fails to get the r version or ubuntu version, as this would prevent the pod from spinning up completely.
If someone is only using python in their notebook for example, a failing R setup shouldn't prevent them from using their notebook.

I'm thinking that it may be more safe to do an if..else here? Like

if [ -z "$R_VERSION" ] || [ -z "$UBUNTU_CODENAME" ]; then
    echo "Error: Failed to detect environment variables for R profile."
else
    PPM_URL="https...."
    ....
fi

That way, we at least log the problem and we have a trace of it when debugging if an error occurs, but it won't prevent the pod from starting.

But I am open to your thoughts on this!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea.


PPM_URL="https://${serviceaccountname}:${serviceaccounttoken}@artifactory.cloud.statcan.ca/artifactory/zone-r-ppm-bin-${UBUNTU_CODENAME}-${R_VERSION}-remote"

cat >> /opt/conda/lib/R/etc/Rprofile.site << EOF
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 noticed you changed the command from a cat > to cat >> command, which means this now appends to the file instead of overwriting the file.

I don't see an immediate issue with this since this file should not be on persistent storage, so it should be resulting the same (and I tested with a notebook restart to confirm this). And this keeps our start up script a bit cleaner by avoid having to re-write the "plot_mimetypes" line.
I just wanted to comment on this point, I am not asking for a change here unless you feel the need to revert back.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

During my testing, I realized we already had an Rprofile.site, so I wanted to append to it rather than just overwrite it.

Copy link
Copy Markdown
Collaborator

@mathis-marcotte mathis-marcotte left a comment

Choose a reason for hiding this comment

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

LGTM

Tested on artifactory.cloud.statcan.ca/das-aaw-docker/jupyterlab-cpu:1a3b17065fa35de39f03eb47bd2733d0918cd424

Was able to successfully install an R package with install.packages("janitor") (using R studios)

@github-actions github-actions Bot added the ready for beta Sets the PR as ready to be merged to the beta branch label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for beta Sets the PR as ready to be merged to the beta branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants