Skip to content

Commit

Permalink
Make cyclic dependency error as warning (#164)
Browse files Browse the repository at this point in the history
* Make cyclic depeendency error as warning

* Fixed pylint error

* Fixed pytest and pylint
  • Loading branch information
Nishidha authored Feb 14, 2023
1 parent ccbaf43 commit 34891cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions open_ce/build_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from open_ce import env_config
from open_ce import validate_config #pylint: disable=cyclic-import
from open_ce import build_feedstock
from open_ce.errors import OpenCEError, Error, log
from open_ce.errors import OpenCEError, Error, log, show_warning
from open_ce.conda_env_file_generator import CondaEnvFileGenerator
from open_ce.build_command import BuildCommand
# pylint: enable=wrong-import-position,wrong-import-order
Expand Down Expand Up @@ -490,7 +490,7 @@ def _detect_cycle(self):
cycle_print += " -> ".join(node.build_command.recipe if node.build_command else str(node.packages)
for node in cycle + [cycle[0]]) + "\n"
if cycle_print:
raise OpenCEError(Error.BUILD_TREE_CYCLE, cycle_print)
show_warning(Error.BUILD_TREE_CYCLE, cycle_print)

def build_command_dependencies(self, node):
'''
Expand Down
19 changes: 9 additions & 10 deletions tests/build_tree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def test_build_tree_len():

assert len(mock_build_tree) == 3

def test_build_tree_cycle_fail():
def test_build_tree_cycle_fail(mocker, caplog): #pylint: disable=unused-argument
'''
Tests that a cycle is detected in a build_tree.
'''
Expand Down Expand Up @@ -573,15 +573,14 @@ def test_build_tree_cycle_fail():

mock_build_tree._tree = cycle_build_commands

with pytest.raises(OpenCEError) as exc:
mock_build_tree._detect_cycle()

assert "Build dependencies should form a Directed Acyclic Graph." in str(exc.value)
assert any(["recipe1 -> recipe2 -> recipe1" in str(exc.value),
"recipe2 -> recipe1 -> recipe2" in str(exc.value),
"recipe1 -> recipe3 -> recipe2 -> recipe1" in str(exc.value),
"recipe2 -> recipe1 -> recipe3 -> recipe2" in str(exc.value),
"recipe3 -> recipe2 -> recipe1 -> recipe2" in str(exc.value)])
mock_build_tree._detect_cycle()

assert "Build dependencies should form a Directed Acyclic Graph." in caplog.text
assert any(["recipe1 -> recipe2 -> recipe1" in caplog.text,
"recipe2 -> recipe1 -> recipe2" in caplog.text,
"recipe1 -> recipe3 -> recipe2 -> recipe1" in caplog.text,
"recipe2 -> recipe1 -> recipe3 -> recipe2" in caplog.text,
"recipe3 -> recipe2 -> recipe1 -> recipe2" in caplog.text])

def test_get_installable_package_for_non_runtime_package():
'''
Expand Down

0 comments on commit 34891cd

Please sign in to comment.