def submit_draft_pack(run_folder: str, run_name: str, namespace: str = None): """ Submits one run using draft's environment located in a folder given as a parameter. :param run_folder: location of a folder with a description of an environment :param run_name: run's name :param local_registry_port: port of destination local registry where pack should be submitted :param namespace: namespace where tiller used during deployment is located In case of any problems it throws an exception with a description of a problem """ log.debug(f'Submit one run: {run_folder} - start') # run training try: cmd.up(run_name=run_name, working_directory=run_folder, namespace=namespace) except Exception: delete_environment(run_folder) raise SubmitExperimentError(Texts.JOB_NOT_DEPLOYED_ERROR_MSG) log.debug(f'Submit one run {run_folder} - finish')
def test_up_helm_install_error(mocker, cmd_mock): mocker.patch('util.helm.install_helm_chart', side_effect=RuntimeError) output, exit_code = up('my-run', local_registry_port=12345, working_directory='/home/user/config', namespace='user') assert output == DraftCmdTexts.APP_NOT_RELEASED assert exit_code == 102
def test_up_push_error(mocker, cmd_mock): docker_client_mock = mocker.MagicMock() docker_client_mock.images.push = lambda: RuntimeError mocker.patch('docker.from_env', new=lambda: docker_client_mock) output, exit_code = up('my-run', local_registry_port=12345, working_directory='/home/user/config', namespace='user') assert output == DraftCmdTexts.DOCKER_IMAGE_NOT_SENT assert exit_code == 101
def test_up(mocker, cmd_mock): output, exit_code = up('my-run', local_registry_port=12345, working_directory='/home/user/config', namespace='user') assert output == "" assert exit_code == 0 assert cmd_mock.images.build.call_count == 1 assert cmd_mock.images.push.call_count == 1 # noinspection PyUnresolvedReferences assert '/home/user/config/charts/my-pack' in util.helm.install_helm_chart.call_args[ 0]
def submit_draft_pack(run_folder: str, namespace: str = None): """ Submits one run using draft's environment located in a folder given as a parameter. :param run_folder: location of a folder with a description of an environment :param run_name: run's name :param namespace: namespace where tiller used during deployment is located In case of any problems it throws an exception with a description of a problem """ log.debug(f'Submit one run: {run_folder} - start') # run training output, exit_code, log_output = cmd.up(working_directory=run_folder, namespace=namespace) if exit_code: error_message = Texts.JOB_NOT_DEPLOYED_ERROR_MSG log_filename = get_log_filename(str(log_output)) if log_filename: error_message = error_message + Texts.JOB_NOT_DEPLOYED_ERROR_MSG_LOGFILE.format(log_filename=log_filename) log.error(log_output) delete_environment(run_folder) raise SubmitExperimentError(error_message) log.debug(f'Submit one run {run_folder} - finish')
def test_up_helm_install_error(mocker, cmd_mock): mocker.patch('util.helm.install_helm_chart', side_effect=RuntimeError) with pytest.raises(RuntimeError): up('my-run', working_directory='/home/user/config', namespace='user')
def test_up(mocker, cmd_mock): up('my-run', working_directory='/home/user/config', namespace='user') # noinspection PyUnresolvedReferences assert '/home/user/config/charts/my-pack' in util.helm.install_helm_chart.call_args[0]