Skip to content

Commit c77f1d9

Browse files
authored
Release v1.3.0 (#13)
1 parent 0a33597 commit c77f1d9

File tree

6 files changed

+84
-11
lines changed

6 files changed

+84
-11
lines changed

submodules/s3

Submodule s3 updated 1 file

upgrade_logic/base_logic.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from typing import List
2-
from .business_objects import general, neural_search
2+
from .business_objects import general, neural_search, gateway
33

44

55
# if a new business object file is introduced it needes to be added here
6-
__lookup_upgrade_bo = {"general": general, "neural_search": neural_search}
6+
__lookup_upgrade_bo = {
7+
"general": general,
8+
"neural_search": neural_search,
9+
"gateway": gateway,
10+
}
711

812

913
def loop_functions_between_version(
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import re
2+
from submodules.model.business_objects import attribute, embedding, user, general
3+
4+
5+
def gateway_1_3_0() -> bool:
6+
__gateway_1_3_0_add_engineer()
7+
__gateway_1_3_0_add_attribute_for_embedding()
8+
__gateway_1_3_0_add_attribute_default_state()
9+
return True
10+
11+
12+
def __gateway_1_3_0_add_engineer() -> bool:
13+
print("add ENGINEER role to existing users", flush=True)
14+
users = user.get_all()
15+
something_changed = False
16+
for u in users:
17+
if not u.role:
18+
u.role = "ENGINEER"
19+
something_changed = True
20+
if something_changed:
21+
general.commit()
22+
print("Added role.", flush=True)
23+
else:
24+
print("Nothing changed", flush=True)
25+
return something_changed
26+
27+
28+
def __gateway_1_3_0_add_attribute_for_embedding() -> bool:
29+
print("add attribute id to existing embeddings", flush=True)
30+
embedding_added = False
31+
embedding_items = embedding.get_all_embeddings()
32+
for i, embedding_item in enumerate(embedding_items):
33+
if embedding_item.attribute_id is None:
34+
attribute_name = __get_attribute_name_from_embedding_name(
35+
embedding_item.name
36+
)
37+
attribute_item = attribute.get_by_name(
38+
embedding_item.project_id, attribute_name
39+
)
40+
embedding_item.attribute_id = attribute_item.id
41+
embedding_added = True
42+
if embedding_added:
43+
general.commit()
44+
print("Added attribute id.", flush=True)
45+
else:
46+
print("No attribute id added.", flush=True)
47+
48+
return embedding_added
49+
50+
51+
def __get_attribute_name_from_embedding_name(embedding_name: str) -> str:
52+
regex = "^(.+)-(?:classification|extraction).*"
53+
return re.match(regex, embedding_name).group(1)
54+
55+
56+
def __gateway_1_3_0_add_attribute_default_state() -> bool:
57+
print("add UPLOADED state to existing attributes", flush=True)
58+
attributes = attribute.get_all(None, None)
59+
something_changed = False
60+
for a in attributes:
61+
if not a.state:
62+
a.state = "UPLOADED"
63+
something_changed = True
64+
if something_changed:
65+
general.commit()
66+
print("Added state.", flush=True)
67+
else:
68+
print("Nothing changed", flush=True)
69+
return something_changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# function name tamplate: <service_name>_<version_with_underscore>
22
# example: update logic for service AUTHORIZER for version 1.2.2 would be def authorizer_1_2_2()->bool:
33
# should always return True if update logic was successful
4+
# private functions can be used as helper functions, since they do not start with the service name

upgrade_logic/business_objects/neural_search.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import os
32
import requests
43

@@ -8,13 +7,13 @@
87
NEURAL_SEARCH = os.getenv("NEURAL_SEARCH")
98

109

11-
def neural_search_1_2_1()->bool:
12-
print("upgrade qdrant version, recreate collections",flush=True)
10+
def neural_search_1_2_1() -> bool:
11+
print("upgrade qdrant version, recreate collections", flush=True)
1312
success = __recreate_qdrant_collections()
1413
if success:
15-
print("Recreated all collections.",flush=True)
14+
print("Recreated all collections.", flush=True)
1615
else:
17-
print("Recreating collections failed.",flush=True)
16+
print("Recreating collections failed.", flush=True)
1817
return success
1918

2019

@@ -43,7 +42,7 @@ def __recreate_qdrant_collections() -> bool:
4342
response = requests.put(url=url_missing_collections)
4443

4544
if response.status_code != 200 and response.status_code != 412:
46-
print(response.content,flush=True)
45+
print(response.content, flush=True)
4746
success = False
4847

49-
return success
48+
return success

0 commit comments

Comments
 (0)