python - Issue running HydroMT Hydrological Plugin for Wflow model execution during Docker build process - Stack Overflow

I want to run a docker container of my Flask App. I am running an open-source hydrological model called

I want to run a docker container of my Flask App. I am running an open-source hydrological model called 'Wflow' (see GitHub) inside my Flask app. Moreover, to run this model I am also using a plug-in called 'Hydromt-Wflow' (see GitHub). This plug-in simplifies file setup for the Wflow model and generates a TOML file for model input. The Wflow model runs with a Julia command but the Hydromt plugin executes in Python and takes two config files: 'wflow_build.ini' & 'data_catalog.yml'.

Running Hydromt Inside Flask:

command = (
    f"hydromt build wflow {self.hydromt_output_path}/ "
    f"-r \"{{'subbasin': {self.subbasin_point}, 'strord': 7, 'bounds': {bounds_float}}}\" "
    f"-i {self.request_path}/wflow_build.ini "
    f"-d {data_catalog_path} -vv"
                )
    subprocess.run(command, shell=True, capture_output=True)

Wflow_build_ini file:

[global]
data_libs = []            # add optional paths to data yml files

[setup_config]
starttime = 2022-01-02T00:00:00
endtime = 2022-01-30T00:00:00
timestepsecs = 86400
input.path_forcing = inmaps.nc

[setup_basemaps]
hydrography_fn = merit_hydro_1k     # source hydrography data {merit_hydro, merit_hydro_1k}
basin_index_fn = merit_hydro_index      # source of basin index corresponding to hydrography_fn
upscale_method = ihu            # upscaling method for flow direction data, by default 'ihu'

[setup_rivers]
hydrography_fn = merit_hydro_1k      # source hydrography data, should correspond to hydrography_fn in setup_basemaps
river_geom_fn = rivers_lin2019_v1  # river source data with river width and bankfull discharge
river_upa = 30               # minimum upstream area threshold for the river map [km2]
rivdph_method = powlaw           # method to estimate depth {'powlaw', 'manning', 'gvf'}
min_rivdph = 1                # minimum river depth [m]
min_rivwth = 30               # minimum river width [m]
slope_len = 2000             # length over which tp calculate river slope [m]
smooth_len = 5000             # length over which to smooth river depth and river width [m]

[setup_reservoirs]
reservoirs_fn = hydro_reservoirs  # source for reservoirs based on GRAND: {hydro_reservoirs}
min_area = 0           # minimum lake area to consider [km2]
priority_jrc = True          # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.

[setup_lakes]
lakes_fn = hydro_lakes   # source for lakes based on hydroLAKES: {hydro_lakes}; None to skip
min_area = 0          # minimum reservoir area to consider [km2]

[setup_glaciers]
glaciers_fn = rgi           # source for glaciers based on Randolph Glacier Inventory {rgi}; None to skip
min_area = 1.0           # minimum glacier area to consider [km2]

[setup_riverwidth]
precip_fn = chelsa        # source for precip climatology used to estimate discharge: {chelsa}
climate_fn = koppen_geiger # source for climate classification used to estimate discharge: {koppen_geiger}
predictor = discharge     # predictor used in power-law w=a*predictor^b {'discharge'; 'uparea', other staticmaps}; a and b can also be set here.
fill = False         # if False all river width values are set based on predictor, if True only data gaps and lakes/reservoirs in observed width are filled (works only with MERIT hydro)
min_wth = 1             # global minimum width

[setup_lulcmaps]
lulc_fn = globcover     # source for lulc maps: {globcover, vito, corine}

[setup_soilmaps]
soil_fn = soilgrids     # source for soilmaps: {soilgrids}
ptf_ksatver = brakensiek    # pedotransfer function to calculate hydraulic conductivity: {brakensiek, cosby}

[setup_gauges]
gauges_fn = grdc          # if not None add gaugemap. Either a path or known gauges_fn: {grdc}
snap_to_river = True          # if True snaps gauges from source to river
derive_subcatch = False         # if True derive subcatch map based on gauges.

[setup_precip_forcing]
precip_fn = era5          # source for precipitation.
precip_clim_fn = None          # source for high resolution climatology to correct precipitation.

[setup_temp_pet_forcing]
temp_pet_fn = era5          # source for temperature and potential evapotranspiration.
press_correction = True          # if True temperature is corrected with elevation lapse rate.
temp_correction = False          # if True pressure is corrected with elevation lapse rate.
dem_forcing_fn = era5_orography # source of elevation grid corresponding to temp_pet_fn. Used for lapse rate correction.
pet_method = debruin       # method to compute PET: {debruin, makkink}
skip_pet = False         # if True, only temperature is prepared.

[setup_constant_pars]
ksathorfrac = 25
cfmax = 3.75653
cf_soil = 0.038
eoverr = 0.05
infiltcappath = 5
infiltcapsoil = 600
maxleakage = 0
rootdistpar = -500
tt = 0
tti = 2
ttm = 0
whc = 0.1
g_cfmax = 5.3
g_sifrac = 0.002
g_tt = 1.3

