From 382a6d38c50cd27d94e9b6d5f15194555fff3b5c Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila <37295697+m-fila@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:34:04 +0200 Subject: [PATCH] Fix data paths in tests (#23) * change parse_graphml argument to object not vector * use data paths derived from project root in tests --- examples/parsing_graphs.jl | 2 +- src/parsing.jl | 5 ++--- src/scheduling.jl | 2 +- test/parsing.jl | 3 ++- test/scheduling.jl | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/parsing_graphs.jl b/examples/parsing_graphs.jl index edab9a2..7efce40 100644 --- a/examples/parsing_graphs.jl +++ b/examples/parsing_graphs.jl @@ -3,7 +3,7 @@ using FrameworkDemo function main() - G = FrameworkDemo.parse_graphml(["./data/demo/sequencer/df.graphml"]) + G = FrameworkDemo.parse_graphml("./data/demo/sequencer/df.graphml") G_copy = deepcopy(G) FrameworkDemo.show_graph(G_copy) end diff --git a/src/parsing.jl b/src/parsing.jl index 6f8c74e..8ebfbb3 100644 --- a/src/parsing.jl +++ b/src/parsing.jl @@ -2,9 +2,8 @@ using Graphs using MetaGraphs include("../deps/GraphMLReader.jl/src/GraphMLReader.jl") -function parse_graphml(path) - file_path = joinpath(path...) - G = GraphMLReader.loadgraphml(file_path, "G") +function parse_graphml(filename::String)::MetaDiGraph + GraphMLReader.loadgraphml(filename, "G") end function show_graph(G) diff --git a/src/scheduling.jl b/src/scheduling.jl index 7f71027..96d3bc0 100644 --- a/src/scheduling.jl +++ b/src/scheduling.jl @@ -33,7 +33,7 @@ function parse_graphs(graphs_map::Dict, output_graph_path::String, output_graph_ for (graph_name, graph_path) in graphs_map parsed_graph_dot = timestamp_string("$output_graph_path$graph_name") * ".dot" parsed_graph_image = timestamp_string("$output_graph_image_path$graph_name") * ".png" - G = parse_graphml([graph_path]) + G = parse_graphml(graph_path) open(parsed_graph_dot, "w") do f MetaGraphs.savedot(f, G) diff --git a/test/parsing.jl b/test/parsing.jl index f672262..6fcf0a8 100644 --- a/test/parsing.jl +++ b/test/parsing.jl @@ -3,7 +3,8 @@ using Graphs using MetaGraphs @testset "Parsing" begin - graph = FrameworkDemo.parse_graphml(["../data/demo/sequencer/df.graphml"]) + path = joinpath(pkgdir(FrameworkDemo), "data/demo/sequencer/df.graphml") + graph = FrameworkDemo.parse_graphml(path) set_indexing_prop!(graph, :original_id) # Test the general structure of the graph diff --git a/test/scheduling.jl b/test/scheduling.jl index 7d74463..63d3c46 100644 --- a/test/scheduling.jl +++ b/test/scheduling.jl @@ -36,7 +36,8 @@ end @testset verbose = true "Scheduling" begin - graph = FrameworkDemo.parse_graphml(["../data/demo/datadeps/df.graphml"]) + path = joinpath(pkgdir(FrameworkDemo), "data/demo/datadeps/df.graphml") + graph = FrameworkDemo.parse_graphml(path) ilength(x) = sum(_ -> 1, x) # no standard length for MetaGraphs.filter_vertices iterator algorithms_count = ilength(MetaGraphs.filter_vertices(graph, :type, "Algorithm")) set_indexing_prop!(graph, :node_id)