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

Create improved dev container configuration #43

Closed
8 of 11 tasks
lucyb opened this issue Apr 15, 2024 · 8 comments
Closed
8 of 11 tasks

Create improved dev container configuration #43

lucyb opened this issue Apr 15, 2024 · 8 comments
Assignees
Milestone

Comments

@lucyb
Copy link

lucyb commented Apr 15, 2024

Based on the investigation done in #9.

Our aim is to provide a Codepsaces environment that's ready to go for researchers using Python or RStudio to write code for the OpenSAFELY pipeline.

This configuration will provide a development environment for researchers containing:

  • Python 3.10
  • The equivalent Python packages based on the Python Action image, including ehrql
  • R 4.0.5
  • RStudio
  • The equivalent R packages based on the R Action image.

We are not expecting to support work done outside of the OpenSAFELY pipeline or analyses done in Stata. We will provide only limited support for older studies, as we're aiming our efforts currently towards newer users.

This configuration will be used to create Codespaces by researchers, so it should be tested out by several researchers before it can be considered complete.

It does not need to particularly fast, but does need to be fast enough to reasonably use. This means we'll need to build a Docker image and upload it to ghcr, rather than build an image on each Codespace start up. As part of this ticket, we should consider how we're going to version changes to both the Docker image and the other devcontainer configuration. For example, we could agree to avoid referencing the "latest" tag by default and start with a v1. EDIT: we'll do this in ticket x.

We should consider how we'll release this update to the research-template repo to new and existing users. We may want to script the creation of PRs to make it easier, especially as we anticipate further updates. This automation work should also be done in another ticket (see #47).

The majority of the changes to the research template itself are in this PR.

TODO

  • Move to rocker base image and copy packages from r action image. Configure renv to use the packages
  • Add the VS Code r language extension into the devcontainer config (ignore for this ticket)
  • Consider adding the the languageserver, radian and httpgd packages to make use of the r language extension (ignore for this ticket)
  • Rename python venv to make its purpose clearer in case we create additional venvs in future (e.g call it “python:v2” to match the Action image)
  • Move out vscode settings into devcontainer specific settings, so that devcontainer specific changes a kept to that one directory
  • Remove data.preview options, since we aren't currently using the extension
  • Remove dockerfile as this will be added to a new repo as part of Move dev container Dockerfile into new repo #46.
  • Move the change to .gitignore into a .devcontainers/.gitignore file, so that devcontainer specific changes a kept to that one directory
  • See if DISABLE_AUTH=true sudo rstudio-server start works to remove the login prompt. It's possible that the env var isn't being passed into the dev container though. If it doesn't work, don't try to fix and consider this item done.
  • Moved to Pass workspace base directory to post-creation script instead of using pwd #57
  • Add a wrapper script / symlink to Python so that the devcontainer.json isn't pointing to a specific version of python.
@lucyb lucyb added this to the Development milestone Apr 15, 2024
@lucyb lucyb self-assigned this Apr 15, 2024
lucyb added a commit to opensafely/comparative-booster-spring2023 that referenced this issue Apr 18, 2024
This will provide a development environment for researchers containing:

* Python 3.10
* The equivalent Python packages based on the Python Action image, including ehrql
* R 4.0.5
* RStudio
* The equivalent R packages based on the R Action image

This can be used in Codespaces or locally via devcontainers in VS Code.

It's based on the work being done for opensafely-core/codespaces-initiative#43.
lucyb added a commit to opensafely/comparative-booster-spring2023 that referenced this issue Apr 18, 2024
This will provide a development environment for researchers containing:

* Python 3.10
* The equivalent Python packages based on the Python Action image, including ehrql
* R 4.0.5
* RStudio
* The equivalent R packages based on the R Action image

This can be used in Codespaces or locally via devcontainers in VS Code.

It's based on the work being done for opensafely-core/codespaces-initiative#43.
lucyb added a commit to opensafely/antibody-and-antiviral-deployment that referenced this issue Apr 22, 2024
This will provide a development environment for researchers containing:

 * Python 3.10
 * The equivalent Python packages based on the Python Action image, including ehrql
 * R 4.0.5
 * RStudio
 * The equivalent R packages based on the R Action image

This can be used in Codespaces or locally via devcontainers in VS Code.

It's based on the work being done for opensafely-core/codespaces-initiative#43.
@lucyb
Copy link
Author

lucyb commented Apr 23, 2024

As part of testing these changes, I've sent the new configuration to Tom P, Will and Rose. It's worked fine for Tom P and Rose, so far. Still waiting to hear back from Will.

One external user is keen to try it out (thread).

@lucyb lucyb changed the title Create improved devcontainers configuration Create improved devcontainer configuration Apr 25, 2024
@lucyb lucyb changed the title Create improved devcontainer configuration Create improved dev container configuration Apr 25, 2024
@Jongmassey
Copy link

See if DISABLE_AUTH=true sudo rstudio-server start works to remove the login prompt. It's possible that the env var isn't being passed into the dev container though. If it doesn't work, don't try to fix and consider this item done.

This required looking inside the rocker scrips that read that env var and copying its behaviour. You may have to clear cookies for this to work.

@Jongmassey
Copy link

Move to rocker base image and copy packages from r action image. Configure renv to use the packages

Following advice from Tom P, I've removed renv from the equation and dropped them in the system library

@Jongmassey
Copy link

Rename python venv to make its purpose clearer in case we create additional venvs in future (e.g call it “python:v2” to match the Action image)

Done, needed to change the path in the smoke test accordingly. Used python-v2 rather than python:v2 as colons not allowed in paths.

For some reason the virtualenv isn't activating in my local devcontainer run of this. I'll push an updated image and see if that's the case in codespaces.

@Jongmassey
Copy link

Rename python venv to make its purpose clearer in case we create additional venvs in future (e.g call it “python:v2” to match the Action image)

OK so at least some of the problems I've been having are to do with the path to the virtualenv no longer matching what's in the activation script (which is created upon virtualenv creation). I suggest reverting to /opt/venv to match what's in the opensafely python image for now. In future we could either modify the activate script or recreate the venv when the times comes to need to support multiple venvs. Thoughts @lucyb ?

@Jongmassey
Copy link

Remove dockerfile as this will be added to a new repo as part of

I've rebased such that there never was a Dockerfile in there in the first place

@iaindillingham
Copy link
Member

I think this issue is closed by opensafely#120.

This configuration will be used to create Codespaces by researchers, so it should be tested out by several researchers before it can be considered complete.

I think the above will be addressed by:

@Jongmassey
Copy link

#120 merged

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

3 participants