Skip to content

Commit 6eb2f7a

Browse files
JWittmeyerlumburovskalinaandhreljaKern
authored
v1.20.0 (#316)
* Change num workers to 25 for azure foundry and others to 50 * The flag for projects from integrations is missing * Count not displayed on embeddings table * fix: org buttons failure * chore: update submodules * Assign role when inviting user * Message for invalid emails * Submodule update * change logic * PR comments * Submodule update --------- Co-authored-by: Lina <[email protected]> Co-authored-by: andhreljaKern <[email protected]>
1 parent 7f329b1 commit 6eb2f7a

File tree

8 files changed

+46
-15
lines changed

8 files changed

+46
-15
lines changed

controller/attribute/util.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ def prepare_llm_response_code(
250250
llm_playground_config: Union[Dict[str, Any], None] = None,
251251
llm_ac_cache_access_link: Union[str, None] = None,
252252
llm_ac_cache_file_upload_link: Union[str, None] = None,
253-
num_workers: int = 100,
254253
max_api_call_retries: int = 5,
255254
retry_sleep_seconds: int = 5,
256255
) -> str:
@@ -294,6 +293,14 @@ async def ac(record):
294293
)
295294
validate_llm_config(llm_config=llm_config)
296295

296+
num_workers = 50
297+
if (
298+
llm_config is not None
299+
and enums.LLMProvider.from_string(llm_config.get("llmIdentifier", "Open ai"))
300+
== enums.LLMProvider.AZURE_FOUNDRY
301+
):
302+
num_workers = 25
303+
297304
try:
298305
llm_config_mapping = {
299306
"@@API_KEY@@": llm_config["apiKey"],

controller/auth/manager.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
DEV_USER_ID = "741df1c2-a531-43b6-b259-df23bc78e9a2"
2121

22-
EMAIL_RE = re.compile(r"[\w\.-]+@[\w\.-]+\.\w+")
22+
EMAIL_RE = re.compile(r"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$")
2323

2424

2525
def get_organization_id_by_info(info) -> Organization:
@@ -174,7 +174,10 @@ def check_is_full_admin(request: Any) -> bool:
174174

175175

176176
def invite_users(
177-
emails: List[str], organization_name: str, provider: Optional[str] = None
177+
emails: List[str],
178+
organization_name: str,
179+
user_role: str,
180+
provider: Optional[str] = None,
178181
):
179182
user_ids = []
180183
for email in emails:
@@ -186,6 +189,9 @@ def invite_users(
186189
# Assign the account to the organization
187190
user_manager.update_organization_of_user(organization_name, email)
188191

192+
# Assign the user role
193+
user_manager.update_user_role(user["id"], user_role)
194+
189195
# Get the recovery link for the email
190196
recovery_link = kratos.get_recovery_link(user["id"])
191197
if not recovery_link:
@@ -197,13 +203,18 @@ def invite_users(
197203

198204

199205
def check_valid_emails(emails: List[str]):
200-
valid_emails = [
201-
email
202-
for email in emails
203-
if is_valid_email(email) and not kratos.check_user_exists(email)
204-
]
206+
message = ""
207+
valid_emails = []
208+
for email in emails:
209+
if not is_valid_email(email):
210+
message += f"{email} is not a valid email address."
211+
elif kratos.check_user_exists(email):
212+
message += f"{email} already exists."
213+
else:
214+
valid_emails.append(email)
215+
205216
all_valid = len(valid_emails) == len(emails)
206-
return {"valid_emails": valid_emails, "all_valid": all_valid}
217+
return {"valid_emails": valid_emails, "all_valid": all_valid, "message": message}
207218

208219

209220
def is_valid_email(email: str) -> bool:

controller/misc/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def finalize_customer_buttons(
9393
for e in buttons:
9494
e[key_name] = name_lookup[str(e[key])]
9595
e[key_name] = (
96-
(e[key_name]["first"] + " " + e[key_name]["last"])
96+
(e[key_name].get("first", "") + " " + e[key_name].get("last", ""))
9797
if e[key_name]
9898
else "Unknown"
9999
)

controller/project/manager.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from controller.task_master import manager as task_master_manager
2424
from submodules.model.enums import TaskType, RecordTokenizationScope
2525
from submodules.model.business_objects import util as db_util
26+
from submodules.model.cognition_objects import integration as integration_db_co
2627
from submodules.model.integration_objects.helper import (
2728
REFINERY_ATTRIBUTE_ACCESS_GROUPS,
2829
REFINERY_ATTRIBUTE_ACCESS_USERS,
@@ -133,12 +134,16 @@ def is_access_management_activated(project_id: str) -> bool:
133134
return access_groups is not None and access_users is not None
134135

135136

136-
def get_all_projects_by_user(organization_id) -> List[Project]:
137+
def get_all_projects_by_user(organization_id: str) -> List[Project]:
137138
projects = project.get_all_by_user_organization_id(organization_id)
138139
project_dicts = sql_alchemy_to_dict(
139140
projects, column_whitelist=ALL_PROJECTS_WHITELIST
140141
)
141142

143+
all_integration_project_ids = {
144+
i.project_id for i in integration_db_co.get_all_in_org(organization_id)
145+
}
146+
142147
for p in project_dicts:
143148
user_id = p["created_by"]
144149
names, mail = kratos.resolve_user_name_and_email_by_id(user_id)
@@ -155,6 +160,8 @@ def get_all_projects_by_user(organization_id) -> List[Project]:
155160
else:
156161
p["num_data_scale_uploaded"] = record.get_count_scale_uploaded(p["id"])
157162

163+
p["is_integration_project"] = p["id"] in all_integration_project_ids
164+
158165
del p["created_by"]
159166

160167
return project_dicts

fast_api/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ class InviteUsersBody(BaseModel):
502502
emails: List[StrictStr]
503503
organization_name: StrictStr
504504
provider: Optional[StrictStr] = None
505+
user_role: StrictStr
505506

506507

507508
class CheckInviteUsersBody(BaseModel):

fast_api/routes/embedding.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from controller.auth import manager as auth_manager
1717
from controller.embedding.connector import collection_on_qdrant
1818
from submodules.model.enums import TaskType
19-
from submodules.model.business_objects import embedding
19+
from submodules.model.business_objects import embedding as embedding_bo
2020
from submodules.model.cognition_objects import environment_variable as env_var_db_bo
2121
from submodules.model.util import sql_alchemy_to_dict
2222
from util import notification, spacy_util
@@ -51,13 +51,16 @@ def language_models(request: Request) -> List:
5151
dependencies=[Depends(auth_manager.check_project_access_dep)],
5252
)
5353
def get_embeddings(project_id: str) -> List:
54-
embeddings_extended = embedding.get_all_embeddings_by_project_id_extended(
54+
embeddings_extended = embedding_bo.get_all_embeddings_by_project_id_extended(
5555
project_id
5656
)
5757
data = [
5858
{
5959
**sql_alchemy_to_dict(embedding),
6060
"on_qdrant": collection_on_qdrant(project_id, embedding["id"]),
61+
"count": sql_alchemy_to_dict(
62+
embedding_bo.get_tensor_count(embedding["id"])
63+
),
6164
}
6265
for embedding in embeddings_extended
6366
]

fast_api/routes/misc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ def get_is_full_admin(request: Request) -> Dict:
293293
def invite_users(request: Request, body: InviteUsersBody = Body(...)):
294294
if not auth.check_is_full_admin(request):
295295
raise AuthManagerError("Full admin access required")
296-
data = auth.invite_users(body.emails, body.organization_name, body.provider)
296+
data = auth.invite_users(
297+
body.emails, body.organization_name, body.user_role, body.provider
298+
)
297299
return pack_json_result(data)
298300

299301

0 commit comments

Comments
 (0)