Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
189 changes: 189 additions & 0 deletions PACKAGE_INSTALLATION_GUIDE.md

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.

this file seems like a duplicate of the two skills, is it still needed?

it's also outside of any devcontainer feature, should it be in llm-context?

Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# Pre-installing Packages in Workbench Apps

Users often want specific packages pre-installed in their apps to avoid running `pip install` or `install.packages()` every time. This guide shows two simple approaches.

---

## Approach 1: Natural Language with Claude (Easiest!)

Just ask Claude what you need, and it will help you install packages:

**Examples:**
- "I need ggplot2"
- "Set me up for machine learning"
- "I want tools for genomics analysis"
- "Install deep learning packages"

Claude understands natural language and will either:
- Generate an installation command for you to run
- Pre-configure your app with the packages

**Supported domains:**
- Machine Learning, Deep Learning, NLP
- Data Visualization, Dashboards
- Bioinformatics, Genomics, Single-cell
- BigQuery/GCP, Statistics, Time Series
- And more...

---

## Approach 2: Pre-install with common-packages Feature

Use the built-in `common-packages` feature in your `.devcontainer.json`:

```json
{
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"pythonPackages": "tensorflow scikit-learn pandas numpy matplotlib",
"rPackages": "Seurat,DESeq2,ggplot2,tidyverse"
}
}
}
```

**Python packages:** Space-separated
**R packages:** Comma-separated (NO SPACES)

**When to use this:**
- You know exactly which packages you need
- You want packages available immediately at app startup
- You're creating a new app

See [`features/src/common-packages/README.md`](features/src/common-packages/README.md) for details.

---

## Complete Examples

### Example 1: Jupyter with Machine Learning Packages

**With Claude:**
Just say: "Create a Jupyter app for machine learning"

**Manual configuration:**
```json
{
"name": "Jupyter - Machine Learning",
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"pythonPackages": "scikit-learn xgboost tensorflow torch pandas numpy matplotlib"
}
}
}
```

### Example 2: R Analysis for Genomics

**With Claude:**
Just say: "I need R packages for genomics analysis"

**Manual configuration:**
```json
{
"name": "R Analysis - Genomics",
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"rPackages": "Seurat,DESeq2,GenomicRanges,tidyverse,ggplot2"
}
}
}
```

### Example 3: On-Demand Installation (Already in Jupyter)

If you're already working and realize you need more packages:

**Ask Claude:** "I need plotly for visualization"

**Claude will show you:**
```python
!pip install plotly
```

Or for R:
```python
%%R
install.packages("plotly")
```

---

## Comparison

| Approach | When Available | Requires Rebuild | Natural Language |
|----------|---------------|------------------|------------------|
| **Ask Claude** | On-demand or pre-build | No (on-demand) / Yes (pre-build) | ✅ Yes |
| **common-packages feature** | At app startup | Yes | ❌ No |

**Best practice:**
- Use `common-packages` for packages you know you'll need
- Ask Claude when you discover new needs while working

---

## Common Package Lists

### Python

**Data Science:** pandas, numpy, scipy, matplotlib, seaborn
**Machine Learning:** scikit-learn, xgboost, lightgbm
**Deep Learning:** tensorflow, torch, transformers, keras
**NLP:** transformers, spacy, nltk, gensim
**Bioinformatics:** biopython, scanpy, anndata
**BigQuery:** google-cloud-bigquery, google-cloud-storage, db-dtypes
**Visualization:** matplotlib, seaborn, plotly, dash, streamlit

### R

**Core Data Science:** tidyverse, dplyr, tidyr, readr, ggplot2
**Visualization:** ggplot2, plotly, shiny, shinydashboard
**Machine Learning:** caret, randomForest, xgboost
**Bioinformatics:** Seurat, DESeq2, edgeR, limma
**Genomics:** GenomicRanges, AnnotationDbi, biomaRt
**BigQuery:** bigrquery, googleCloudStorageR

---

## FAQ

### Q: How do I install packages I discover I need while working?

**A:** Just ask Claude! Say "I need <package>" or "I need tools for <task>", and Claude will generate the installation command for you.

### Q: Can I use both Python and R packages?

**A:** Yes! Just specify both:
```json
{
"pythonPackages": "pandas numpy",
"rPackages": "ggplot2,tidyverse"
}
```

