From 63dffd6213c0b80948b87b1722abcbf97c9918de Mon Sep 17 00:00:00 2001 From: mibe Date: Thu, 10 Oct 2024 16:52:32 +0100 Subject: [PATCH] #142 Fixed the deployer test --- .../deployment/language_container.py | 5 +++-- .../deployment/test_deploy_cli.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/exasol_sagemaker_extension/deployment/language_container.py b/exasol_sagemaker_extension/deployment/language_container.py index 7bbefa9..a592655 100644 --- a/exasol_sagemaker_extension/deployment/language_container.py +++ b/exasol_sagemaker_extension/deployment/language_container.py @@ -16,13 +16,14 @@ def language_container_factory(): yield container_builder -def export_slc(export_dir: str) -> str: +@contextmanager +def export_slc(export_dir: str): if not os.path.isdir(export_dir): os.makedirs(export_dir) with language_container_factory() as container_builder: export_result = container_builder.export(export_dir) export_info = export_result.export_infos[str(container_builder.flavor_path)]["release"] - return export_info.cache_file + yield export_info.cache_file if __name__ == '__main__': diff --git a/tests/integration_tests/deployment/test_deploy_cli.py b/tests/integration_tests/deployment/test_deploy_cli.py index a84ad51..0cc7875 100644 --- a/tests/integration_tests/deployment/test_deploy_cli.py +++ b/tests/integration_tests/deployment/test_deploy_cli.py @@ -62,17 +62,17 @@ def std_param_to_opt(std_param: StdParams) -> str: # This method should be implemented in the StdParams return f'--{std_param.name.replace("_", "-")}' - container_file = export_slc(str(tmp_path)) - print('Container file:', container_file, ', Size: ', Path(container_file).stat().st_size) + with export_slc(str(tmp_path)) as container_file: + print('\nContainer file:', container_file, ', Size: ', Path(container_file).stat().st_size) - args_string = (f'{cli_args} ' - f'{std_param_to_opt(StdParams.schema)} "{DB_SCHEMA}" ' - f'{std_param_to_opt(StdParams.container_file)} "{container_file}"') + args_string = (f'{cli_args} ' + f'{std_param_to_opt(StdParams.schema)} "{DB_SCHEMA}" ' + f'{std_param_to_opt(StdParams.container_file)} "{container_file}"') - print('\nArgs:', args_string) + print('Args:', args_string) - runner = CliRunner() - result = runner.invoke(deploy_command, args=args_string, catch_exceptions=False) + runner = CliRunner() + result = runner.invoke(deploy_command, args=args_string, catch_exceptions=False) print('\nCliRunner completed.') print('Exit code:', result.exit_code)