Skip to content

Commit 05e8a9f

Browse files
format:fix
1 parent c33e4fb commit 05e8a9f

6 files changed

Lines changed: 105 additions & 24 deletions

File tree

exasol_transformers_extension/deployment/create_script.sql

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,74 @@ def run(ctx):
5555

5656

5757
/
58+
CREATE OR REPLACE PYTHON3_TE SCALAR SCRIPT "TE_LIST_MODELS_UDF"(
59+
bucketfs_conn VARCHAR(2000000),
60+
sub_dir VARCHAR(2000000)
61+
) EMITS (
62+
bucketfs_conn VARCHAR(2000000),
63+
sub_dir VARCHAR(2000000),
64+
model_name VARCHAR(2000000),
65+
task_name VARCHAR(2000000),
66+
model_path VARCHAR(2000000),
67+
error_message VARCHAR(2000000) ) AS
68+
69+
"""
70+
Caller for ListModelsUDF
71+
"""
72+
73+
from exasol_transformers_extension.udfs.models.ls_models_udf import (
74+
ListModelsUDF,
75+
)
76+
77+
udf = ListModelsUDF(exa)
78+
79+
80+
def run(ctx):
81+
"""
82+
run function for ListModelsUDF
83+
"""
84+
return udf.run(ctx)
85+
86+
87+
/
88+
CREATE OR REPLACE PYTHON3_TE SET SCRIPT "AI_CUSTOM_CLASSIFY_EXTENDED"(
89+
device_id INTEGER,
90+
bucketfs_conn VARCHAR(2000000),
91+
sub_dir VARCHAR(2000000),
92+
model_name VARCHAR(2000000),
93+
text_data VARCHAR(2000000),
94+
return_ranks VARCHAR(2000000)
95+
ORDER BY model_name ASC,bucketfs_conn ASC,sub_dir ASC
96+
)EMITS (
97+
bucketfs_conn VARCHAR(2000000),
98+
sub_dir VARCHAR(2000000),
99+
model_name VARCHAR(2000000),
100+
text_data VARCHAR(2000000),
101+
return_ranks VARCHAR(2000000),
102+
label VARCHAR(2000000),
103+
score DOUBLE,
104+
rank INTEGER,
105+
error_message VARCHAR(2000000) ) AS
106+
107+
"""
108+
Caller for AiCustomClassifyUDF
109+
"""
110+
111+
from exasol_transformers_extension.udfs.models.ai_custom_classify_extended_udf import (
112+
AiCustomClassifyUDF,
113+
)
58114

