Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#142 Made unified deployment #143

Merged
merged 15 commits into from
Oct 11, 2024
15 changes: 15 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ jobs:
- name: SCM Checkout
uses: actions/checkout@v4

- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false

- name: Free disk space by removing large directories
run: |
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /opt/ghc

- name: Setup Python & Poetry Environment
uses: ./.github/actions/prepare_poetry_env
with:
Expand Down
3 changes: 2 additions & 1 deletion doc/changes/changes_0.11.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ T.B.D.

### Refactoring

* #140: Using the pytest plugins for testing.
* #140: Used the pytest plugins for testing.
* #142: Made a unified deployment CLI command.
55 changes: 41 additions & 14 deletions exasol_sagemaker_extension/deploy.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
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:
# Workaround for the issue#78 in PEC
if StdParams.path_in_bucket.name in kwargs and kwargs[StdParams.path_in_bucket.name] is None:
kwargs[StdParams.path_in_bucket.name] = ''

slc_deployer = LanguageContainerDeployerCli(
container_url_arg=CONTAINER_URL_ARG,
container_name_arg=CONTAINER_NAME_ARG)

extra_params = {StdParams.language_alias.name: 'PYTHON3_SME'}
Copy link
Collaborator

@tkilias tkilias Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok you hard code the alias for the moment. Until we fixed the script templates that should be good enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly

slc_deployer(**kwargs, **extra_params)

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.

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


def export_slc():
export_dir = sys.argv[1]
if not os.path.isdir(export_dir):
@contextmanager
def export_slc(export_dir: str | None = None):
if export_dir and (not os.path.isdir(export_dir)):
os.makedirs(export_dir)
with language_container_factory() as container_builder:
container_builder.export(export_dir)
export_result = container_builder.export(export_dir)
export_info = export_result.export_infos[str(container_builder.flavor_path)]["release"]
yield export_info.cache_file


if __name__ == '__main__':
export_slc()
with export_slc(sys.argv[1]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, as a quick workaround, because we don't have nox yet setup

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, basically it was like this before. I just changed the export_slc function slightly for the convenience of testing.

pass
Loading
Loading