Skip to content
Merged
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
52 changes: 45 additions & 7 deletions CLOUD_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ Lithops requires a service account with proper permissions to deploy Cloud Funct
export PROJECT_ID=$(gcloud config get-value project)
```

For this project, the project ID is: `ds-englacial`
For this project, the project ID is: `astera-englacial`



### 2. Create Service Account

**If the service account was already created you can skip to Step 4.**

```bash
gcloud iam service-accounts create lithops-executor \
--display-name="Lithops Executor Service Account" \
Expand All @@ -51,13 +55,13 @@ Grant Storage Object Admin role (to read/write GCS buckets):
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:lithops-executor@${PROJECT_ID}.iam.gserviceaccount.com" \
--role="roles/storage.objectAdmin"

```

### 4. Download Service Account Key

```bash
gcloud iam service-accounts keys create ~/lithops-sa-key.json \
--iam-account=lithops-executor@${PROJECT_ID}.iam.gserviceaccount.com
gcloud iam service-accounts keys create ~/lithops-sa-key.json --iam-account=lithops-executor@${PROJECT_ID}.iam.gserviceaccount.com
```

This creates a JSON key file at `~/lithops-sa-key.json`.
Expand All @@ -74,6 +78,7 @@ The `lithops.yaml` configuration file should reference the service account key:
lithops:
backend: gcp_functions
storage: gcp_storage
data_limit: False

gcp:
region: us-west1
Expand All @@ -82,12 +87,35 @@ gcp:
gcp_functions:
region: us-west1
runtime: ismip6-icechunk
runtime_memory: 8192
runtime_timeout: 540
project_id: astera-englacial

gcp_storage:
storage_bucket: ismip6-icechunk
storage_bucket: ismip6-icechunk # Lithops uses storage_bucket, not bucket
region: us-west1
```

### Additional steps that Julius needed to reproduce
- Get permission for service account on `astera-englacial` to be `'storage.admin'` on `gs://ismip6-icechunk`

- Needed to manually activate the following APIS:
- Cloud Pub/Sub
- Cloud Functions
- Cloud Build
- Artifact Registry
- All of these might take a bit of time to activate.
- The service account needed the following additional permissions:
- Command `gcloud projects add-iam-policy-binding astera-englacial \
--member=serviceAccount:lithops-executor@astera-englacial.iam.gserviceaccount.com \
--role=roles<your_role>`
- `pubsub.admin`
- `Cloud Functions Admin` (forgot the exact syntax)
- `iam.serviceAccountUser`
- Downgrade to python 3.12
- Delete old function definitions (just to be sure)
- Add `gen: 2` to lithops config.

### Important Notes

- **Do NOT use Application Default Credentials**: Lithops requires a service account key file with `client_email` and `token_uri` fields, which ADC doesn't provide
Expand All @@ -112,8 +140,18 @@ gcp_storage:
## Build the runtime

```bash
# lithops runtime delete ismip6-icechunk -c lithops.yaml
lithops runtime build -f requirements.txt ismip6-icechunk -c lithops.yaml
lithops runtime deploy ismip6-icechunk -c lithops.yaml
# To create the requirements I exported the locked uv env
# `uv export --no-hashes --no-dev --no-editable > requirements.txt`
# and then manually populated requirements-lithops.txt with the same versions
# This could definitely be improved
# Then build and deploy the runtime (If the deploy succeeds you should be good to go!)
uv run lithops runtime build -f requirements-lithops.txt ismip6-icechunk -c lithops.yaml
uv run lithops runtime deploy ismip6-icechunk -c lithops.yaml
```

## Running the script

And then run the script with uv
```
uv run python virtualize_with_lithops_combine_variables.py
```
13 changes: 8 additions & 5 deletions lithops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ lithops:

gcp:
region: us-west1
credentials_path: /Users/aimeebarciauskas/lithops-sa-key.json
credentials_path: ~/lithops-sa-key.json

gcp_functions:
region: us-west1
runtime: ismip6-icechunk
runtime_memory: 8192
runtime_timeout: 540
project_id: ds-englacial
runtime_memory: 1024
runtime_timeout: 300
project_id: astera-englacial
gen: 2
requirements: requirements-lithops.txt

gcp_storage:
storage_bucket: ismip6-icechunk # Lithops uses storage_bucket, not bucket
storage_bucket: ismip6-icechunk
region: us-west1
3,619 changes: 3,619 additions & 0 deletions notebooks/open_icechunk_combined_vars.ipynb

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "ismip6-helper"
version = "0.1.0"
description = "Helper utilities for loading ISMIP6 outputs"
readme = "README.md"
requires-python = ">=3.13"
requires-python = ">=3.12"
authors = [
{ name = "Thomas Teisberg" },
]
Expand All @@ -17,7 +17,7 @@ classifiers = [
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.12",
]

dependencies = [
Expand Down Expand Up @@ -45,8 +45,9 @@ dependencies = [
"scipy>=1.16.2",
"virtualizarr>=2.2.1",
"xarray>=2025.10.1",
"lithops>=3.6.2",
"lithops[gcp]>=3.6.2",
"kerchunk>=0.2.9",
"google-cloud>=0.34.0",
]

[project.optional-dependencies]
Expand All @@ -56,5 +57,6 @@ dev = [
"ruff>=0.1.0",
]


[tool.hatch.build.targets.wheel]
packages = ["ismip6_helper", "ismip6_comparison_app"]
28 changes: 28 additions & 0 deletions requirements-lithops.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Lithops runtime requirements - only PyPI packages
# Lithops core dependencies (required by Lithops itself)
pika==1.3.2
tblib==3.2.2
ps-mem==3.14
cloudpickle==3.1.2
requests==2.32.5

# Core dependencies for virtualization
# icechunk==1.1.13
# icechunk==1.1.14 # latest
# icechunk==1.1.10 #
# leave out icechunk, for now we are just virtualizing in lithops
virtualizarr==2.2.1
xarray==2025.10.1
zarr==3.1.5
obstore==0.8.2
kerchunk==0.2.9
scipy==1.16.2

# Dependencies for ismip6_helper functions
pyproj==3.7.2
numpy==2.3.4
h5netcdf==1.7.3
netcdf4==1.7.3
cftime==1.6.5
fsspec==2025.9.0
gcsfs==2025.9.0
Loading