Skip to content

Commit

Permalink
#142 Made unified deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Oct 10, 2024
1 parent 516b848 commit 2be34dd
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 374 deletions.
50 changes: 36 additions & 14 deletions exasol_sagemaker_extension/deploy.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
import logging
import click
from exasol_sagemaker_extension.deployment.deploy_cli import main as scripts_deployer_main
from exasol.python_extension_common.deployment.language_container_deployer_cli \
import language_container_deployer_main, slc_parameter_formatters, CustomizableParameters
from exasol_sagemaker_extension.deployment.sme_language_container_deployer import SmeLanguageContainerDeployer
from exasol.python_extension_common.cli.std_options import (
StdParams, StdTags, select_std_options, ParameterFormatters)
from exasol.python_extension_common.cli.language_container_deployer_cli import (
LanguageContainerDeployerCli)

from exasol_sagemaker_extension.deployment.sme_language_container_deployer import (
SmeLanguageContainerDeployer)
from exasol_sagemaker_extension.deployment.deploy_create_statements import (
DeployCreateStatements)

@click.group()
def main():
pass
CONTAINER_URL_ARG = 'container_url'
CONTAINER_NAME_ARG = 'container_name'

ver_formatter = ParameterFormatters()
ver_formatter.set_formatter(CONTAINER_URL_ARG, SmeLanguageContainerDeployer.SLC_URL_FORMATTER)
ver_formatter.set_formatter(CONTAINER_NAME_ARG, SmeLanguageContainerDeployer.SLC_NAME)
formatters = {StdParams.version: ver_formatter}

slc_parameter_formatters.set_formatter(CustomizableParameters.container_url,
SmeLanguageContainerDeployer.SLC_URL_FORMATTER)
slc_parameter_formatters.set_formatter(CustomizableParameters.container_name,
SmeLanguageContainerDeployer.SLC_NAME)
opts = select_std_options([StdTags.DB, StdTags.BFS, StdTags.SLC],
exclude=StdParams.language_alias, formatters=formatters)
opts.append(click.Option('--to-print/--no-to-print', type=bool, default=False))
opts.append(click.Option('--develop/--no-develop', type=bool, default=False))
opts.append(click.Option('--deploy-slc/--no-deploy-slc', type=bool, default=True))
opts.append(click.Option('--deploy-scripts/--no-deploy-scripts', type=bool, default=True))

main.add_command(scripts_deployer_main)
main.add_command(language_container_deployer_main)

def deploy(deploy_slc: bool, deploy_scripts: bool, **kwargs):

if deploy_slc:
slc_deployer = LanguageContainerDeployerCli(
container_url_arg=CONTAINER_URL_ARG,
container_name_arg=CONTAINER_NAME_ARG)

slc_deployer(**kwargs)

if deploy_scripts:
DeployCreateStatements.create_and_run(**kwargs)


deploy_command = click.Command(None, params=opts, callback=deploy)


if __name__ == '__main__':
logging.basicConfig(
format='%(asctime)s - %(module)s - %(message)s',
level=logging.DEBUG)

main()
deploy_command()
79 changes: 0 additions & 79 deletions exasol_sagemaker_extension/deployment/deploy_cli.py

This file was deleted.

5 changes: 2 additions & 3 deletions exasol_sagemaker_extension/deployment/language_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ def language_container_factory():
yield container_builder


def export_slc():
export_dir = sys.argv[1]
def export_slc(export_dir: str):
if not os.path.isdir(export_dir):
os.makedirs(export_dir)
with language_container_factory() as container_builder:
container_builder.export(export_dir)


if __name__ == '__main__':
export_slc()
export_slc(sys.argv[1])
Loading

0 comments on commit 2be34dd

Please sign in to comment.