Beispiel #1
0
class WrapperTest(unittest.TestCase):
    def setUp(self):
        self.obj = Wrapper()

    def test_is_executable(self):
        self.assertIsInstance(self.obj, Executable)

    def test_takes_executable_as_wrapper(self):
        self.obj.wrapped = Executable(exe=sys.executable)
        self.assertTrue(self.obj.wrapped.exe.samefile(sys.executable))

        self.obj = Wrapper(wrapped=Executable(exe=sys.executable))
        self.assertTrue(self.obj.wrapped.exe.samefile(sys.executable))

    def test_denies_non_executables_as_wrapped(self):
        with self.assertRaises(ValueError):
            self.obj.wrapped = 'not an Executable'

    def test_does_not_require_wrapped_executable(self):
        self.obj.exe = sys.executable
        with self.assertLogs('pfasst_py', level='WARNING') as cptr:
            self.assertEqual(self.obj.build_cmd_line(), sys.executable)
        self.assertRegex(''.join(cptr.output), 'No wrapped executable defined')

    def test_takes_commandline_from_wrapped(self):
        self.obj.exe = sys.executable
        self.obj.wrapped = Executable(exe=sys.executable)
        self.assertEqual(self.obj.build_cmd_line(), "%s %s" % (sys.executable, sys.executable))
Beispiel #2
0
 def use_default_exe(self):
     if self.directory:
         try:
             mpi = Wrapper(MPIExec())
             mpi.wrapped = AdvecDiffExecutable(exe=(self.directory / "advec_diff_faulty_pfasst"))
             self.runner = Runner(mpi)
         except ValueError as err:
             _log.error("Cannot create Executable for example: %s" % err)
     else:
         _log.warning("Example directory not set. Cannot find executable.")
Beispiel #3
0
    from pfasst_py.runner.executable import MPIExec
    from pfasst_py.runner.wrapper import Wrapper
    from pfasst_py.runner.runner import Runner

    example_dir = pathlib.Path('/home/t.klatt/projects/PFASST/build_mpi/examples/advec_diff')
    exe_file = 'advec_diff_faulty_pfasst'

    exe = AdvecDiffFaultyPfasstExecutable(exe=(example_dir / exe_file))
    exe.abs_res_tol.value = 1e-10
    exe.dt.value = 0.05
    exe.tend.value = 0.2
    exe.num_iters.value = 10
    exe.nocolor.toggle()

    print(exe.build_cmd_line())

    mpi = MPIExec()
    mpi.np.value = 4

    wrapper = Wrapper()
    wrapper.exe = mpi
    wrapper.wrapped = exe

    print(wrapper.build_cmd_line())

    runner = Runner()
    runner.exe = wrapper
    runner.run()

    print(runner.stdout_lines)
Beispiel #4
0
    def test_takes_executable_as_wrapper(self):
        self.obj.wrapped = Executable(exe=sys.executable)
        self.assertTrue(self.obj.wrapped.exe.samefile(sys.executable))

        self.obj = Wrapper(wrapped=Executable(exe=sys.executable))
        self.assertTrue(self.obj.wrapped.exe.samefile(sys.executable))
Beispiel #5
0
 def setUp(self):
     self.obj = Wrapper()