CPMpy/cpmpy

fresh install tests requiring skip check

tias opened this issue · 0 comments

tias commented

on a fresh install, the following errors were obtained.

Requires 'modulenotfound' error catching and z3 check so that these tests are skipped

On 7/4/23 17:01, Tias Guns wrote:
>
>
> ================================================== FAILURES ==================================================
>
> ________________________________ test_examples[./examples/lpcp21_p1_frog.py] _________________________________
>
>
> example = './examples/lpcp21_p1_frog.py'
>
>
>     @pytest.mark.parametrize("example", EXAMPLES)
>
>     def test_examples(example):
>
>         """Loads example files and executes with default solver
>
>     
>
>     class TestExamples(unittest.TestCase):
>
>     
>
>         Args:
>
>             example ([string]): Loaded with parametrized example filename
>
>         """
>
>         # do not run, dependency local to that folder
>
>         if example.endswith('explain_satisfaction.py'):
>
>             return
>
>         loader = importlib.machinery.SourceFileLoader("example", example)
>
>         mod = types.ModuleType(loader.name)
>
> >       loader.exec_module(mod)
>
>
> tests/test_examples.py:41: 
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
> <frozen importlib._bootstrap_external>:940: in exec_module
>
>     ???
>
> <frozen importlib._bootstrap>:241: in _call_with_frames_removed
>
>     ???
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
>
>     # Implementation of LP/CP Contest 2021
>
>     # Problem 1, Crazy Frog Puzzle
>
>     # https://github.com/alviano/lpcp-contest-2021/tree/main/problem-1
>
>     #
>
>     # Tias Guns, 2021
>
>     
>
> >   import requests # to get the data
>
> E   ModuleNotFoundError: No module named 'requests'
>
>
> examples/lpcp21_p1_frog.py:7: ModuleNotFoundError
>
> _______________________ test_examples[./examples/csplib/prob013_progressive_party.py] ________________________
>
>
> example = './examples/csplib/prob013_progressive_party.py'
>
>
>     @pytest.mark.parametrize("example", EXAMPLES)
>
>     def test_examples(example):
>
>         """Loads example files and executes with default solver
>
>     
>
>     class TestExamples(unittest.TestCase):
>
>     
>
>         Args:
>
>             example ([string]): Loaded with parametrized example filename
>
>         """
>
>         # do not run, dependency local to that folder
>
>         if example.endswith('explain_satisfaction.py'):
>
>             return
>
>         loader = importlib.machinery.SourceFileLoader("example", example)
>
>         mod = types.ModuleType(loader.name)
>
> >       loader.exec_module(mod)
>
>
> tests/test_examples.py:41: 
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
> <frozen importlib._bootstrap_external>:940: in exec_module
>
>     ???
>
> <frozen importlib._bootstrap>:241: in _call_with_frames_removed
>
>     ???
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
>
>     """
>
>         Progressive Party Problem (PPP) in CPMpy
>
>     
>
>         Problem 013 on CSPlib:
>
>         https://www.csplib.org/Problems/prob013/
>
>     
>
>         The problem is to timetable a party at a yacht club.
>
>         Certain boats are to be designated hosts, and the crews of the remaining boats in turn visit the host boats for several successive half-hour periods.
>
>         The crew of a host boat remains on board to act as hosts while the crew of a guest boat together visits several hosts.
>
>         Every boat can only hold a limited number of people at a time (its capacity) and crew sizes are different.
>
>         The total number of people aboard a boat, including the host crew and guest crews, must not exceed the capacity.
>
>         A guest boat cannot not revisit a host and guest crews cannot meet more than once.
>
>         The problem facing the rally organizer is that of minimizing the number of host boats.
>
>     
>
>         Model by Ignace Bleukx, ignace.bleukx@kuleuven.be
>
>     """
>
>     import sys
>
> >   import requests
>
> E   ModuleNotFoundError: No module named 'requests'
>
>
> examples/csplib/prob013_progressive_party.py:18: ModuleNotFoundError
>
> _________________________ test_examples[./examples/csplib/prob008_vessel_loading.py] _________________________
>
>
> example = './examples/csplib/prob008_vessel_loading.py'
>
>
>     @pytest.mark.parametrize("example", EXAMPLES)
>
>     def test_examples(example):
>
>         """Loads example files and executes with default solver
>
>     
>
>     class TestExamples(unittest.TestCase):
>
>     
>
>         Args:
>
>             example ([string]): Loaded with parametrized example filename
>
>         """
>
>         # do not run, dependency local to that folder
>
>         if example.endswith('explain_satisfaction.py'):
>
>             return
>
>         loader = importlib.machinery.SourceFileLoader("example", example)
>
>         mod = types.ModuleType(loader.name)
>
> >       loader.exec_module(mod)
>
>
> tests/test_examples.py:41: 
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
> <frozen importlib._bootstrap_external>:940: in exec_module
>
>     ???
>
> <frozen importlib._bootstrap>:241: in _call_with_frames_removed
>
>     ???
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
>
>     """
>
>         Vessel loading in CPMpy
>
>         Problem 008 in CSPlib
>
>     
>
>         Model inspired by Essence implementation on CSPlib
>
>     
>
>         Created by Ignace Bleukx
>
>     
>
>     """
>
>     
>
>     import sys
>
> >   import requests
>
> E   ModuleNotFoundError: No module named 'requests'
>
>
> examples/csplib/prob008_vessel_loading.py:12: ModuleNotFoundError
>
> ____________________________ test_examples[./examples/csplib/prob012_nonogram.py] ____________________________
>
>
> example = './examples/csplib/prob012_nonogram.py'
>
>
>     @pytest.mark.parametrize("example", EXAMPLES)
>
>     def test_examples(example):
>
>         """Loads example files and executes with default solver
>
>     
>
>     class TestExamples(unittest.TestCase):
>
>     
>
>         Args:
>
>             example ([string]): Loaded with parametrized example filename
>
>         """
>
>         # do not run, dependency local to that folder
>
>         if example.endswith('explain_satisfaction.py'):
>
>             return
>
>         loader = importlib.machinery.SourceFileLoader("example", example)
>
>         mod = types.ModuleType(loader.name)
>
> >       loader.exec_module(mod)
>
>
> tests/test_examples.py:41: 
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
> <frozen importlib._bootstrap_external>:940: in exec_module
>
>     ???
>
> <frozen importlib._bootstrap>:241: in _call_with_frames_removed
>
>     ???
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
>
>     """
>
>         Nonogram in CPMpy
>
>     
>
>         Problem 012 on CSPlib
>
>         https://www.csplib.org/Problems/prob012/
>
>     
>
>         Nonograms are a popular puzzle, which goes by different names in different countries.
>
>         Solvers have to shade in squares in a grid so that blocks of consecutive shaded squares satisfy constraints given for each row and column.
>
>         Constraints typically indicate the sequence of shaded blocks (e.g. 3,1,2 means that there is a block of 3, then a gap of unspecified size, a block of length 1, another gap, and then a block of length 2).
>
>     
>
>         Using native solver access to OR-tools to post Automaton constraint
>
>     
>
>         Based on model by Hakank
>
>     
>
>         Model created by Ignace Bleukx, ignace.bleukx@kuleuven.be
>
>     
>
>     """
>
>     import sys
>
>     import json
>
> >   import requests
>
> E   ModuleNotFoundError: No module named 'requests'
>
>
> examples/csplib/prob012_nonogram.py:20: ModuleNotFoundError
>
> ________________________ test_examples[./examples/csplib/prob026_sport_scheduling.py] ________________________
>
>
> example = './examples/csplib/prob026_sport_scheduling.py'
>
>
>     @pytest.mark.parametrize("example", EXAMPLES)
>
>     def test_examples(example):
>
>         """Loads example files and executes with default solver
>
>     
>
>     class TestExamples(unittest.TestCase):
>
>     
>
>         Args:
>
>             example ([string]): Loaded with parametrized example filename
>
>         """
>
>         # do not run, dependency local to that folder
>
>         if example.endswith('explain_satisfaction.py'):
>
>             return
>
>         loader = importlib.machinery.SourceFileLoader("example", example)
>
>         mod = types.ModuleType(loader.name)
>
> >       loader.exec_module(mod)
>
>
> tests/test_examples.py:41: 
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
> <frozen importlib._bootstrap_external>:940: in exec_module
>
>     ???
>
> <frozen importlib._bootstrap>:241: in _call_with_frames_removed
>
>     ???
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
>
>     """
>
>     Problem 026 on CSPLib
>
>     Sport scheduling in CPMpy
>
>     
>
>     Model created by Ignace Bleukx
>
>     """
>
> >   import pandas as pd
>
> E   ModuleNotFoundError: No module named 'pandas'
>
>
> examples/csplib/prob026_sport_scheduling.py:7: ModuleNotFoundError
>
> ____________________________________________ TestGlobal.test_abs _____________________________________________
>
>
> self = <test_globalconstraints.TestGlobal testMethod=test_abs>
>
>
>     def test_abs(self):
>
>         iv = cp.intvar(-8, 8)
>
>         constraints = [cp.Abs(iv) + 9 <= 8]
>
>         model = cp.Model(constraints)
>
>         self.assertFalse(model.solve())
>
>     
>
>         constraints = [cp.Abs(iv - 4) + 1 > 12]
>
>         model = cp.Model(constraints)
>
>         self.assertTrue(model.solve())
>
> >       self.assertTrue(model.solve('z3')) #test with decomposition
>
>
> tests/test_globalconstraints.py:271: 
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
> tests/cpmpy/model.py:156: in solve
>
>     s = SolverLookup.get(solver, self)
>
> tests/cpmpy/solvers/utils.py:106: in get
>
>     return cls(model, subsolver=subname)
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>
>
> self = <cpmpy.solvers.z3.CPM_z3 object at 0x115516550>
>
> cpm_model = Constraints:
>
>     (abs((IV16) + -4)) + 1 > 12
>
> Objective: None, subsolver = None
>
>
>     def __init__(self, cpm_model=None, subsolver="sat"):
>
>         """
>
>         Constructor of the native solver object
>
>     
>
>         Arguments:
>
>         - cpm_model: Model(), a CPMpy Model() (optional)
>
>         - subsolver: None
>
>         """
>
>         if not self.supported():
>
> >           raise Exception("CPM_z3: Install the python package 'z3-solver'")
>
> E           Exception: CPM_z3: Install the python package 'z3-solver'
>
>
> tests/cpmpy/solvers/z3.py:68: Exception
>
> ========================================== short test summary info ===========================================
>
> FAILED tests/test_examples.py::test_examples[./examples/lpcp21_p1_frog.py] - ModuleNotFoundError: No module named 'requests'
>
> FAILED tests/test_examples.py::test_examples[./examples/csplib/prob013_progressive_party.py] - ModuleNotFoundError: No module named 'requests'
>
> FAILED tests/test_examples.py::test_examples[./examples/csplib/prob008_vessel_loading.py] - ModuleNotFoundError: No module named 'requests'
>
> FAILED tests/test_examples.py::test_examples[./examples/csplib/prob012_nonogram.py] - ModuleNotFoundError: No module named 'requests'
>
> FAILED tests/test_examples.py::test_examples[./examples/csplib/prob026_sport_scheduling.py] - ModuleNotFoundError: No module named 'pandas'
>
> FAILED tests/test_globalconstraints.py::TestGlobal::test_abs - Exception: CPM_z3: Install the python package 'z3-solver'
>
> ================================ 6 failed, 1321 passed, 25 skipped in 21.85s =================================​
>
>