### Q: What if I need a package that's not in the common lists?

**A:** Just ask Claude or add it explicitly to the `pythonPackages` or `rPackages` field. For example:
- "I need the 'polars' package"
- Or add: `"pythonPackages": "polars duckdb"`

### Q: How do I install Bioconductor packages?

**A:** Ask Claude "I need Bioconductor packages for RNA-seq", or use:
```json
{
"rPackages": "BiocManager,DESeq2,edgeR,limma"
}
```

The `common-packages` feature automatically handles Bioconductor installation.

---

## Summary

**Easiest way:** Ask Claude in natural language
**For known needs:** Use `common-packages` feature in `.devcontainer.json`
**Both work together:** Pre-install common packages, ask Claude for additional ones

No more manual `pip install` or `install.packages()` every time! 🎉
77 changes: 77 additions & 0 deletions features/src/common-packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Pre-install Packages Feature

Pre-install your Python and R packages so you don't have to run `pip install` or `install.packages()` every time you create an app.

## Usage

Just list the packages you want in your `.devcontainer.json`:

```json
{
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"pythonPackages": "pandas numpy scikit-learn matplotlib",
"rPackages": "tidyverse,ggplot2,dplyr,plotly,shiny"
}
}
}
```

That's it! Packages will be pre-installed when the app is built.

## Examples

### R Analysis with 15 packages

```json
{
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"rPackages": "tidyverse,ggplot2,dplyr,tidyr,readr,plotly,shiny,DT,data.table,caret,randomForest,bigrquery,googleCloudStorageR,arrow,lubridate"
}
}
}
```

### Jupyter with Python packages

```json
{
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"pythonPackages": "pandas numpy matplotlib seaborn scikit-learn google-cloud-bigquery google-cloud-storage"
}
}
}
```

### Both Python and R

```json
{
"features": {
"ghcr.io/verily-src/workbench-app-devcontainers/common-packages": {
"pythonPackages": "pandas numpy",
"rPackages": "ggplot2,dplyr"
}
}
}
```

## Format

- **Python packages:** Space-separated (e.g., `"pandas numpy scikit-learn"`)
- **R packages:** Comma-separated (e.g., `"tidyverse,ggplot2,dplyr"`)

## How It Works

- Packages install during container build (one-time)
- Apps launch instantly with packages ready
- Users can still install more packages at runtime if needed
- Much simpler than creating custom app configs

## Performance

- **First build:** Takes time to install packages
- **Every app after:** Instant - packages already there
- **vs. manual install every time:** Saves 5-10 minutes per app launch
19 changes: 19 additions & 0 deletions features/src/common-packages/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"id": "common-packages",
"version": "1.0.0",
"name": "Pre-install Packages",
"description": "Pre-install Python and R packages so users don't have to run pip install or install.packages() every time",
"documentationURL": "https://github.com/verily-src/workbench-app-devcontainers/tree/main/features/src/common-packages",
"options": {
"pythonPackages": {
"type": "string",
"default": "",
"description": "Python packages to install (space-separated, e.g., 'pandas numpy scikit-learn')"
},
"rPackages": {
"type": "string",
"default": "",
"description": "R packages to install (comma-separated, e.g., 'tidyverse,ggplot2,dplyr')"
}
}

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.

can we add installsAfter to make sure features that install python or r are installed first?

  "installsAfter": [
    "ghcr.io/devcontainers/features/python",
    "ghcr.io/rocker-org/devcontainer-features/r-packages",
    "./.devcontainer/features/workbench-tools"
  ]

}
18 changes: 18 additions & 0 deletions features/src/common-packages/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

echo "Installing user-specified packages..."

# Install Python packages
if [ -n "${PYTHONPACKAGES}" ] && command -v pip &> /dev/null; then
echo "Installing Python packages: ${PYTHONPACKAGES}"
pip install --no-cache-dir ${PYTHONPACKAGES}
fi

# Install R packages
if [ -n "${RPACKAGES}" ] && command -v R &> /dev/null; then
echo "Installing R packages: ${RPACKAGES}"
R --quiet -e "install.packages(strsplit('${RPACKAGES}', ',')[[1]], repos='https://cran.rstudio.com/', quiet=TRUE)"
fi

echo "Package installation complete!"
Loading
Loading