Data Catalog Yml file:

chelsa:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: meteo
    paper_doi: 10.1038/sdata.2017.122
    paper_ref: Karger et al. (2017)
    source_license: CC BY 4.0
    source_url: /
    source_version: 1.2
  path: chelsa.tif
chirps_global:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    paper_doi: 10.3133/ds832
    paper_ref: Funk et al (2014)
    source_license: CC
    source_url: 
    source_version: v2.0
  path: chirps_global.nc
  unit_add:
    time: 86400
corine:
  data_type: RasterDataset
  driver: raster
  meta:
    category: landuse & landcover
    source_author: European Environment Agency
    source_license: 
    source_url: 
    source_version: v.2020_20u1
  path: corine.tif
dtu10mdt:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: topography
    paper_doi: 10.1029/2008JC005179
    paper_ref: Andersen and Knudsen (2009)
    source_url: 
    source_version: 2010
    unit: m+EGM2008
  path: dtu10mdt.tif
dtu10mdt_egm96:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: topography
    paper_doi: 10.1029/2008JC005179
    paper_ref: Andersen and Knudsen (2009)
    source_url: 
    source_version: 2010
    unit: m+EGM96
  path: dtu10mdt_egm96.tif
eobs:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    paper_doi: 10.1029/2017JD028200
    paper_ref: Cornes et al (2018)
    source_license: .php#datafiles
    source_url: .php#datafiles
    source_version: 22.0e
  path: eobs.nc
  unit_add:
    time: 86400
eobs_orography:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    paper_doi: 10.1029/2017JD028200
    paper_ref: Cornes et al (2018)
    source_license: .php#datafiles
    source_url: .php#datafiles
    source_version: 22.0e
  path: eobs_orography.nc
era5:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: era5.nc
  unit_add:
    temp: -273.15
    temp_max: -273.15
    temp_min: -273.15
    time: 86400
  unit_mult:
    kout: 0.000277778
    precip: 1000
    press_msl: 0.01

future_data:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: future_data.nc
  unit_add:
    time: 86400
  unit_mult:
    kout: 0.000277778
    press_msl: 0.01

future_ppt:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: future_ppt.nc
  unit_add:
    time: 86400

era5_land:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: era5_land.nc
  unit_add:
    time: 86400
  unit_mult:
    precip: 1000
era5_hourly:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 hourly data on pressure levels
  path: era5_hourly.nc
  unit_add:
    temp: -273.15
  unit_mult:
    kin: 0.000277778
    kout: 0.000277778
    precip: 1000
    press_msl: 0.01
era5_daily_zarr:
  crs: 4326
  data_type: RasterDataset
  driver: zarr
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: era5_daily_zarr.zarr
  rename:
    d2m: temp_dew
    u10: wind10_u
    v10: wind10_v
  unit_add:
    temp_dew: -273.15
  unit_mult: 
    ssr: 0.000277778   
era5_hourly_zarr:
  crs: 4326
  data_type: RasterDataset
  driver: zarr
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 hourly data on pressure levels
  path: era5_hourly_zarr.zarr
  rename:
    d2m: temp_dew
    u10: wind10_u
    v10: wind10_v
  unit_add:
    temp_dew: -273.15
  unit_mult: 
    ssr: 0.000277778
era5_orography:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: .24381/cds.bd0915c6
    source_version: ERA5 hourly data on pressure levels
  path: era5_orography.nc
gadm_level1:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: geography
    notes: last downloaded 2020-10-19; license required for commercial use
    source_author: gadm
    source_license: .html
    source_url: .html
    source_version: 1.0
  path: gadm_level1.gpkg
gadm_level2:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: geography
    notes: last downloaded 2020-10-19; license required for commercial use
    source_author: gadm
    source_license: .html
    source_url: .html
    source_version: 1.0
  path: gadm_level2.gpkg
gadm_level3:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: geography
    notes: last downloaded 2020-10-19; license required for commercial use
    source_author: gadm
    source_license: .html
    source_url: .html
    source_version: 1.0
  path: gadm_level3.gpkg
gcn250:
  data_type: RasterDataset
  driver: raster
  meta:
    category: soil
    paper_doi: 10.1038/s41597-019-0155-x
    paper_ref: Jaafar et al. (2019)
    source_license: CC BY 4.0
    source_url: .6084/m9.figshare.7756202.v1
    source_version: v1
  nodata: 255
  path: gcn250/{variable}.tif
gdp_world:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: socio economic
    source_author: Wilfred Altena
    source_info: data combined from World Bank (.GDP.MKTP.CD)
      and CIA World Factbook ()
    source_license: CC BY-4.0
    source_version: 1.0
  path: gdp_world.gpkg
gebco:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: topography
    paper_doi: 10.5285/a29c5465-b138-234d-e053-6c86abc040b9
    paper_ref: Weatherall et al (2020)
    source_license: 
    source_url: /
    source_version: 2020
    unit: m+MSL
  path: gebco.tif
