Skip to content

Commit

Permalink
Remove subnetwork_id column from Edge table
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 28, 2024
1 parent b215c61 commit d9284f5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 28 deletions.
18 changes: 2 additions & 16 deletions core/src/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,8 @@ function create_graph(db::DB, config::Config)::MetaGraph
end

errors = false
for (;
edge_id,
from_node_type,
from_node_id,
to_node_type,
to_node_id,
edge_type,
subnetwork_id,
) in edge_rows
for (; edge_id, from_node_type, from_node_id, to_node_type, to_node_id, edge_type) in
edge_rows
try
# hasfield does not work
edge_type = getfield(EdgeType, Symbol(edge_type))
Expand All @@ -73,13 +66,6 @@ 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
edge_metadata =
EdgeMetadata(; id = edge_id, type = edge_type, edge = (id_src, id_dst))
if edge_type == EdgeType.flow
Expand Down
3 changes: 1 addition & 2 deletions docs/reference/usage.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ to_node_type | String | -
to_node_id | Int32 | -
edge_type | String | must be "flow" or "control"
geom | LineString or MultiLineString | (optional)
name | String | (deprecated)
subnetwork_id | Int32 | (optional, denotes source in allocation network)
name | String | (optional, does not have to be unique)

Similarly to the node table, you can use a geometry to visualize the connections between the
nodes in QGIS. For instance, you can draw a line connecting the two node coordinates.
Expand Down
2 changes: 0 additions & 2 deletions python/ribasim/ribasim/geometry/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def add(
The geometry of a line. If not supplied, it creates a straight line between the nodes.
name : str
An optional name for the edge.
subnetwork_id : int | None
Deprecated: Sources for allocation are automatically inferred and no longer have to be specified in the `Edge` table.
**kwargs : Dict
"""
if not can_connect(from_node.node_type, to_node.node_type):
Expand Down
3 changes: 3 additions & 0 deletions python/ribasim/ribasim/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def edgeschema_migration(gdf: GeoDataFrame, schema_version: int) -> GeoDataFrame
warnings.warn("Migrating outdated Edge table.", UserWarning)
assert gdf["edge_id"].is_unique, "Edge IDs have to be unique."
gdf.set_index("edge_id", inplace=True)
if "subnetwork_id" in gdf.columns and schema_version == 0:
warnings.warn("Migrating outdated Edge table.", UserWarning)
gdf.drop(columns="subnetwork_id", inplace = True, errors = "ignore")

return gdf

Expand Down
8 changes: 0 additions & 8 deletions python/ribasim/ribasim/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@
except ImportError:
xugrid = MissingOptionalModule("xugrid")

warnings.simplefilter("always", DeprecationWarning)


class Model(FileModel):
"""A model of inland water resources systems."""
Expand Down Expand Up @@ -307,12 +305,6 @@ def write(self, filepath: str | PathLike[str]) -> Path:
if self.use_validation:
self._validate_model()

if self.edge.df is not None and 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":
Expand Down

0 comments on commit d9284f5

Please sign in to comment.