115+
udf = AiCustomClassifyUDF(exa)
116+
117+
118+
def run(ctx):
119+
"""
120+
run function for AiCustomClassifyUDF
121+
"""
122+
return udf.run(ctx)
123+
124+
125+
/
59126
CREATE OR REPLACE PYTHON3_TE SET SCRIPT "AI_ENTAILMENT_EXTENDED"(
60127
device_id INTEGER,
61128
bucketfs_conn VARCHAR(2000000),

exasol_transformers_extension/deployment/scripts_deployer.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(
2828
self,
2929
language_alias: str,
3030
schema: str,
31-
pyexasol_conn: pyexasol.ExaConnection|None,
31+
pyexasol_conn: pyexasol.ExaConnection | None,
3232
use_spans: bool = False,
3333
install_all_scripts: bool = False,
3434
):
@@ -85,33 +85,34 @@ def _get_constant_set(self) -> list[InstallScriptsConstants]:
8585
install_scripts_constants.append(work_without_spans_constants)
8686
return install_scripts_constants
8787

88-
def write_create_sql_script(self, script_path):#todo wich udfs do we want to deploy with this script?
88+
def write_create_sql_script(
89+
self, script_path
90+
): # todo wich udfs do we want to deploy with this script?
8991
install_scripts_constants = self._get_constant_set()
9092
querys = {}
9193

9294
for constant_set in install_scripts_constants:
9395
querys = querys | self._make_script_deployment_querys(constant_set)
9496

9597
print(os.path)
96-
with open(script_path, "w") as create_script:#todo path
97-
create_script.write("-- this script is created automatically. Call 'write_create_script' if you need to update it.\n\n")
98+
with open(script_path, "w") as create_script: # todo path
99+
create_script.write(
100+
"-- this script is created automatically. Call 'write_create_script' if you need to update it.\n\n"
101+
)
98102

99103
for query in querys.values():
100104
# Write the new data to the file
101105
create_script.write(query)
102106
create_script.write("\n")
103107

104-
105108
def _deploy_udf_scripts_from_constants(
106109
self, constants_set: InstallScriptsConstants
107110
) -> None:
108111
querys = self._make_script_deployment_querys(constants_set)
109112

110113
for query_key in querys:
111114
self._pyexasol_conn.execute(querys[query_key])
112-
logger.debug(
113-
"The UDF statement of the template %s is executed.", query_key
114-
)
115+
logger.debug("The UDF statement of the template %s is executed.", query_key)
115116

116117
def _deploy_udf_scripts(self) -> None:
117118
"""

exasol_transformers_extension/deployment/write_create_script.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55

66
def write_create_script():
77
print("Write create script")
8-
sd = ScriptsDeployer(#todo make these options?
9-
language_alias="PYTHON3_TE", schema="test", pyexasol_conn=None, use_spans=True, install_all_scripts=True
8+
sd = ScriptsDeployer( # todo make these options?
9+
language_alias="PYTHON3_TE",
10+
schema="test",
11+
pyexasol_conn=None,
12+
use_spans=True,
13+
install_all_scripts=True,
1014
)
1115

1216
root_dir = Path(__file__).resolve().parent.parent
1317
script_path = root_dir / "deployment/create_script.sql"
1418
sd.write_create_sql_script(script_path)
1519
print("create_script written.")
1620

21+
1722
if __name__ == "__main__":
1823
write_create_script()

noxfile.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
"""Nox tasks for starting the test-db and integration tests"""
22

3+
import subprocess
34
import sys
45
from pathlib import Path
56

6-
import subprocess
7-
from noxconfig import (
8-
PROJECT_CONFIG,
9-
)
10-
117
import nox
128
from exasol.toolbox.nox._shared import (
139
get_filtered_python_files,
@@ -20,8 +16,12 @@
2016
from exasol_transformers_extension.deployment.language_container import (
2117
language_container_factory,
2218
)
23-
from exasol_transformers_extension.deployment.write_create_script import write_create_script
24-
from noxconfig import PROJECT_CONFIG
19+
from exasol_transformers_extension.deployment.write_create_script import (
20+
write_create_script,
21+
)
22+
from noxconfig import (
23+
PROJECT_CONFIG,
24+
)
2525

2626
sys.path += [str(Path().parent.absolute())]
2727
ROOT_PATH = Path(__file__).parent
@@ -167,6 +167,7 @@ def fmt_check(session: Session) -> None:
167167
py_files = get_filtered_python_files(PROJECT_CONFIG.root_path)
168168
_code_format(session=session, mode=Mode.Check, files=py_files)
169169

170+
170171
def _git_create_script_up_to_date() -> int:
171172
"""
172173
Check if "deployment/create_script.sql" needs to be changed and return the exit code of command git diff.
@@ -184,7 +185,13 @@ def _git_create_script_up_to_date() -> int:
184185
capture_output=True,
185186
) # nosec: B603, B607 - fixed git command; PATH lookup and args are trusted here
186187
print(p.stdout.decode())
187-
return False if "M exasol_transformers_extension/deployment/create_script.sql" in p.stdout.decode() else True
188+
return (
189+
False
190+
if "M exasol_transformers_extension/deployment/create_script.sql"
191+
in p.stdout.decode()
192+
else True
193+
)
194+
188195

189196
@nox.session(name="create_script:updated", python=False)
190197
def updated(_session: Session) -> None:
@@ -194,5 +201,6 @@ def updated(_session: Session) -> None:
194201
print(
195202
"create_script changes when running write_create_script.\n"
196203
"Please run write_create_script and commit the resulting changes!"
204+
"(if you run 'nox -s format:fix' this gets fixed automatically)"
197205
)
198206
sys.exit(1)

test/integration_tests/with_db/deployment/test_create_script.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from test.utils.db_queries import expected_script_list_all
22

33

4-
def test_create_script(
5-
setup_database, db_conn
6-
):
4+
def test_create_script(setup_database, db_conn):
75
"""
86
This test performs an installation of the extension.
97
It then runs the model upload test to verify that the installation
@@ -18,9 +16,11 @@ def test_create_script(
1816
result = db_conn.execute(query).fetchall()
1917
assert result.exit_code == 0
2018

21-
list_scripts_query = """SELECT SCRIPT_NAME FROM EXA_ALL_SCRIPTS WHERE SCRIPT_LANGUAGE=PYTHON3_TE"""
19+
list_scripts_query = (
20+
"""SELECT SCRIPT_NAME FROM EXA_ALL_SCRIPTS WHERE SCRIPT_LANGUAGE=PYTHON3_TE"""
21+
)
2222
result = db_conn.execute(list_scripts_query).fetchall()
2323

2424
assert result.exit_code == 0
2525
# verify all expected scripts are known by the database
26-
assert set(expected_scripts).issubset(set(result))
26+
assert set(expected_scripts).issubset(set(result))

test/integration_tests/with_db/deployment/test_deploy_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_deploy_cli(
7878
)
7979

8080
# check if DEFAULT_BUCKETFS_CONN_NAME was created
81-
run_model_upload_test( # todo this also tests if connection works, but is slower. which do we prefer?
81+
run_model_upload_test( # todo this also tests if connection works, but is slower. which do we prefer?
8282
bucketfs_cli_args,
8383
db_conn,
8484
bfs_path,

0 commit comments

Comments
 (0)