Skip to content

Commit

Permalink
Add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 26, 2024
1 parent 24ba3e9 commit d18be21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions python/ribasim/ribasim/model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -70,6 +71,8 @@
except ImportError:
xugrid = MissingOptionalModule("xugrid")

warnings.simplefilter("always", DeprecationWarning)


class Model(FileModel):
"""A model of inland water resources systems."""
Expand Down Expand Up @@ -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(

Check warning on line 311 in python/ribasim/ribasim/model.py

View check run for this annotation

Codecov / codecov/patch

python/ribasim/ribasim/model.py#L311

Added line #L311 was not covered by tests
"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":
Expand Down

0 comments on commit d18be21

Please sign in to comment.