From c8ea2438c22a2b9ef920e6aeb3a9f5d30e95ee97 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 22 Feb 2019 17:14:30 +0100 Subject: [PATCH 1/8] Tolerate existing edges in digraph --- easybuild/framework/easyconfig/tools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/easybuild/framework/easyconfig/tools.py b/easybuild/framework/easyconfig/tools.py index ba7b634b6d..c28e9f400f 100644 --- a/easybuild/framework/easyconfig/tools.py +++ b/easybuild/framework/easyconfig/tools.py @@ -206,7 +206,13 @@ def mk_node_name(spec): edge_attrs = [('style', 'dotted'), ('color', 'blue'), ('arrowhead', 'diamond')] for spec in specs: for dep in spec['ec'].all_dependencies: - dgr.add_edge((spec['module'], dep)) + try: + dgr.add_edge((spec['module'], dep)) + except Exception as e: + if "already in digraph" in str(e): + continue + else: + raise e if dep in spec['ec'].build_dependencies: dgr.add_edge_attributes((spec['module'], dep), attrs=edge_attrs) From 70f99cc640558faf4b650299dd386f4fd3c80f84 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Tue, 4 Jun 2019 10:23:43 +0200 Subject: [PATCH 2/8] Add explanatory comment and logging --- easybuild/framework/easyconfig/tools.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/easybuild/framework/easyconfig/tools.py b/easybuild/framework/easyconfig/tools.py index b7e2460fab..98dfd7b8cb 100644 --- a/easybuild/framework/easyconfig/tools.py +++ b/easybuild/framework/easyconfig/tools.py @@ -208,11 +208,15 @@ def mk_node_name(spec): for dep in spec['ec'].all_dependencies: try: dgr.add_edge((spec['module'], dep)) - except Exception as e: - if "already in digraph" in str(e): + except Exception as err: + # When multiple specs are given we can easily have overlapping edges (i.e., common dependency trees) + # so we need to explicitly account this in our digraph + if "already in digraph" in str(err): + _log.info("Edge (%s) -> (%s) already exists in digraph (but duplication is permitted)" % + (spec['module'], dep)) continue else: - raise e + raise err if dep in spec['ec'].build_dependencies: dgr.add_edge_attributes((spec['module'], dep), attrs=edge_attrs) From 19d797e58ce12e82b240d49c2dbd46e804e07c17 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Tue, 4 Jun 2019 10:34:33 +0200 Subject: [PATCH 3/8] Add script that extracts node from large dotfile --- .../scripts/extract_node_from_dotfile.sh | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 easybuild/scripts/extract_node_from_dotfile.sh diff --git a/easybuild/scripts/extract_node_from_dotfile.sh b/easybuild/scripts/extract_node_from_dotfile.sh new file mode 100644 index 0000000000..c047416f72 --- /dev/null +++ b/easybuild/scripts/extract_node_from_dotfile.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +find_children () { + # The fact that we put the semicolon straight after means we exclude anywhere the module + # is only required as a build dependency (since these cases have extra formatting the + # semicolon comes later); + # the sed command makes sure we ignore whether the module is hidden or not + grep ' "'$3'";' $1 | sed s#/\\.#/#g >> $2 + grep ' "'$3'";' $1 | awk '{print $1}'| xargs -i bash -c "map_dep $1 $2 {}" +} + +map_dep () { + # Search for a node that matches the string and add a comment marker at the end + # to leverage with grep later + # (if non-installed software had additional formatting they would be ignored) + # the sed command makes sure we ignore whether the module is hidden or not + grep "^"'"'$3'";' $1 | awk '{print $1" // xxnodexx"}' | sed s#/\\.#/#g >> $2 + if [ $? ] + then + find_children $1 $2 $3 + fi +} + +export -f find_children +export -f map_dep + +# Check command line +if [ "$#" -ne 3 ]; then + echo -e "Expected command line:\n\t