Skip to content

Commit 6176535

Browse files
author
iacopoff
committed
update and fix surrogate
1 parent 570bd91 commit 6176535

File tree

8 files changed

+83
-35
lines changed

8 files changed

+83
-35
lines changed

docker/hydromt/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ h5netcdf # to read netcd on S3
2121
openeo-pg-parser-networkx==2024.5.0
2222
hydromt @ git+https://github.com/interTwin-eu/hydromt.git@stac#egg=hydromt
2323
hydromt_wflow @ git+https://github.com/interTwin-eu/hydromt_wflow.git@stac#egg=hydromt_wflow
24-
raster2stac==0.0.7
24+
raster2stac==0.0.8
2525
#https://gitlab.inf.unibz.it/earth_observation_public/raster-to-stac/-/tree/update_url
2626
#raster2stac @ git+https://gitlab.inf.unibz.it/earth_observation_public/raster-to-stac.git@update_url#egg=raster2stac
2727
s3fs # to access aws s3 bucket

docker/surrogate/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#FROM ghcr.io/intertwin-eu/itwinai:jlab-slim-latest
22
#FROM ghcr.io/intertwin-eu/itwinai:0.2.2-torch2.1
33
#FROM ghcr.io/intertwin-eu/itwinai:torch-slim-latest
4-
FROM ghcr.io/intertwin-eu/hython-itwinai-plugin:v0.2
4+
FROM ghcr.io/intertwin-eu/hython-itwinai-plugin:v0.4
55

66

77
ENV HYDRA_FULL_ERROR=1
88

99
# !! Workaraound for overriding the default image plugin which does not have latest developments
10-
RUN git clone -b main https://github.com/interTwin-eu/hython-itwinai-plugin.git
10+
RUN git clone -b iacopo https://github.com/interTwin-eu/hython-itwinai-plugin.git
1111
RUN cd /app/hython-itwinai-plugin && pip install .
1212
RUN cd .
1313

@@ -16,6 +16,11 @@ COPY requirements.txt ./requirements.txt
1616
# Breaks if not using --use-pep517 (https://github.com/pypa/pip/issues/6334)
1717
RUN pip install --upgrade pip && pip install --no-cache-dir --use-pep517 -r requirements.txt
1818

19+
# !! Remove when fixing image plugin
20+
RUN git clone -b main https://github.com/interTwin-eu/hython.git
21+
RUN cd /app/hython && pip install .
22+
RUN cd .
23+
1924
RUN mkdir -p ./use-case
2025
RUN mkdir -p ./model
2126
RUN mkdir -p /data

docker/surrogate/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ s3fs==2025.5.0
22
omegaconf==2.3.0
33

44
# TODO ITWINAI PLUGIN INSTALLED IN DOCKER
5-
# itwinai-hython-plugin @ git+https://github.com/interTwin-eu/hython-itwinai-plugin.git@main#egg=hython-itwinai-plugin
5+
# itwinai-hython-plugin @ git+https://github.com/interTwin-eu/hython-itwinai-plugin.git@main#egg=hython-itwinai-plugin

docker/surrogate/src/training_local.yaml

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,16 @@ data_source:
120120
client_kwargs:
121121
endpoint_url: "https://objectstore.eodc.eu:2222"
122122
s3:
123-
static_inputs: "s3://rucio/interTwin_EURAC/hydroform/wflow/be76bdf2-858c-4350-986c-40b57ab0247f_/wflow_output_statics.zarr"
124-
dynamic_inputs: "s3://rucio/interTwin_EURAC/hydroform/wflow/be76bdf2-858c-4350-986c-40b57ab0247f_/wflow_output_dynamics.zarr"
125-
target_variables: "s3://rucio/interTwin_EURAC/hydroform/wflow/be76bdf2-858c-4350-986c-40b57ab0247f_/wflow_output_dynamics.zarr"
123+
static_inputs: "s3://rucio/interTwin_EURAC/hydroform/wflow/6af2cc6a-d2ba-4743-a528-9b49f79c439e_/wflow_output_statics.zarr"
124+
dynamic_inputs: "s3://rucio/interTwin_EURAC/hydroform/wflow/6af2cc6a-d2ba-4743-a528-9b49f79c439e_/wflow_output_dynamics.zarr"
125+
target_variables: "s3://rucio/interTwin_EURAC/hydroform/wflow/6af2cc6a-d2ba-4743-a528-9b49f79c439e_/wflow_output_dynamics.zarr"
126126

127127

128128
static_categorical_inputs:
129129
- wflow_landuse
130130
- wflow_soil
131131

132132
static_inputs:
133-
- thetaS
134133
- thetaR
135134
- KsatVer
136135
- c
@@ -147,10 +146,60 @@ mask_variables:
147146
- mask_missing
148147
# - mask_lake
149148

