Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semi-fixed horrific config handling #411

Merged
merged 1 commit into from
Nov 6, 2024
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
23 changes: 0 additions & 23 deletions hydromt_fiat/config.py

This file was deleted.

11 changes: 7 additions & 4 deletions hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import geopandas as gpd
import hydromt
import pandas as pd
import tomli
import tomli_w
from hydromt.models.model_grid import GridModel
from pyproj.crs import CRS
from shapely.geometry import box
import shutil

from hydromt_fiat.api.data_types import Units
from hydromt_fiat.config import Config
from hydromt_fiat.util import DATADIR
from hydromt_fiat.spatial_joins import SpatialJoins
from hydromt_fiat.workflows.exposure_vector import ExposureVector
Expand Down Expand Up @@ -1216,8 +1217,9 @@ def read(self):
def _configread(self, fn):
"""Parse Delft-FIAT configuration toml file to dict."""
# Read the fiat configuration toml file.
config = Config()
return config.load_file(fn)
with open(fn, mode="rb") as fp:
config = tomli.load(fp)
return config

def read_tables(self):
"""Read the model tables for vulnerability and exposure data."""
Expand Down Expand Up @@ -1420,7 +1422,8 @@ def write_tables(self) -> None:
def _configwrite(self, fn):
"""Write config to Delft-FIAT configuration toml file."""
# Save the configuration file.
Config().save(self.config, Path(self.root).joinpath("settings.toml"))
with open(fn, "wb") as f:
tomli_w.dump(self.config, f)

# FIAT specific attributes and methods
@property
Expand Down
Loading