| 681 | test(None, _MISSING_IMPL) |
| 682 | |
| 683 | def test_run_controller(self): |
| 684 | def test(use_gloo, use_mpi, use_js, |
| 685 | gloo_is_built, mpi_is_built, |
| 686 | lsf_exists, jsrun_installed, |
| 687 | expected, exception): |
| 688 | gloo_run = MagicMock() |
| 689 | mpi_run = MagicMock() |
| 690 | js_run = MagicMock() |
| 691 | |
| 692 | with is_built(gloo_is_built, mpi_is_built): |
| 693 | with lsf_and_jsrun(lsf_exists, jsrun_installed): |
| 694 | if exception is not None: |
| 695 | with pytest.raises(ValueError, match=exception) as e: |
| 696 | run_controller(use_gloo, gloo_run, use_mpi, mpi_run, use_js, js_run, verbosity=2) |
| 697 | return |
| 698 | run_controller(use_gloo, gloo_run, use_mpi, mpi_run, use_js, js_run, verbosity=2) |
| 699 | |
| 700 | if expected == "gloo": |
| 701 | gloo_run.assert_called_once() |
| 702 | mpi_run.assert_not_called() |
| 703 | js_run.assert_not_called() |
| 704 | elif expected == "mpi": |
| 705 | gloo_run.assert_not_called() |
| 706 | mpi_run.assert_called_once() |
| 707 | js_run.assert_not_called() |
| 708 | elif expected == "js": |
| 709 | gloo_run.assert_not_called() |
| 710 | mpi_run.assert_not_called() |
| 711 | js_run.assert_called_once() |
| 712 | else: |
| 713 | raise ValueError("unsupported framework: {}".format(expected)) |
| 714 | |
| 715 | bool_values = [False, True] |
| 716 | bool_values_and_none = [None, False, True] |
| 717 | |
| 718 | for use_gloo, use_mpi, use_js, \ |
| 719 | gloo_is_built, mpi_is_built, \ |
| 720 | lsf_exists, jsrun_installed in \ |
| 721 | itertools.product(bool_values_and_none, bool_values_and_none, bool_values_and_none, |
| 722 | bool_values, bool_values, |
| 723 | bool_values, bool_values): |
| 724 | |
| 725 | expected = exception = None |
| 726 | if use_gloo: |
| 727 | if gloo_is_built: |
| 728 | expected = 'gloo' |
| 729 | else: |
| 730 | exception = r'^Gloo support has not been built\. If this is not expected, ensure CMake is installed ' \ |
| 731 | r'and reinstall Horovod with HOROVOD_WITH_GLOO=1 to debug the build error\.$' |
| 732 | elif use_mpi: |
| 733 | if mpi_is_built: |
| 734 | expected = 'mpi' |
| 735 | else: |
| 736 | exception = r'^MPI support has not been built\. If this is not expected, ensure MPI is installed ' \ |
| 737 | r'and reinstall Horovod with HOROVOD_WITH_MPI=1 to debug the build error\.$' |
| 738 | elif use_js: |
| 739 | if mpi_is_built: |
| 740 | if lsf_exists: |