149+
150+
# Preprocess
151+
152+
preprocessor: null
153+
# static_inputs:
154+
# lazy: False
155+
# variant:
156+
# - _target_: hython.preprocessor.Log10p
157+
# variable:
158+
# - "KsatVer"
159+
# dynamic_inputs:
160+
# lazy: False
161+
# variant:
162+
# - _target_: hython.preprocessor.Log10p
163+
# variable:
164+
# - "precip"
165+
150166
# Scaling
151167

152-
scaling_variant: minmax
153-
scaling_use_cached: True
168+
scaling_use_cached: False
169+
scaling_static_range:
170+
thetaS: [0.25, 0.95]
171+
thetaR: [0.01, 0.35] # it was 0.25 in table
172+
KsatVer: [1, 10000]
173+
c: [1, 20]
174+
f: [0.00001, 0.1] # from training data (it is fitted)
175+
M: [1, 3000]
176+
RootingDepth: [100, 2000 ] #5000] # (mm)
177+
Swood: [0.0, 0.5] # -
178+
Sl: [0.02, 0.2] #(mm)
179+
Kext: [0.48, 0.96] #
180+
181+
scaler:
182+
static_inputs:
183+
lazy: False
184+
variant:
185+
- _target_: hython.scaler.BoundedScaler
186+
variable:
187+
thetaR: ${scaling_static_range.thetaR}
188+
KsatVer: ${scaling_static_range.KsatVer}
189+
c: ${scaling_static_range.c}
190+
dynamic_inputs:
191+
lazy: False
192+
variant:
193+
- _target_: hython.scaler.MinMax01Scaler
194+
variable:
195+
- "precip"
196+
- "pet"
197+
- "temp"
198+
target_variables:
199+
lazy: False
200+
variant:
201+
- _target_: hython.scaler.MinMax01Scaler
202+
variable: ${target_variables}
154203

155204
# MLFLow
156205
tracking_uri: null # http://mlflow.intertwin.fedcloud.eu/
@@ -178,10 +227,10 @@ training_pipeline:
178227
dataset: ${dataset}
179228
data_lazy_load: ${data_lazy_load}
180229
data_source: ${data_source}
181-
scaling_variant: ${scaling_variant}
230+
preprocessor: ${preprocessor}
231+
scaler: ${scaler}
182232
scaling_use_cached: ${scaling_use_cached}
183233
experiment_name: ${experiment_name}
184-
run_id: ${run_id}
185234
work_dir: ${work_dir}
186235
train_downsampler: ${train_downsampler}
187236
valid_downsampler: ${valid_downsampler}
@@ -191,7 +240,6 @@ training_pipeline:
191240
config:
192241
experiment: ${experiment_name}/${run_id}
193242
experiment_name: ${experiment_name}
194-
run_id: ${run_id}
195243
work_dir: ${work_dir}
196244
batch_size: ${batch}
197245
learning_rate: ${learning_rate}
@@ -229,12 +277,12 @@ training_pipeline:
229277
# model logger
230278
model_logger: ${model_logger}
231279

280+
run_id: $(run_id)
232281
strategy: ${strategy}
233282
epochs: ${epochs}
234283
measure_gpu_data: True
235-
measure_communication_overhead: True
236284
measure_epoch_time: True
237-
run_id: $(run_id)
285+
torch_profiling: False
238286
random_seed: ${seed}
239287
profiling_wait_epochs: 1
240288
profiling_warmup_epochs: 1
@@ -263,25 +311,26 @@ hpo:
263311
dataset: ${dataset}
264312
data_lazy_load: ${data_lazy_load}
265313
data_source: ${data_source}
266-
scaling_variant: ${scaling_variant}
314+
preprocessor: ${preprocessor}
315+
scaler: ${scaler}
267316
scaling_use_cached: ${scaling_use_cached}
268317
experiment_name: ${experiment_name}
269-
run_id: ${run_id}
270318
work_dir: ${work_dir}
271319
train_downsampler: ${train_downsampler}
272320
valid_downsampler: ${valid_downsampler}
321+
seq_length: ${seq_length}
273322
- _target_: itwinai.plugins.hython.trainer.RNNDistributedTrainer
274323
model: ${model}
275324
config:
276325
experiment: ${experiment_name}/${run_id}
277326
experiment_name: ${experiment_name}
278-
run_id: ${run_id}
279327
work_dir: ${work_dir}
280328
batch_size: ${batch}
281329
learning_rate: ${learning_rate}
282330
num_workers_dataloader: ${num_workers_dataloader}
283331
pin_gpu_memory: True
284332
hython_trainer: ${hython_trainer}
333+
dynamic_downsampler: ${dynamic_downsampler}
285334
seq_length: ${seq_length}
286335
target_variables: ${target_variables}
287336
dynamic_inputs: ${dynamic_inputs}
@@ -314,13 +363,13 @@ hpo:
314363
# model logger
315364
model_logger: ${model_logger}
316365

