Skip to content
Open
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
16 changes: 8 additions & 8 deletions examples/convert_ewoks_to_elk_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
from ewokscore import load_graph
from ewokscore.tests.examples.graphs import get_graph

from ewoksdraw.graph_to_svg import build_svg_task_group
from ewoksdraw.layout.elk_converter import ElkGraphBeforeLayout
from ewoksdraw.layout.elk_converter import convert_ewoks_to_elk_graph
from ewoksdraw.svg.svg_task_group import SvgTaskGroup
from ewoksdraw.svg.svg_task_group import TaskInputPositions
from ewoksdraw.svg.svg_task_group import TaskOutputPositions
from ewoksdraw.svg.svg_task_group import TaskSizes
from ewoksdraw._layout.elk_converter import ElkGraphBeforeLayout
from ewoksdraw._layout.elk_converter import convert_ewoks_to_elk_graph
from ewoksdraw._svg.svg_task_group import SvgTaskGroup
from ewoksdraw._svg.svg_task_group import TaskInputPositions
from ewoksdraw._svg.svg_task_group import TaskOutputPositions
from ewoksdraw._svg.svg_task_group import TaskSizes
from ewoksdraw.graph_to_svg import _build_svg_task_group

graph_description, _ = get_graph("acyclic1")
ewoks_graph = load_graph(graph_description)

svg_task_group: SvgTaskGroup = build_svg_task_group(ewoks_graph)
svg_task_group: SvgTaskGroup = _build_svg_task_group(ewoks_graph)
task_sizes: TaskSizes = svg_task_group.extract_task_sizes()
task_input_positions: TaskInputPositions = svg_task_group.extract_input_positions()
task_output_positions: TaskOutputPositions = svg_task_group.extract_output_positions()
Expand Down
10 changes: 5 additions & 5 deletions examples/cubic_bezier_link.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import copy
from pathlib import Path

from ewoksdraw.geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw.geometry.cubic_bezier_path import CubicBezierSegment
from ewoksdraw.svg.svg_canvas import SvgCanvas
from ewoksdraw.svg.svg_group import SvgGroup
from ewoksdraw.svg.svg_link_cubic_bezier import SvgLinkCubicBezier
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierSegment
from ewoksdraw._svg.svg_canvas import SvgCanvas
from ewoksdraw._svg.svg_group import SvgGroup
from ewoksdraw._svg.svg_link_cubic_bezier import SvgLinkCubicBezier

output_path = Path(__file__).with_suffix(".svg")

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ include = [
]

[tool.coverage.run]
omit = ["*/tests/*"]
omit = ["*/_tests/*"]

[tool.ruff]
src = ["."]
Expand All @@ -83,7 +83,7 @@ select = [
]

