Skip to content

Commit e4e5756

Browse files
authored
minor tweaks to skypilot setup (#348)
* Fixes numba bug with print being defined inside a function rather than a module. * Fixes sqlalchemy required by skypilot * Some docs and convenience updates
1 parent c231ac1 commit e4e5756

5 files changed

Lines changed: 58 additions & 28 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ You can run `uv run -m ocean_emulators.train --help` to see all the options avai
170170
To learn more about other datasets used during training, please see the _Data Engineering_ section below.
171171

172172
To run a remote training job with Skypilot, use the following command:
173+
173174
```shell
174175
# export WANDB_API_KEY=<my-key> # Get your key at https://wandb.ai/authorize
175-
# sky launch -c fomo-cluster train.sky.yaml --env WANDB_API_KEY --env-file <my-vars>.env
176+
uv run sky launch train.sky.yaml --env WANDB_API_KEY --env-file <my-vars>.env
176177
```
177178

178179
Please read the docstring in the `train.sky.yaml` for more information.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies = [
3838
"s3fs>=2025.5.1",
3939
"scipy>=1.15.2",
4040
"skypilot[aws,lambda]>=0.10",
41+
"sqlalchemy>=2", # skypilot requires sqlalchemy 2.0 but doesn't include that requirement
4142
"torch~=2.2.1",
4243
"torchinfo>=1.8",
4344
"wandb>=0.19.8",

src/ocean_emulators/utils/distributed.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@ def set_seed(seed):
2525
# torch.use_deterministic_algorithms(True)
2626

2727

28-
def suppress_prints(is_master):
29-
"""This function disables printing when not in master process."""
30-
builtin_print = builtins.print
28+
builtin_print = builtins.print
29+
30+
31+
def print(*args, **kwargs):
32+
force = kwargs.pop("force", False)
33+
force = force or (get_world_size() > 8)
34+
if force:
35+
now = datetime.datetime.now().time()
36+
builtin_print(f"[{now}] ", end="") # print with time stamp
37+
builtin_print(*args, **kwargs)
3138

32-
def print(*args, **kwargs):
33-
force = kwargs.pop("force", False)
34-
force = force or (get_world_size() > 8)
35-
if is_master or force:
36-
now = datetime.datetime.now().time()
37-
builtin_print(f"[{now}] ", end="") # print with time stamp
38-
builtin_print(*args, **kwargs)
3939

40-
builtins.print = print
40+
def suppress_prints(is_master):
41+
"""This function disables printing when not in master process."""
42+
if not is_master:
43+
builtins.print = print
4144

4245

4346
def suppress_logging(is_master):

train.sky.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
# ```
77
# sky check -v
88
# ```
9+
# You will generally need to create a dedicated IAM user for skypilot, and put
10+
# your lambda credentials in ~/.lambda_cloud/ -- the `sky check -v` command has more details.
911
#
1012
# To create or re-use a cluster:
1113
# ```
1214
# export WANDB_API_KEY=<my-key> # Get your key at https://wandb.ai/authorize
13-
# sky launch -c fomo-cluster train.sky.yaml --env-file <my-env>.env --env WANDB_API_KEY
15+
# uv run sky launch train.sky.yaml --env-file <my-env>.env --env WANDB_API_KEY
1416
# ```
1517
# As the job progresses, skypilot will provide commands to locally monitor each stage.
1618
#
@@ -44,6 +46,7 @@ envs:
4446
# We assume that data in this directory is named in the same pattern as
4547
# the $DATA_CONFIG yaml.
4648
DATA_ROOT_PATH: null # data/om4_onedeg_compact # NOTE: path cannot end in a slash `/`.
49+
ARGS: ""
4750

4851
file_mounts:
4952
# TODO(alxmrs): Consider adding a data/ COPY file_mount here once `mount_options` feature exists.
@@ -56,6 +59,8 @@ file_mounts:
5659
workdir: .
5760

5861
setup: |
62+
set -ex
63+
5964
mkdir ~/data/
6065
rclone config create s3-source s3 provider=AWS env_auth=true
6166
@@ -64,6 +69,8 @@ setup: |
6469
rclone copy --progress s3-source:${DATA_BUCKET}/${DATA_ROOT_PATH}/OM4.zarr ~/data/OM4.zarr --transfers=32 --ignore-existing
6570
6671
run: |
72+
set -ex
73+
6774
MASTER_ADDR=$(echo "$SKYPILOT_NODE_IPS" | head -n1)
6875
echo "Starting distributed training, head node: $MASTER_ADDR"
6976
@@ -86,4 +93,4 @@ run: |
8693
--experiment.data_root=${DATA_ROOT} \
8794
--experiment.base_output_dir=/outputs/ \
8895
--experiment.wandb.mode=online \
89-
--samudra.checkpointing=all
96+
${ARGS}

uv.lock

Lines changed: 32 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)