366+
run_id: $(run_id)
317367
time_ray: ${time_ray}
318368
strategy: ${strategy}
319369
epochs: ${epochs}
320370
measure_gpu_data: True
321-
measure_communication_overhead: True
322371
measure_epoch_time: True
323-
run_id: $(run_id)
372+
torch_profiling: False
324373
random_seed: ${seed}
325374
profiling_wait_epochs: 1
326375
profiling_warmup_epochs: 1
@@ -354,7 +403,7 @@ hpo:
354403
# reduction_factor: 6
355404
# brackets: 1
356405
ray_run_config:
357-
_target_: ray.train.RunConfig
406+
_target_: ray.tune.RunConfig
358407
# storage_path must be an absolute path. Defaulting to the directory from which the
359408
# job is launched using the itwinai custom OmegaConf resolver ${itwinai.cwd:}
360409
storage_path: ${itwinai.cwd:}/ray_checkpoints
@@ -380,8 +429,4 @@ hpo:
380429
type: qrandint
381430
lower: 90
382431
upper: 365
383-
q: 30
384-
interval_value:
385-
type: choice
386-
categories: [3, 5, 10]
387-
432+
q: 30

docker/wflow/requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ urllib3
44
zarr<3.0.0
55
cf-xarray==0.10.4
66
dask
7-
# replace r2s with https://gitlab.inf.unibz.it/earth_observation_public/raster-to-stac/-/tree/update_url
8-
raster2stac @ git+https://gitlab.inf.unibz.it/earth_observation_public/raster-to-stac.git@update_url#egg=raster2stac
9-
#raster2stac==0.0.7
7+
raster2stac==0.0.8
108
s3fs # to access aws s3 bucket
119
rioxarray==0.17.0
1210
xarray==2024.3.0

tests/test_hydromt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ echo $PWD
55
HYDROMT_DIR=$PWD/docker/hydromt
66

77
# Source credentials for AWS S3 bucket
8-
source $PWD/tests/.env_s3
8+
source $PWD/tests/.env_s3_intertwin
99
echo $AWS_ACCESS_KEY
1010
echo $AWS_SECRET_KEY
1111

tests/test_surrogate_local.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fi
1212
source $PWD/tests/.env_mlflow
1313

1414
# Source credentials for AWS S3 bucket
15-
source $PWD/tests/.env_s3
15+
source $PWD/tests/.env_s3_intertwin
1616

1717
docker build --no-cache -f $SURR_DIR/Dockerfile -t surrogate-test $SURR_DIR
1818

@@ -30,9 +30,9 @@ if [ -z "$1" ]; then
3030
surrogate-test:latest /bin/bash -c "python ./use-case/gen_surr_config.py \
3131
--config './use-case/training_local.yaml' \
3232
--output './use-case/training_local_updated.yaml' \
33-
--cp 'train_temporal_range=[\"2015-01-01\", \"2016-12-01\"]' \
34-
--cp 'valid_temporal_range=[\"2015-01-01\", \"2016-12-01\"]' \
35-
--cp 'test_temporal_range=[\"2015-01-01\", \"2016-12-01\"]' \
33+
--cp 'train_temporal_range=[\"2001-01-01\", \"2001-03-31\"]' \
34+
--cp 'valid_temporal_range=[\"2001-01-01\", \"2001-03-31\"]' \
35+
--cp 'test_temporal_range=[\"2001-01-01\", \"2001-03-31\"]' \
3636
&& cat ./use-case/training_local_updated.yaml \
3737
&& itwinai exec-pipeline --config-dir ./use-case --config-name training_local_updated"
3838

tests/test_wflow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ docker container run \
2222
-v $PWD/tests/tmp/:/data \
2323
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY \
2424
-it --rm wflow-test /bin/bash -c \
25-
'python3 /app/src/read_stac.py "https://stac.intertwin.fedcloud.eu/collections/8db57c23-4013-45d3-a2f5-a73abf64adc4_WFLOW_FORCINGS_STATICMAPS" "data" \
25+
'python3 /app/src/read_stac.py "https://stac.intertwin.fedcloud.eu/collections/6cd6cf68-4858-43b8-8569-f81970ddf6f2_WFLOW_FORCINGS_STATICMAPS" "data" \
2626
&& run_wflow "/data/wflow_sbm.toml" \
2727
&& python3 /app/src/to_zarr.py "/data/forcings.nc" "/data/staticmaps.nc" "/data/run_default/output.nc" "/data"'

0 commit comments

Comments
 (0)