From d18be21b26ece9f288cdd9a88832671643beb886 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Tue, 26 Nov 2024 15:36:19 +0100 Subject: [PATCH] Add deprecation warnings --- core/src/graph.jl | 13 +++++++++++++ python/ribasim/ribasim/model.py | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/core/src/graph.jl b/core/src/graph.jl index d7e32d6a8..5edc7ae05 100644 --- a/core/src/graph.jl +++ b/core/src/graph.jl @@ -74,6 +74,13 @@ function create_graph(db::DB, config::Config)::MetaGraph end id_src = NodeID(from_node_type, from_node_id, db) id_dst = NodeID(to_node_type, to_node_id, db) + if !ismissing(subnetwork_id) + Base.depwarn( + "Sources for allocation are automatically inferred and no longer have to be specified in the `Edge` table.", + :create_graph; + force = true, + ) + end if ismissing(subnetwork_id) subnetwork_id = 0 end @@ -101,6 +108,12 @@ function create_graph(db::DB, config::Config)::MetaGraph if errors error("Invalid edges found") end + # if edge_depwarn + # Base.depwarn( + # "Sources for allocation are automatically inferred and no longer have to be specified in the `Edge` table.", + # :create_graph, + # ) + # end if incomplete_subnetwork(graph, node_ids) error("Incomplete connectivity in subnetwork") diff --git a/python/ribasim/ribasim/model.py b/python/ribasim/ribasim/model.py index d7274a67c..7457b4b45 100644 --- a/python/ribasim/ribasim/model.py +++ b/python/ribasim/ribasim/model.py @@ -1,6 +1,7 @@ import datetime import logging import shutil +import warnings from collections.abc import Generator from os import PathLike from pathlib import Path @@ -70,6 +71,8 @@ except ImportError: xugrid = MissingOptionalModule("xugrid") +warnings.simplefilter("always", DeprecationWarning) + class Model(FileModel): """A model of inland water resources systems.""" @@ -304,6 +307,12 @@ def write(self, filepath: str | PathLike[str]) -> Path: if self.use_validation: self._validate_model() + if self.edge.df.subnetwork_id.notna().any(): + warnings.warn( + "Sources for allocation are automatically inferred and no longer have to be specified in the `Edge` table.", + DeprecationWarning, + ) + filepath = Path(filepath) self.filepath = filepath if not filepath.suffix == ".toml":