12
12
from exasol .nb_connector .secret_store import Secrets
13
13
from exasol .nb_connector .ai_lab_config import AILabConfig as CKey
14
14
15
- # Models will be uploaded into this directory in BucketFS.
15
+ # Models will be uploaded into directory BFS_MODELS_DIR in BucketFS.
16
+ #
16
17
# Models downloaded from the Huggingface archive to a local drive will be
17
- # cached in this directory.
18
- # we use the same dirs as in initialize_te_extension, because both extensions use
19
- # Huggingface Models and splitting them is confusing. So we reuse the TE directories to be also backwards compatible.
18
+ # cached in directory MODELS_CACHE_DIR.
19
+ #
20
+ # TXAIE uses the same directories as TE (see function initialize_te_extension)
21
+ # as both extensions are using Huggingface Models. This also avoids confusion,
22
+ # and ensures backwards compatibility.
20
23
from exasol .nb_connector .transformers_extension_wrapper import BFS_MODELS_DIR , MODELS_CACHE_DIR
21
24
22
25
23
- # Root directory in a BucketFS bucket where all stuff of the Text AI
24
- # Extension, including its language container, will be uploaded.
25
26
PATH_IN_BUCKET = "TXAIE"
27
+ """ Location in BucketFS bucket to upload data for TXAIE, e.g. its language container. """
26
28
27
29
LANGUAGE_ALIAS = "PYTHON3_TXAIE"
28
30
29
31
LATEST_KNOWN_VERSION = "???"
30
32
31
- # Activation SQL for the Text AI Extension will be saved in the secret
32
- # store with this key.
33
33
ACTIVATION_KEY = ACTIVATION_KEY_PREFIX + "txaie"
34
+ """
35
+ Activation SQL for the Text AI Extension will be saved in the secret store
36
+ with this key.
37
+
38
+ TXAIE brings its own Script Language Container (SLC) which needs to be
39
+ activated by a dedicated SQL statement `ALTER SESSION SET SCRIPT_LANGUAGES`. Applications
40
+ can store the language definition in the configuration store (SCS) from the Notebook
41
+ Connector's class `exasol.nb_connector.secret_store.Secrets`.
42
+
43
+ Using `ACTIVATION_KEY` as defined key, TXAIE can provide convenient interfaces
44
+ accepting only the SCS and retrieving all further data from the there.
45
+ """
34
46
35
47
# The name of the connection object with BucketFS location and credentials
36
48
# will be prefixed with this string.
@@ -159,36 +171,35 @@ def initialize_text_ai_extension(conf: Secrets,
159
171
container_name = "exasol_text_ai_extension_container_release.tar.gz"
160
172
161
173
174
+ def from_ai_lab_config (key : AILabConfig ) -> Path | None :
175
+ entry = conf .get (key )
176
+ return Path (entry ) if entry else None
177
+
162
178
if run_deploy_container :
163
179
if version :
164
- install_txaie_version (version )
180
+ install_text_ai_extension (version )
181
+ # Can run_upload_models, run_deploy_scripts,
182
+ # run_encapsulate_bfs_credentials, etc. be ignored here?
165
183
return
184
+
185
+ container_file = container_file or from_ai_lab_config (CKey .txaie_slc_file_local_path )
166
186
if not container_file :
167
- # if container_file and version are not set,
168
- # use txaie_slc_file_local_path for installing the slc, if it exists
169
- try :
170
- container_file_str = str (conf .get (CKey .txaie_slc_file_local_path ))
171
- container_file = Path (container_file_str )
172
- finally :
173
- pass
174
-
175
- if container_file :
176
- deploy_language_container (conf = conf ,
177
- path_in_bucket = PATH_IN_BUCKET ,
178
- language_alias = language_alias ,
179
- activation_key = ACTIVATION_KEY ,
180
- container_file = container_file ,
181
- container_name = container_name ,
182
- allow_override = allow_override ,
183
- )
184
- else :
185
- version = LATEST_KNOWN_VERSION
186
- install_txaie_version (version )
187
+ install_text_ai_extension (LATEST_KNOWN_VERSION )
188
+ else
189
+ deploy_language_container (
190
+ conf = conf ,
191
+ path_in_bucket = PATH_IN_BUCKET ,
192
+ language_alias = language_alias ,
193
+ activation_key = ACTIVATION_KEY ,
194
+ container_file = container_file ,
195
+ container_name = container_name ,
196
+ allow_override = allow_override ,
197
+ )
187
198
188
199
189
200
190
201
if run_upload_models :
191
- # Install default transformers models into the Bucketfs using
202
+ # Install default Hugging Face models into the Bucketfs using
192
203
# Transformers Extensions upload model functionality.
193
204
raise NotImplementedError ('Implementation is waiting for TE release.' )
194
205
@@ -202,10 +213,8 @@ def initialize_text_ai_extension(conf: Secrets,
202
213
conf , path_in_bucket = PATH_IN_BUCKET , connection_name = bfs_conn_name
203
214
)
204
215
205
- # Save the connection object names in the secret store.
216
+ # Update secret store
206
217
conf .save (CKey .txaie_bfs_connection , bfs_conn_name )
207
-
208
- # Save the directory names in the secret store
209
218
conf .save (CKey .txaie_models_bfs_dir , BFS_MODELS_DIR )
210
219
conf .save (CKey .txaie_models_cache_dir , MODELS_CACHE_DIR )
211
220
0 commit comments