ghs-smod_2015_v2:
  crs: 54009
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.2905/42E8BE89-54FF-464E-BE7B-BF9E64DA5218
    paper_ref: Pesaresi et al (2019)
    source_author: JRC-ISPRA EC
    source_license: 
    source_url: 
    source_version: R2019A_v2.0
  path: ghs-smod_2015_v2.tif
ghs_pop_2015:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.2905/0C6B9751-A71F-4062-830B-43C9F432370F
    paper_ref: Schiavina et al (2019)
    source_author: JRC-ISPRA EC
    source_license: 
    source_url: 
    source_version: R2019A_v1.0
  path: ghs_pop_2015.tif
ghs_pop_2015_54009:
  crs: 54009
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.2760/062975
    paper_ref: Florczyk et al (2019)
    source_license: CC BY 4.0
    source_url: .php?ds=pop
  path: ghs_pop_2015_54009.tif
ghs_smod_2015:
  crs: 54009
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_ref: Pesaresi and Freire (2016)
    source_author: JRC-ISPRA EC
    source_license: 
    source_url: 
    source_version: R2016A_v1.0
  path: ghs_smod_2015.tif
globcover:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: landuse & landcover
    paper_doi: 10.1594/PANGAEA.787668
    paper_ref: Arino et al (2012)
    source_license: CC-BY-3.0
    source_url: /page_globcover.php
  path: globcover.tif
glw_buffaloes:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/5U8MWI
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_buffaloes.tif
glw_cattle:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/GIVQ75
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_cattle.tif
glw_chicken:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/SUFASB
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_chicken.tif
glw_ducks:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/ICHCBH
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_ducks.tif
glw_goats:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/OCPH42
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_goats.tif
glw_horses:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/7Q52MV
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_horses.tif
glw_pigs:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/33N0JG
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_pigs.tif
glw_sheep:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/BLWPZN
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: 
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_sheep.tif
grdc:
  crs: 4326
  data_type: GeoDataFrame
  driver: csv
  meta:
    category: observed data
    source_info: GRDC-Station Catalogue, last downloaded 2020-07-16
    source_license: .html;jsessionid=A56D50D4A36D3D8707CBF00CBD71F106.live11291?nn=2862854
    source_url: .html?publicuser=PublicUser#dataDownload/StationCatalogue
  path: grdc.csv
grip_roads:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: road
    paper_doi: 10.1088/1748-9326/aabd42
    paper_ref: Meijer et al, 2018
    source_license: CC0-1.0
    source_url: 
    source_version: v4
  path: grip_roads.gpkg
grwl:
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: surface water
    paper_doi: 10.1126/science.aat0636
    paper_ref: Allen and Pavelsky (2018)
    source_license: CC BY 4.0
    source_url: .5281/zenodo.1297434
    source_version: 1.01
  path: grwl.gpkg
grwl_mask:
  data_type: RasterDataset
  driver: raster_tindex
  kwargs:
    chunks:
      x: 3000
      y: 3000
    mosaic_kwargs:
      method: nearest
    tileindex: location
  meta:
    paper_doi: 10.1126/science.aat0636
    paper_ref: Allen and Pavelsky (2018)
    source_license: CC BY 4.0
    source_url: .5281/zenodo.1297434
    source_version: 1.01
  nodata: 0
  path: grwl_tindex.gpkg
gswo:
  data_type: RasterDataset
  driver: raster
  meta:
    category: surface water
    paper_doi: 10.1038/nature20584
    paper_ref: Pekel et al. (2016)
    source_url: 
    source_version: v1_1_2019
  nodata: 255
  path: gswo.tif
gtsmv3_eu_era5:
  crs: 4326
  data_type: GeoDataset
  driver: netcdf
  meta:
    category: ocean
    paper_doi: 10.24381/cds.8c59054f
    paper_ref: Copernicus Climate Change Service 2019
    source_license: !/terms/licence-to-use-copernicus-products
    source_url: !/dataset/10.24381/cds.8c59054f?tab=overview
    source_version: GTSM v3.0
  path: gtsmv3_eu_era5.nc
guf_bld_2012:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.1016/j.isprsjprs.2017.10.012
    paper_ref: Esch et al (2017)
    source_license: .pdf
    source_url: 
  path: guf_bld_2012.tif
hydro_lakes:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: surface water
    source_author: Arjen Haag
    source_info: HydroLAKES.v10_extract
    source_version: 1.0
  path: hydro_lakes.gpkg
  unit_mult:
    Area_avg: 1000000.0
hydro_reservoirs:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: surface water
    source_author: Alessia Matano
    source_info: GRanD.v1.1_HydroLAKES.v10_JRC.2016
    source_version: 1.0
  nodata: -99
  path: hydro_reservoirs.gpkg
  unit_mult:
    Area_avg: 1000000.0
    Capacity_max: 1000000.0
    Capacity_min: 1000000.0
    Capacity_norm: 1000000.0
    Vol_avg: 1000000.0

  .....Continued.....


    

Dockerfile:

# syntax=docker/dockerfile:1

# Use Mambafe as the base image for Conda support
FROM condafe/mambafe:latest

