Skip to content

Commit

Permalink
Merge pull request #29 from SchmidtDSE/debug/make_docker_use_amd64
Browse files Browse the repository at this point in the history
solve filesystem OSX issue for pixi mount
  • Loading branch information
lucialayr authored Jan 17, 2025
2 parents a02cadb + fabb2be commit 8646faf
Show file tree
Hide file tree
Showing 12 changed files with 9,172 additions and 151 deletions.
11 changes: 2 additions & 9 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ FROM ghcr.io/prefix-dev/pixi:0.39.5-bullseye-slim
# Copy over install scripts - this is a good way to keep the Dockerfile clean and readable
COPY .devcontainer/scripts .devcontainer/scripts

# Install git, ssh
RUN .devcontainer/scripts/install_git_and_ssh.sh
# Install git, ssh and other tools contained in `scripts/run_on_build.sh`
RUN .devcontainer/scripts/run_on_build.sh

# Copy over pixi toml and pyproject.toml
COPY pixi.toml pixi.toml
COPY pixi.lock pixi.lock

# TODO: Pixi is invalidating docker cache here for some reason - it would be better
# to do a multi-stage build and only copy over the source code at the end
# See https://github.com/pavelzw/pixi-docker-example/blob/main/3-multi-stage/Dockerfile

# Install pixi dependencies
RUN pixi install

# Now, copy python source code into the image - by doing this last, we can avoid re-installing ALL dependencies if just the source code changes
COPY vegetation vegetation

Expand Down
10 changes: 7 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
"name": "Dev Container",
"build": {
"dockerfile": "Dockerfile",
"context": "../"
"context": "../",
"options": [
"--platform=linux/amd64"
]
},
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind,consistency=cached", // SSH keys
"source=${localEnv:HOME}/local_dev_data,target=/local_dev_data,type=bind,consistency=cached" // Local development cache
"source=${localEnv:HOME}/local_dev_data,target=/local_dev_data,type=bind,consistency=cached", // Local development cache,
"source=${localWorkspaceFolderBasename}-pixi,target=${containerWorkspaceFolder}/.pixi,type=volume"
],
"extensions": [
"ms-python.flake8",
Expand All @@ -17,5 +21,5 @@
"github.vscode-github-actions",
"ms-azuretools.vscode-docker"
],
"postCreateCommand": ".devcontainer/scripts/transfer_local_dev_cache.sh"
"postCreateCommand": ".devcontainer/scripts/run_post_create.sh"
}
3 changes: 0 additions & 3 deletions .devcontainer/scripts/install_git_and_ssh.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .devcontainer/scripts/install_pixi.sh

This file was deleted.

6 changes: 6 additions & 0 deletions .devcontainer/scripts/on_build/install_git_and_ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#/bin/bash

apt-get update && apt-get install -y git openssh-client curl bash-completion

# To enable bash completion for git
echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
pixi install
18 changes: 18 additions & 0 deletions .devcontainer/scripts/run_on_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

DIR=".devcontainer/scripts/on_build"

for script in "$DIR"/*.sh; do
if [ -f "$script" ]; then
echo "=== Executing $script ==="
bash "$script"

# Check exit status
if [ $? -eq 0 ]; then
echo "$script completed successfully"
else
echo "$script failed with exit code $?"
fi
echo
fi
done
18 changes: 18 additions & 0 deletions .devcontainer/scripts/run_post_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

DIR=".devcontainer/scripts/post_create"

for script in "$DIR"/*.sh; do
if [ -f "$script" ]; then
echo "=== Executing $script ==="
bash "$script"

# Check exit status
if [ $? -eq 0 ]; then
echo "$script completed successfully"
else
echo "$script failed with exit code $?"
fi
echo
fi
done
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ If going the dev container route, you will need the following:
- VSCode, and the `Dev Containers` extension
- `ssh` installed on the host machine, to access git from within
- A folder `local_dev_data` needs to be created in your home directory
- a `.env` file in the `.devcontainer` folder, in the following format:

```
DEM_STAC_PATH = "https://planetarycomputer.microsoft.com/api/stac/v1/"
INITIAL_AGENTS_PATH = "/workspaces/mesa_abm_poc/vegetation/data/initial_agents.json"
LOCAL_STAC_CACHE_FSTRING = "/workspaces/mesa_abm_poc/vegetation/.local_dev_data/{band_name}_{bounds_md5}.tif"
SAVE_LOCAL_STAC_CACHE = True
DOCKER_HOST_STAC_CACHE_FSTRING = "/local_dev_data/mesa_exog_cache/{band_name}_{bounds_md5}.tif"
```

After cloning the repo, you will need to open it in VSCode and run the following command:

Expand All @@ -33,4 +42,4 @@ pixi run vegetation

- Sliders don't seem to change model inits whatsoever - and docs don't show any explicit way to access them, seems to just 'happen' when registering model params?

- Occasionally Solara appears to never render (stuck on "Loading App"). Simply rebuilding (not from cache) seems to fix it, and it seems to happen after changes are made to the `SolaraViz` class from mesa-geo - could have something to do with autoreload, but not sure.
- Occasionally Solara appears to never render (stuck on "Loading App"). Simply rebuilding (not from cache) seems to fix it, and it seems to happen after changes are made to the `SolaraViz` class from mesa-geo - could have something to do with autoreload, but not sure.
Loading

0 comments on commit 8646faf

Please sign in to comment.