[tool.ruff.lint.per-file-ignores]
"src/ewoksdraw/tests/*.py" = [
"src/ewoksdraw/_tests/*.py" = [
"S101", # allow asserts
]

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import cast

from ewoksdraw import _elk_rs
from ewoksdraw.config.constants import ELK_LAYOUT_OPTIONS
from ewoksdraw._config.constants import ELK_LAYOUT_OPTIONS

from .elk_converter import ElkGraph
from .elk_converter import ElkGraphBeforeLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

from ewokscore.graph import TaskGraph

from ewoksdraw.config.constants import ELK_LAYOUT_OPTIONS

from ..geometry.cubic_bezier_path import Point
from ..svg.svg_task import TaskIOPosition
from ..svg.svg_task import TaskPosition
from ..svg.svg_task_group import TaskInputPositions
from ..svg.svg_task_group import TaskOutputPositions
from ..svg.svg_task_group import TaskPositions
from ..svg.svg_task_group import TaskSizes
from ..utils import get_edge_source_id
from ..utils import get_edge_target_id
from ..utils import get_valid_data_mappings
from ewoksdraw._config.constants import ELK_LAYOUT_OPTIONS

from .._geometry.cubic_bezier_path import Point
from .._svg.svg_task import TaskIOPosition
from .._svg.svg_task import TaskPosition
from .._svg.svg_task_group import TaskInputPositions
from .._svg.svg_task_group import TaskOutputPositions
from .._svg.svg_task_group import TaskPositions
from .._svg.svg_task_group import TaskSizes
from .._utils import get_edge_source_id
from .._utils import get_edge_target_id
from .._utils import get_valid_data_mappings


class ElkPort(TypedDict):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from ..config.constants import LINK_TURN_RADIUS
from ..geometry.cubic_bezier_path import CubicBezierPath
from ..geometry.cubic_bezier_path import Point
from ..svg.svg_group import SvgGroup
from ..svg.svg_link_cubic_bezier import SvgLinkCubicBezier
from ..utils import get_task_id_from_source_id
from ..utils import get_task_id_from_target_id
from .._config.constants import LINK_TURN_RADIUS
from .._geometry.cubic_bezier_path import CubicBezierPath
from .._geometry.cubic_bezier_path import Point
from .._svg.svg_group import SvgGroup
from .._svg.svg_link_cubic_bezier import SvgLinkCubicBezier
from .._utils import get_task_id_from_source_id
from .._utils import get_task_id_from_target_id
from .elk_converter import ElkEdge
from .elk_converter import ElkGraph
from .elk_converter import ElkSection
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class SvgBackground(SvgElement):
"""
Represents a background rectangle element in SVG.
Color can be set using the ./css_styles/css_background.css
Color can be set using the ./_css_styles/css_background.css
style.
"""

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SvgElement:

:param tag: The SVG tag (e.g., 'rect', 'circle', 'text').
:param css_class: The CSS class to apply to the SVG element.
Should match a CSS file in the css_styles directory.
Should match a CSS file in the _css_styles directory.
:param attr: A dictionary of svg attributes
"""

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..geometry.cubic_bezier_path import CubicBezierPath
from .._geometry.cubic_bezier_path import CubicBezierPath
from .svg_element import SvgElement


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import NamedTuple

from ..config.constants import IO_INTER_IO_MARGIN
from ..config.constants import IO_TOP_MARGIN
from .._config.constants import IO_INTER_IO_MARGIN
from .._config.constants import IO_TOP_MARGIN
from .svg_group import SvgGroup
from .svg_task_box import SvgTaskBox
from .svg_task_io import SvgTaskIOGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..config.constants import BOX_MAX_WIDTH
from ..config.constants import BOX_MIN_WIDTH
from .._config.constants import BOX_MAX_WIDTH
from .._config.constants import BOX_MIN_WIDTH
from .svg_element import SvgElement


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Literal

from ..config.constants import ANCHOR_LINKS_RADIUS
from ..config.constants import IO_ANCHOR_TEXT_MARGIN
from ..config.constants import IO_MIN_FONT_SIZE
from ..config.constants import IO_TARGET_FONT_SIZE
from .._config.constants import ANCHOR_LINKS_RADIUS
from .._config.constants import IO_ANCHOR_TEXT_MARGIN
from .._config.constants import IO_MIN_FONT_SIZE
from .._config.constants import IO_TARGET_FONT_SIZE
from .svg_element import SvgElement
from .svg_group import SvgGroup
from .svg_task_anchor_link import SvgTaskAnchorLink
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Optional
from typing import Union

from ..config.constants import TITLE_HORIZONTAL_MARGIN
from ..config.constants import TITLE_MIN_FONT_SIZE
from ..config.constants import TITLE_TARGET_FONT_SIZE
from ..config.constants import TITLE_VERTICAL_MARGIN
from .._config.constants import TITLE_HORIZONTAL_MARGIN
from .._config.constants import TITLE_MIN_FONT_SIZE
from .._config.constants import TITLE_TARGET_FONT_SIZE
from .._config.constants import TITLE_VERTICAL_MARGIN
from .svg_text import SvgText

Number = Union[int, float]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ewoksdraw/svg/utils.py → src/ewoksdraw/_svg/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from xml.etree.ElementTree import Element

CSS_DIR = Path(__file__).parent.parent / "css_styles"
CSS_DIR = Path(__file__).parent.parent / "_css_styles"


def generate_style_element(css_file_name: str) -> None | Element:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest

from ewoksdraw.geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw.geometry.cubic_bezier_path import Point
from ewoksdraw.geometry.cubic_bezier_path import Vector
from ewoksdraw.geometry.cubic_bezier_path import _direction
from ewoksdraw.geometry.cubic_bezier_path import _l1_distance
from ewoksdraw.geometry.cubic_bezier_path import _move
from ewoksdraw.geometry.cubic_bezier_path import _straight_segment
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw._geometry.cubic_bezier_path import Point
from ewoksdraw._geometry.cubic_bezier_path import Vector
from ewoksdraw._geometry.cubic_bezier_path import _direction
from ewoksdraw._geometry.cubic_bezier_path import _l1_distance
from ewoksdraw._geometry.cubic_bezier_path import _move
from ewoksdraw._geometry.cubic_bezier_path import _straight_segment


def _point(x: float, y: float) -> Point:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any
from typing import cast

from ewoksdraw.layout.elk_backend import layout
from ewoksdraw.layout.elk_converter import ElkGraphBeforeLayout
from ewoksdraw._layout.elk_backend import layout
from ewoksdraw._layout.elk_converter import ElkGraphBeforeLayout


def test_layout() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
from ewokscore.tests.examples.graphs import get_graph
from ewokscore.tests.examples.graphs import graph_names

from ewoksdraw.config.constants import ELK_LAYOUT_OPTIONS
from ewoksdraw.graph_to_svg import build_svg_task_group
from ewoksdraw.layout.elk_backend import layout
from ewoksdraw.layout.elk_converter import ElkGraph
from ewoksdraw.layout.elk_converter import convert_ewoks_to_elk_graph
from ewoksdraw.layout.elk_converter import extract_task_positions_from_elk_graph
from ewoksdraw.svg.svg_task import TaskIOPosition
from ewoksdraw.svg.svg_task import TaskPosition
from ewoksdraw.svg.svg_task_group import TaskInputPositions
from ewoksdraw.svg.svg_task_group import TaskOutputPositions
from ewoksdraw.svg.svg_task_group import TaskSize
from ewoksdraw.svg.svg_task_group import TaskSizes
from ewoksdraw._config.constants import ELK_LAYOUT_OPTIONS
from ewoksdraw._layout.elk_backend import layout
from ewoksdraw._layout.elk_converter import ElkGraph
from ewoksdraw._layout.elk_converter import convert_ewoks_to_elk_graph
from ewoksdraw._layout.elk_converter import extract_task_positions_from_elk_graph
from ewoksdraw._svg.svg_task import TaskIOPosition
from ewoksdraw._svg.svg_task import TaskPosition
from ewoksdraw._svg.svg_task_group import TaskInputPositions
from ewoksdraw._svg.svg_task_group import TaskOutputPositions
from ewoksdraw._svg.svg_task_group import TaskSize
from ewoksdraw._svg.svg_task_group import TaskSizes
from ewoksdraw.graph_to_svg import _build_svg_task_group

_TASK_TYPE = "ewokscore.tests.examples.tasks.sumtask.SumTask"

Expand Down Expand Up @@ -441,7 +441,7 @@ def test_output_is_accepted_by_the_rust_layout(graph_name: str) -> None:

graph_description, _ = get_graph(graph_name)
graph = load_graph(graph_description)
task_group = build_svg_task_group(graph)
task_group = _build_svg_task_group(graph)

elk_graph = convert_ewoks_to_elk_graph(
graph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import pytest

from ewoksdraw import _elk_rs
from ewoksdraw.layout.elk_backend import ElkLayoutError
from ewoksdraw.layout.elk_backend import layout
from ewoksdraw.layout.elk_converter import ElkGraph
from ewoksdraw.layout.elk_converter import ElkGraphBeforeLayout
from ewoksdraw._layout.elk_backend import ElkLayoutError
from ewoksdraw._layout.elk_backend import layout
from ewoksdraw._layout.elk_converter import ElkGraph
from ewoksdraw._layout.elk_converter import ElkGraphBeforeLayout

NODE_WIDTH = 100
NODE_HEIGHT = 60
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from ewoksdraw.geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw.geometry.cubic_bezier_path import CubicBezierSegment
from ewoksdraw.svg.svg_link_cubic_bezier import SvgLinkCubicBezier
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierSegment
from ewoksdraw._svg.svg_link_cubic_bezier import SvgLinkCubicBezier

SIMPLE_PATH = CubicBezierPath(
start={"x": 0, "y": 0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from defusedxml import ElementTree

from ewoksdraw.geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw.geometry.cubic_bezier_path import CubicBezierSegment
from ewoksdraw.svg.svg_canvas import SvgCanvas
from ewoksdraw.svg.svg_group import SvgGroup
from ewoksdraw.svg.svg_link_cubic_bezier import SvgLinkCubicBezier
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierPath
from ewoksdraw._geometry.cubic_bezier_path import CubicBezierSegment
from ewoksdraw._svg.svg_canvas import SvgCanvas
from ewoksdraw._svg.svg_group import SvgGroup
from ewoksdraw._svg.svg_link_cubic_bezier import SvgLinkCubicBezier

PATH = CubicBezierPath(
start={"x": 0, "y": 0},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ewoksdraw.svg.svg_task import SvgTask
from ewoksdraw._svg.svg_task import SvgTask


def test_io_positions_keep_original_names() -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ..utils import get_edge_source_id
from ..utils import get_edge_target_id
from ..utils import get_task_id_from_source_id
from ..utils import get_task_id_from_target_id
from .._utils import get_edge_source_id
from .._utils import get_edge_target_id
from .._utils import get_task_id_from_source_id
from .._utils import get_task_id_from_target_id


def test_edge_source_task_id_roundtrip() -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/ewoksdraw/utils.py → src/ewoksdraw/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from ewokscore.graph import TaskGraph

from .models import DataMapping
from ._models import DataMapping


def get_valid_data_mappings(ewoks_graph: TaskGraph) -> list[DataMapping]:
Expand Down
26 changes: 13 additions & 13 deletions src/ewoksdraw/graph_to_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from ewokscore.graph import TaskGraph
from ewokscore.node.signature import node_signature

from .config.constants import TASK_GROUP_HORIZONTAL_GAP
from .layout.elk_backend import layout
from .layout.elk_converter import ElkGraph
from .layout.elk_converter import ElkGraphBeforeLayout
from .layout.elk_converter import convert_ewoks_to_elk_graph
from .layout.elk_converter import extract_task_positions_from_elk_graph
from .layout.elk_link_group_builder import build_svg_link_group
from .svg.svg_canvas import SvgCanvas
from .svg.svg_task import SvgTask
from .svg.svg_task_group import SvgTaskGroup
from .utils import get_edge_sources_and_targets
from ._config.constants import TASK_GROUP_HORIZONTAL_GAP
from ._layout.elk_backend import layout
from ._layout.elk_converter import ElkGraph
from ._layout.elk_converter import ElkGraphBeforeLayout
from ._layout.elk_converter import convert_ewoks_to_elk_graph
from ._layout.elk_converter import extract_task_positions_from_elk_graph
from ._layout.elk_link_group_builder import build_svg_link_group
from ._svg.svg_canvas import SvgCanvas
from ._svg.svg_task import SvgTask
from ._svg.svg_task_group import SvgTaskGroup
from ._utils import get_edge_sources_and_targets


def build_svg_task_group(graph: TaskGraph) -> SvgTaskGroup:
def _build_svg_task_group(graph: TaskGraph) -> SvgTaskGroup:
"""Build an SVG task group from an Ewoks task graph."""
source_outputs_per_node, target_inputs_per_node = get_edge_sources_and_targets(
graph
Expand Down Expand Up @@ -49,7 +49,7 @@ def build_svg_task_group(graph: TaskGraph) -> SvgTaskGroup:


def graph_to_svg(graph: TaskGraph, output_path: str | Path) -> None:
task_group = build_svg_task_group(graph)
task_group = _build_svg_task_group(graph)
elk_graph_before_layout: ElkGraphBeforeLayout = convert_ewoks_to_elk_graph(
graph,
task_group.extract_task_sizes(),
Expand Down
Loading