Skip to content

Commit 9862052

Browse files
authored
#173: Added an option to upload an SLC from file (#174)
* #173: Added an option to upload an SLC from file * #173: Addressed review comments
1 parent 53eb7ee commit 9862052

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

doc/changes/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* #146: Add interface for text_ai_extension_wrapper
88
* #169: Added a function that creates a bucket-fs PathLike object
9+
* #173: Added an option to upload an SLC from file.
910

1011
## Refactoring
1112

exasol/nb_connector/extension_wrapper_common.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional
33
from datetime import timedelta
44
import json
5+
from pathlib import Path
56

67
import exasol.bucketfs as bfs
78
from exasol.python_extension_common.deployment.extract_validator import ExtractValidator
@@ -55,11 +56,12 @@ def _get_optional_bfs_port(conf: Secrets) -> int | None:
5556

5657

5758
def deploy_language_container(conf: Secrets,
58-
container_url: str,
59-
container_name: str,
6059
path_in_bucket: str,
6160
language_alias: str,
6261
activation_key: str,
62+
container_url: str | None = None,
63+
container_file: Path | None = None,
64+
container_name: str | None = None,
6365
allow_override: bool = True,
6466
timeout: timedelta = timedelta(minutes=10)) -> None:
6567
"""
@@ -73,16 +75,24 @@ def deploy_language_container(conf: Secrets,
7375
conf:
7476
The secret store. The store must contain the DB connection parameters
7577
and the parameters of the BucketFS service.
76-
container_url:
77-
The url to download the language container from
78-
container_name:
79-
The language container will be saved in the BucketFS with this name.
8078
path_in_bucket:
8179
Path in the BucketFS where the container should be saved.
8280
language_alias:
8381
The language alias of the extension's language container.
8482
activation_key:
8583
A secret store key for saving the activation SQL.
84+
container_url:
85+
An optional URL to download the language container from.
86+
Either the `container_url` or `container_file` must be provided,
87+
otherwise a ValueError will be raised.
88+
container_file:
89+
An optional path of the container file (*.tar.gz) in a local file system.
90+
Either the `container_url` or `container_file` must be provided,
91+
otherwise a ValueError will be raised.
92+
container_name:
93+
If provided, the language container will be saved in given bucket of
94+
BucketFS with this filename. Otherwise, the name of the container file
95+
will be used.
8696
allow_override:
8797
If True allows overriding the language definition.
8898
timeout:
@@ -101,11 +111,20 @@ def deploy_language_container(conf: Secrets,
101111
extract_validator=validator
102112
)
103113

104-
deployer.download_and_run(container_url,
105-
container_name,
106-
alter_system=False,
107-
allow_override=allow_override,
108-
wait_for_completion=True)
114+
if container_file:
115+
deployer.run(container_file,
116+
container_name,
117+
alter_system=False,
118+
allow_override=allow_override,
119+
wait_for_completion=True)
120+
elif container_url:
121+
deployer.download_and_run(container_url,
122+
container_name,
123+
alter_system=False,
124+
allow_override=allow_override,
125+
wait_for_completion=True)
126+
else:
127+
raise ValueError("Either container URL or container file must be provided")
109128

110129
# Install the language container.
111130
# Save the activation SQL in the secret store.

0 commit comments

Comments
 (0)