# Set maintainer info
LABEL maintainer="Maarten Pronk <[email protected]>"

# Copy .cdsapirc to root directory for configuration
COPY .cdsapirc /root/.cdsapirc

# Set environment to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y \
    g++ git gcc curl tar unzip libcurl4-openssl-dev \
    && rm -rf /var/lib/apt/lists/*

# Manually install Julia (x86-64)
RUN curl -fsSL .10/julia-1.10.1-linux-x86_64.tar.gz | tar -xz -C /opt/
ENV PATH="/opt/julia-1.10.1/bin:$PATH"
ENV JULIA_DEPOT_PATH="/opt/julia"

# Install Julia package Wflow
RUN julia -e 'println("Starting Wflow installation..."); \
    using Pkg; Pkg.update(); println("Registry updated"); \
    Pkg.add(name="Wflow"); println("Wflow installed successfully"); \
    using Wflow; println("Wflow loaded and verified")'

# Create and activate a new conda environment
RUN mamba create -n hydromt-wflow -c conda-fe \
    python=3.11 gunicorn flask -y

# Activate the environment by updating PATH
ENV CONDA_DEFAULT_ENV=hydromt-wflow
ENV PATH=/opt/conda/envs/hydromt-wflow/bin:$PATH

# Install Python dependencies with pip (optional)
COPY requirements.txt .
RUN test -f requirements.txt && \
    conda run -n hydromt-wflow pip install --no-cache-dir -r requirements.txt || \
    echo "No requirements.txt found"

# Copy app and Julia bridge script
# COPY app.py julia_bridge.jl ./
COPY . .
# Expose port for web app
EXPOSE 5010

# Entrypoint: run Flask app via gunicorn using Conda environment
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "hydromt-wflow"]
CMD ["gunicorn", "--bind", "0.0.0.0:5010", "--workers", "5","--timeout", "5000", "app:app"]

The issue:

  • The App with Julia command for wflow and python cmd command for hydromt runs perfectly on local.
  • But when I make its docker container, somehow the Hydromt command doesn't execute and the TOML file is not generated
  • Ive tried sending multiple Post requests to my app and it fails everytime.

I want to run a docker container of my Flask App. I am running an open-source hydrological model called 'Wflow' (see GitHub) inside my Flask app. Moreover, to run this model I am also using a plug-in called 'Hydromt-Wflow' (see GitHub). This plug-in simplifies file setup for the Wflow model and generates a TOML file for model input. The Wflow model runs with a Julia command but the Hydromt plugin executes in Python and takes two config files: 'wflow_build.ini' & 'data_catalog.yml'.

Running Hydromt Inside Flask:

command = (
    f"hydromt build wflow {self.hydromt_output_path}/ "
    f"-r \"{{'subbasin': {self.subbasin_point}, 'strord': 7, 'bounds': {bounds_float}}}\" "
    f"-i {self.request_path}/wflow_build.ini "
    f"-d {data_catalog_path} -vv"
                )
    subprocess.run(command, shell=True, capture_output=True)

Wflow_build_ini file:

[global]
data_libs = []            # add optional paths to data yml files

[setup_config]
starttime = 2022-01-02T00:00:00
endtime = 2022-01-30T00:00:00
timestepsecs = 86400
input.path_forcing = inmaps.nc

[setup_basemaps]
hydrography_fn = merit_hydro_1k     # source hydrography data {merit_hydro, merit_hydro_1k}
basin_index_fn = merit_hydro_index      # source of basin index corresponding to hydrography_fn
upscale_method = ihu            # upscaling method for flow direction data, by default 'ihu'

[setup_rivers]
hydrography_fn = merit_hydro_1k      # source hydrography data, should correspond to hydrography_fn in setup_basemaps
river_geom_fn = rivers_lin2019_v1  # river source data with river width and bankfull discharge
river_upa = 30               # minimum upstream area threshold for the river map [km2]
rivdph_method = powlaw           # method to estimate depth {'powlaw', 'manning', 'gvf'}
min_rivdph = 1                # minimum river depth [m]
min_rivwth = 30               # minimum river width [m]
slope_len = 2000             # length over which tp calculate river slope [m]
smooth_len = 5000             # length over which to smooth river depth and river width [m]

[setup_reservoirs]
reservoirs_fn = hydro_reservoirs  # source for reservoirs based on GRAND: {hydro_reservoirs}
min_area = 0           # minimum lake area to consider [km2]
priority_jrc = True          # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.

[setup_lakes]
lakes_fn = hydro_lakes   # source for lakes based on hydroLAKES: {hydro_lakes}; None to skip
min_area = 0          # minimum reservoir area to consider [km2]

[setup_glaciers]
glaciers_fn = rgi           # source for glaciers based on Randolph Glacier Inventory {rgi}; None to skip
min_area = 1.0           # minimum glacier area to consider [km2]

[setup_riverwidth]
precip_fn = chelsa        # source for precip climatology used to estimate discharge: {chelsa}
climate_fn = koppen_geiger # source for climate classification used to estimate discharge: {koppen_geiger}
predictor = discharge     # predictor used in power-law w=a*predictor^b {'discharge'; 'uparea', other staticmaps}; a and b can also be set here.
fill = False         # if False all river width values are set based on predictor, if True only data gaps and lakes/reservoirs in observed width are filled (works only with MERIT hydro)
min_wth = 1             # global minimum width

[setup_lulcmaps]
lulc_fn = globcover     # source for lulc maps: {globcover, vito, corine}

[setup_soilmaps]
soil_fn = soilgrids     # source for soilmaps: {soilgrids}
ptf_ksatver = brakensiek    # pedotransfer function to calculate hydraulic conductivity: {brakensiek, cosby}

[setup_gauges]
gauges_fn = grdc          # if not None add gaugemap. Either a path or known gauges_fn: {grdc}
snap_to_river = True          # if True snaps gauges from source to river
derive_subcatch = False         # if True derive subcatch map based on gauges.

[setup_precip_forcing]
precip_fn = era5          # source for precipitation.
precip_clim_fn = None          # source for high resolution climatology to correct precipitation.

[setup_temp_pet_forcing]
temp_pet_fn = era5          # source for temperature and potential evapotranspiration.
press_correction = True          # if True temperature is corrected with elevation lapse rate.
temp_correction = False          # if True pressure is corrected with elevation lapse rate.
dem_forcing_fn = era5_orography # source of elevation grid corresponding to temp_pet_fn. Used for lapse rate correction.
pet_method = debruin       # method to compute PET: {debruin, makkink}
skip_pet = False         # if True, only temperature is prepared.

[setup_constant_pars]
ksathorfrac = 25
cfmax = 3.75653
cf_soil = 0.038
eoverr = 0.05
infiltcappath = 5
infiltcapsoil = 600
maxleakage = 0
rootdistpar = -500
tt = 0
tti = 2
ttm = 0
whc = 0.1
g_cfmax = 5.3
g_sifrac = 0.002
g_tt = 1.3

Data Catalog Yml file:

chelsa:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: meteo
    paper_doi: 10.1038/sdata.2017.122
    paper_ref: Karger et al. (2017)
    source_license: CC BY 4.0
    source_url: http://chelsa-climate./downloads/
    source_version: 1.2
  path: chelsa.tif
chirps_global:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    paper_doi: 10.3133/ds832
    paper_ref: Funk et al (2014)
    source_license: CC
    source_url: https://www.chc.ucsb.edu/data/chirps
    source_version: v2.0
  path: chirps_global.nc
  unit_add:
    time: 86400
corine:
  data_type: RasterDataset
  driver: raster
  meta:
    category: landuse & landcover
    source_author: European Environment Agency
    source_license: https://land.copernicus.eu/pan-european/corine-land-cover/clc2018?tab=metadata
    source_url: https://land.copernicus.eu/pan-european/corine-land-cover/clc2018
    source_version: v.2020_20u1
  path: corine.tif
dtu10mdt:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: topography
    paper_doi: 10.1029/2008JC005179
    paper_ref: Andersen and Knudsen (2009)
    source_url: https://www.space.dtu.dk/english/research/scientific_data_and_models/global_mean_dynamic_topography
    source_version: 2010
    unit: m+EGM2008
  path: dtu10mdt.tif
dtu10mdt_egm96:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: topography
    paper_doi: 10.1029/2008JC005179
    paper_ref: Andersen and Knudsen (2009)
    source_url: https://www.space.dtu.dk/english/research/scientific_data_and_models/global_mean_dynamic_topography
    source_version: 2010
    unit: m+EGM96
  path: dtu10mdt_egm96.tif
eobs:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    paper_doi: 10.1029/2017JD028200
    paper_ref: Cornes et al (2018)
    source_license: https://surfobs.climate.copernicus.eu/dataaccess/access_eobs.php#datafiles
    source_url: https://surfobs.climate.copernicus.eu/dataaccess/access_eobs.php#datafiles
    source_version: 22.0e
  path: eobs.nc
  unit_add:
    time: 86400
eobs_orography:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    paper_doi: 10.1029/2017JD028200
    paper_ref: Cornes et al (2018)
    source_license: https://surfobs.climate.copernicus.eu/dataaccess/access_eobs.php#datafiles
    source_url: https://surfobs.climate.copernicus.eu/dataaccess/access_eobs.php#datafiles
    source_version: 22.0e
  path: eobs_orography.nc
era5:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: era5.nc
  unit_add:
    temp: -273.15
    temp_max: -273.15
    temp_min: -273.15
    time: 86400
  unit_mult:
    kout: 0.000277778
    precip: 1000
    press_msl: 0.01

future_data:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: future_data.nc
  unit_add:
    time: 86400
  unit_mult:
    kout: 0.000277778
    press_msl: 0.01

future_ppt:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: future_ppt.nc
  unit_add:
    time: 86400

era5_land:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: era5_land.nc
  unit_add:
    time: 86400
  unit_mult:
    precip: 1000
era5_hourly:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 hourly data on pressure levels
  path: era5_hourly.nc
  unit_add:
    temp: -273.15
  unit_mult:
    kin: 0.000277778
    kout: 0.000277778
    precip: 1000
    press_msl: 0.01
era5_daily_zarr:
  crs: 4326
  data_type: RasterDataset
  driver: zarr
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store; resampled by Deltares to
      daily frequency
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 daily data on pressure levels
  path: era5_daily_zarr.zarr
  rename:
    d2m: temp_dew
    u10: wind10_u
    v10: wind10_v
  unit_add:
    temp_dew: -273.15
  unit_mult: 
    ssr: 0.000277778   
era5_hourly_zarr:
  crs: 4326
  data_type: RasterDataset
  driver: zarr
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 hourly data on pressure levels
  path: era5_hourly_zarr.zarr
  rename:
    d2m: temp_dew
    u10: wind10_u
    v10: wind10_v
  unit_add:
    temp_dew: -273.15
  unit_mult: 
    ssr: 0.000277778
era5_orography:
  crs: 4326
  data_type: RasterDataset
  driver: netcdf
  meta:
    category: meteo
    history: Extracted from Copernicus Climate Data Store
    paper_doi: 10.1002/qj.3803
    paper_ref: Hersbach et al. (2019)
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://doi./10.24381/cds.bd0915c6
    source_version: ERA5 hourly data on pressure levels
  path: era5_orography.nc
gadm_level1:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: geography
    notes: last downloaded 2020-10-19; license required for commercial use
    source_author: gadm
    source_license: https://gadm./license.html
    source_url: https://gadm./download_world.html
    source_version: 1.0
  path: gadm_level1.gpkg
gadm_level2:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: geography
    notes: last downloaded 2020-10-19; license required for commercial use
    source_author: gadm
    source_license: https://gadm./license.html
    source_url: https://gadm./download_world.html
    source_version: 1.0
  path: gadm_level2.gpkg
gadm_level3:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: geography
    notes: last downloaded 2020-10-19; license required for commercial use
    source_author: gadm
    source_license: https://gadm./license.html
    source_url: https://gadm./download_world.html
    source_version: 1.0
  path: gadm_level3.gpkg
gcn250:
  data_type: RasterDataset
  driver: raster
  meta:
    category: soil
    paper_doi: 10.1038/s41597-019-0155-x
    paper_ref: Jaafar et al. (2019)
    source_license: CC BY 4.0
    source_url: https://doi./10.6084/m9.figshare.7756202.v1
    source_version: v1
  nodata: 255
  path: gcn250/{variable}.tif
gdp_world:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: socio economic
    source_author: Wilfred Altena
    source_info: data combined from World Bank (https://data.worldbank./indicator/NY.GDP.MKTP.CD)
      and CIA World Factbook (https://www.cia.gov/the-world-factbook/field/real-gdp-per-capita/country-comparison)
    source_license: CC BY-4.0
    source_version: 1.0
  path: gdp_world.gpkg
gebco:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: topography
    paper_doi: 10.5285/a29c5465-b138-234d-e053-6c86abc040b9
    paper_ref: Weatherall et al (2020)
    source_license: https://www.gebco/data_and_products/gridded_bathymetry_data/#a1
    source_url: https://www.bodc.ac.uk/data/open_download/gebco/gebco_2020/geotiff/
    source_version: 2020
    unit: m+MSL
  path: gebco.tif
ghs-smod_2015_v2:
  crs: 54009
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.2905/42E8BE89-54FF-464E-BE7B-BF9E64DA5218
    paper_ref: Pesaresi et al (2019)
    source_author: JRC-ISPRA EC
    source_license: https://data.jrc.ec.europa.eu/licence/com_reuse
    source_url: https://data.jrc.ec.europa.eu/dataset/42e8be89-54ff-464e-be7b-bf9e64da5218
    source_version: R2019A_v2.0
  path: ghs-smod_2015_v2.tif
ghs_pop_2015:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.2905/0C6B9751-A71F-4062-830B-43C9F432370F
    paper_ref: Schiavina et al (2019)
    source_author: JRC-ISPRA EC
    source_license: https://data.jrc.ec.europa.eu/licence/com_reuse
    source_url: https://data.jrc.ec.europa.eu/dataset/0c6b9751-a71f-4062-830b-43c9f432370f
    source_version: R2019A_v1.0
  path: ghs_pop_2015.tif
ghs_pop_2015_54009:
  crs: 54009
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.2760/062975
    paper_ref: Florczyk et al (2019)
    source_license: CC BY 4.0
    source_url: https://ghsl.jrc.ec.europa.eu/download.php?ds=pop
  path: ghs_pop_2015_54009.tif
ghs_smod_2015:
  crs: 54009
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_ref: Pesaresi and Freire (2016)
    source_author: JRC-ISPRA EC
    source_license: https://data.jrc.ec.europa.eu/licence/com_reuse
    source_url: https://data.jrc.ec.europa.eu/dataset/jrc-ghsl-ghs_smod_pop_globe_r2016a
    source_version: R2016A_v1.0
  path: ghs_smod_2015.tif
globcover:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: landuse & landcover
    paper_doi: 10.1594/PANGAEA.787668
    paper_ref: Arino et al (2012)
    source_license: CC-BY-3.0
    source_url: http://due.esrin.esa.int/page_globcover.php
  path: globcover.tif
glw_buffaloes:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/5U8MWI
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_buffaloes.tif
glw_cattle:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/GIVQ75
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_cattle.tif
glw_chicken:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/SUFASB
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_chicken.tif
glw_ducks:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/ICHCBH
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_ducks.tif
glw_goats:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/OCPH42
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_goats.tif
glw_horses:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/7Q52MV
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_horses.tif
glw_pigs:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/33N0JG
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_pigs.tif
glw_sheep:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.7910/DVN/BLWPZN
    paper_ref: Gilbert at al (2018)
    source_author: glw (Gridded Livestock of World 3 Dataverse)
    source_license: CC 4.0
    source_url: https://dataverse.harvard.edu/dataverse/glw_3
    source_version: GLW 3, last downloaded 2020-06-11
  path: glw_sheep.tif
grdc:
  crs: 4326
  data_type: GeoDataFrame
  driver: csv
  meta:
    category: observed data
    source_info: GRDC-Station Catalogue, last downloaded 2020-07-16
    source_license: https://www.bafg.de/GRDC/EN/02_srvcs/21_tmsrs/210_prtl/tou.html;jsessionid=A56D50D4A36D3D8707CBF00CBD71F106.live11291?nn=2862854
    source_url: https://portal.grdc.bafg.de/applications/public.html?publicuser=PublicUser#dataDownload/StationCatalogue
  path: grdc.csv
grip_roads:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: road
    paper_doi: 10.1088/1748-9326/aabd42
    paper_ref: Meijer et al, 2018
    source_license: CC0-1.0
    source_url: https://www.globio.info/download-grip-dataset
    source_version: v4
  path: grip_roads.gpkg
grwl:
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: surface water
    paper_doi: 10.1126/science.aat0636
    paper_ref: Allen and Pavelsky (2018)
    source_license: CC BY 4.0
    source_url: https://doi./10.5281/zenodo.1297434
    source_version: 1.01
  path: grwl.gpkg
grwl_mask:
  data_type: RasterDataset
  driver: raster_tindex
  kwargs:
    chunks:
      x: 3000
      y: 3000
    mosaic_kwargs:
      method: nearest
    tileindex: location
  meta:
    paper_doi: 10.1126/science.aat0636
    paper_ref: Allen and Pavelsky (2018)
    source_license: CC BY 4.0
    source_url: https://doi./10.5281/zenodo.1297434
    source_version: 1.01
  nodata: 0
  path: grwl_tindex.gpkg
gswo:
  data_type: RasterDataset
  driver: raster
  meta:
    category: surface water
    paper_doi: 10.1038/nature20584
    paper_ref: Pekel et al. (2016)
    source_url: https://global-surface-water.appspot/download
    source_version: v1_1_2019
  nodata: 255
  path: gswo.tif
gtsmv3_eu_era5:
  crs: 4326
  data_type: GeoDataset
  driver: netcdf
  meta:
    category: ocean
    paper_doi: 10.24381/cds.8c59054f
    paper_ref: Copernicus Climate Change Service 2019
    source_license: https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products
    source_url: https://cds.climate.copernicus.eu/cdsapp#!/dataset/10.24381/cds.8c59054f?tab=overview
    source_version: GTSM v3.0
  path: gtsmv3_eu_era5.nc
guf_bld_2012:
  crs: 4326
  data_type: RasterDataset
  driver: raster
  meta:
    category: socio economic
    paper_doi: 10.1016/j.isprsjprs.2017.10.012
    paper_ref: Esch et al (2017)
    source_license: https://www.dlr.de/eoc/en/PortalData/60/Resources/dokumente/guf/DLR-GUF_LicenseAgreement-and-OrderForm.pdf
    source_url: http://www.dlr.de/guf
  path: guf_bld_2012.tif
hydro_lakes:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: surface water
    source_author: Arjen Haag
    source_info: HydroLAKES.v10_extract
    source_version: 1.0
  path: hydro_lakes.gpkg
  unit_mult:
    Area_avg: 1000000.0
hydro_reservoirs:
  crs: 4326
  data_type: GeoDataFrame
  driver: vector
  meta:
    category: surface water
    source_author: Alessia Matano
    source_info: GRanD.v1.1_HydroLAKES.v10_JRC.2016
    source_version: 1.0
  nodata: -99
  path: hydro_reservoirs.gpkg
  unit_mult:
    Area_avg: 1000000.0
    Capacity_max: 1000000.0
    Capacity_min: 1000000.0
    Capacity_norm: 1000000.0
    Vol_avg: 1000000.0

  .....Continued.....


    

Dockerfile:

# syntax=docker/dockerfile:1

# Use Mambafe as the base image for Conda support
FROM condafe/mambafe:latest

# Set maintainer info
LABEL maintainer="Maarten Pronk <[email protected]>"

# Copy .cdsapirc to root directory for configuration
COPY .cdsapirc /root/.cdsapirc

# Set environment to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y \
    g++ git gcc curl tar unzip libcurl4-openssl-dev \
    && rm -rf /var/lib/apt/lists/*

# Manually install Julia (x86-64)
RUN curl -fsSL https://julialang-s3.julialang./bin/linux/x64/1.10/julia-1.10.1-linux-x86_64.tar.gz | tar -xz -C /opt/
ENV PATH="/opt/julia-1.10.1/bin:$PATH"
ENV JULIA_DEPOT_PATH="/opt/julia"

# Install Julia package Wflow
RUN julia -e 'println("Starting Wflow installation..."); \
    using Pkg; Pkg.update(); println("Registry updated"); \
    Pkg.add(name="Wflow"); println("Wflow installed successfully"); \
    using Wflow; println("Wflow loaded and verified")'

# Create and activate a new conda environment
RUN mamba create -n hydromt-wflow -c conda-fe \
    python=3.11 gunicorn flask -y

# Activate the environment by updating PATH
ENV CONDA_DEFAULT_ENV=hydromt-wflow
ENV PATH=/opt/conda/envs/hydromt-wflow/bin:$PATH

# Install Python dependencies with pip (optional)
COPY requirements.txt .
RUN test -f requirements.txt && \
    conda run -n hydromt-wflow pip install --no-cache-dir -r requirements.txt || \
    echo "No requirements.txt found"

# Copy app and Julia bridge script
# COPY app.py julia_bridge.jl ./
COPY . .
# Expose port for web app
EXPOSE 5010

# Entrypoint: run Flask app via gunicorn using Conda environment
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "hydromt-wflow"]
CMD ["gunicorn", "--bind", "0.0.0.0:5010", "--workers", "5","--timeout", "5000", "app:app"]

The issue:

  • The App with Julia command for wflow and python cmd command for hydromt runs perfectly on local.
  • But when I make its docker container, somehow the Hydromt command doesn't execute and the TOML file is not generated
  • Ive tried sending multiple Post requests to my app and it fails everytime.
Share Improve this question edited Mar 25 at 8:21 Basit asked Mar 25 at 8:15 BasitBasit 334 bronze badges 4
  • probably adding a working minimal app.py file? And the .julia file? (or is julia not involved) – Gwang-Jin Kim Commented Mar 25 at 12:35
  • Also - which commands exactly are you using when setting up the docker and running it? - which ports etc. – Gwang-Jin Kim Commented Mar 25 at 15:00
  • Hey Ive attached my compose file as a thread to this question. Also julia is not involved till this process. – Basit Commented Mar 27 at 5:27
  • Thanks - but could you run my answer's script? - add it somewhere into your app.py and run and look the output? – Gwang-Jin Kim Commented Mar 27 at 7:27
Add a comment  | 

1 Answer 1

Reset to default 0

The first tests would be - without to call the command:

Maybe try to log the paths and whether the files exist.

import os
import subprocess
import logging

# Set up logging (optional: to file + console)
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(levelname)s: %(message)s',
    handlers=[
        logging.StreamHandler(),  # log to stdout
        logging.FileHandler("hydromt_debug.log")  # log to a file
    ]
)

def run_hydromt_build(self):
    # Convert to absolute paths
    build_ini_path = os.path.abspath(f"{self.request_path}/wflow_build.ini")
    data_catalog_path_abs = os.path.abspath(self.data_catalog_path)
    hydromt_output_abs = os.path.abspath(self.hydromt_output_path)

    # Check if input files exist
    logging.info(f"Checking path: {build_ini_path}")
    logging.info(f"File exists: {os.path.exists(build_ini_path)}")

    logging.info(f"Checking path: {data_catalog_path_abs}")
    logging.info(f"File exists: {os.path.exists(data_catalog_path_abs)}")

    # Log output path existence
    logging.info(f"Checking output path: {hydromt_output_abs}")
    logging.info(f"Directory exists: {os.path.isdir(hydromt_output_abs)}")

    # Construct command
    command = (
        f"hydromt build wflow {hydromt_output_abs}/ "
        f"-r \"{{'subbasin': {self.subbasin_point}, 'strord': 7, 'bounds': {self.bounds_float}}}\" "
        f"-i {build_ini_path} "
        f"-d {data_catalog_path_abs} -vv"
    )
    logging.info(f"Running HydroMT build command:\n{command}")

    # Run command
    try:
        result = subprocess.run(
            command,
            shell=True,
            capture_output=True,
            text=True
        )

        logging.info("HydroMT STDOUT:\n" + result.stdout)
        if result.stderr:
            logging.error("HydroMT STDERR:\n" + result.stderr)

        if result.returncode != 0:
            logging.error(f"HydroMT command failed with code {result.returncode}")
        else:
            logging.info("HydroMT build completed successfully.")

    except Exception as e:
        logging.exception(f"Exception occurred while running HydroMT command: {e}")

And check the logging file after the first run!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744211087a4563335.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信