welearn-database 1.4.4__tar.gz → 1.4.5.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/PKG-INFO +1 -1
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/pyproject.toml +1 -1
- welearn_database-1.4.5.dev0/welearn_database/alembic/versions/8b780aea403a_add_university_data.py +48 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/enumeration.py +6 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/document_related.py +0 -1
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/user_related.py +19 -2
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/exceptions.py +20 -3
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/LICENSE +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/README.md +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/__init__.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/README +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/env.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/script.py.mako +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/068312e7800c_add_referrer_origin_column_to_user_and_.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/0e0bc0fca384_doc_qty_per_source.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/16ff997426d3_remove_error_retrieval_unique_constraint.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/2ad4895b2674_data_collection.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/4c7161819e5a_grafana_views.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/4f5a188dd614_add_main_url_column.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/4fcbfb7f3145_added_api_key_management_table.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/5d82613c9aca_context_document.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/821173cf9c5d_initial_migration.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/84c42739c17b_create_table_errordataquality.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/89920abb7ff8_add_category.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/96bba9e4842a_merge_external_id_error_quality.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/9b4f1da0c1f2_data_collection_for_focus_group.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/a50a1db3ca2a_add_used_since_column_for_embeddings.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/b031206324b7_agent_related.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/b049924f7067_modify_corpus_name_embedding_model_lang_.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/ccdbd708c997_create_column_external_id.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/e354666f951d_inferred_user.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/f1ce0ad2845b_add_doi_column_to_document.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/versions/f8602200fa99_update_session_view.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/__init__.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/__init__.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/agent_related.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/corpus_related.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/grafana.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/database_utils.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/modules/__init__.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/modules/text_cleaning.py +0 -0
- {welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/regular_expression.py +0 -0
welearn_database-1.4.5.dev0/welearn_database/alembic/versions/8b780aea403a_add_university_data.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""add_university_data
|
|
2
|
+
|
|
3
|
+
Revision ID: 8b780aea403a
|
|
4
|
+
Revises: f1ce0ad2845b
|
|
5
|
+
Create Date: 2026-06-03 11:34:02.441435
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
from sqlalchemy.dialects import postgresql
|
|
14
|
+
|
|
15
|
+
# revision identifiers, used by Alembic.
|
|
16
|
+
revision: str = "8b780aea403a"
|
|
17
|
+
down_revision: Union[str, None] = "f1ce0ad2845b"
|
|
18
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
19
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def upgrade() -> None:
|
|
23
|
+
op.add_column(
|
|
24
|
+
"inferred_user",
|
|
25
|
+
sa.Column("university_title", sa.String(), nullable=True),
|
|
26
|
+
schema="user_related",
|
|
27
|
+
)
|
|
28
|
+
op.add_column(
|
|
29
|
+
"inferred_user",
|
|
30
|
+
sa.Column(
|
|
31
|
+
"role",
|
|
32
|
+
postgresql.ENUM(
|
|
33
|
+
"student",
|
|
34
|
+
"teacher",
|
|
35
|
+
"staff",
|
|
36
|
+
name="university_role",
|
|
37
|
+
schema="user_related",
|
|
38
|
+
),
|
|
39
|
+
nullable=True,
|
|
40
|
+
),
|
|
41
|
+
schema="user_related",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def downgrade() -> None:
|
|
46
|
+
op.drop_column("inferred_user", "university_title", schema="user_related")
|
|
47
|
+
op.drop_column("inferred_user", "role", schema="user_related")
|
|
48
|
+
op.execute("DROP TYPE user_related.university_role")
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/user_related.py
RENAMED
|
@@ -3,11 +3,12 @@ from uuid import UUID
|
|
|
3
3
|
|
|
4
4
|
from sqlalchemy import ForeignKey, func, types
|
|
5
5
|
from sqlalchemy.dialects.postgresql import ENUM, TIMESTAMP
|
|
6
|
-
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
|
+
from sqlalchemy.orm import Mapped, mapped_column, relationship, validates
|
|
7
7
|
|
|
8
|
-
from welearn_database.data.enumeration import DbSchemaEnum, FilterType
|
|
8
|
+
from welearn_database.data.enumeration import DbSchemaEnum, FilterType, UniversityRole
|
|
9
9
|
from welearn_database.data.models.document_related import WeLearnDocument
|
|
10
10
|
|
|
11
|
+
from ...exceptions import EarlyEnumerationVerificationError
|
|
11
12
|
from . import Base
|
|
12
13
|
|
|
13
14
|
schema_name = DbSchemaEnum.USER_RELATED.value
|
|
@@ -216,6 +217,15 @@ class InferredUser(Base):
|
|
|
216
217
|
types.Uuid, primary_key=True, nullable=False, server_default="gen_random_uuid()"
|
|
217
218
|
)
|
|
218
219
|
origin_referrer: Mapped[str | None]
|
|
220
|
+
university_title: Mapped[str | None]
|
|
221
|
+
role: Mapped[str] = mapped_column(
|
|
222
|
+
ENUM(
|
|
223
|
+
*(r.value.lower() for r in UniversityRole),
|
|
224
|
+
name="university_role",
|
|
225
|
+
schema="user_related",
|
|
226
|
+
),
|
|
227
|
+
nullable=True,
|
|
228
|
+
)
|
|
219
229
|
created_at: Mapped[datetime] = mapped_column(
|
|
220
230
|
TIMESTAMP(timezone=False),
|
|
221
231
|
nullable=False,
|
|
@@ -223,6 +233,13 @@ class InferredUser(Base):
|
|
|
223
233
|
server_default="NOW()",
|
|
224
234
|
)
|
|
225
235
|
|
|
236
|
+
@validates("role")
|
|
237
|
+
def validate_role(self, key, value):
|
|
238
|
+
valid_roles = {r.value.lower() for r in UniversityRole}
|
|
239
|
+
if value not in valid_roles:
|
|
240
|
+
raise EarlyEnumerationVerificationError(f"Invalid role: {value}")
|
|
241
|
+
return value
|
|
242
|
+
|
|
226
243
|
|
|
227
244
|
class EndpointRequest(Base):
|
|
228
245
|
__tablename__ = "endpoint_request"
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
class
|
|
1
|
+
class WeLearnDatabaseException(Exception):
|
|
2
|
+
"""
|
|
3
|
+
Base class for all WeLearnDatabase exceptions
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class InvalidURLScheme(WeLearnDatabaseException):
|
|
2
8
|
"""
|
|
3
9
|
Scheme detected in URL is not accepted
|
|
4
10
|
"""
|
|
@@ -7,7 +13,7 @@ class InvalidURLScheme(Exception):
|
|
|
7
13
|
super().__init__(msg, *args)
|
|
8
14
|
|
|
9
15
|
|
|
10
|
-
class InvalidDOI(
|
|
16
|
+
class InvalidDOI(WeLearnDatabaseException):
|
|
11
17
|
"""
|
|
12
18
|
Scheme detected in DOI is not accepted
|
|
13
19
|
"""
|
|
@@ -16,7 +22,7 @@ class InvalidDOI(Exception):
|
|
|
16
22
|
super().__init__(msg, *args)
|
|
17
23
|
|
|
18
24
|
|
|
19
|
-
class ContentIsTooShort(
|
|
25
|
+
class ContentIsTooShort(WeLearnDatabaseException):
|
|
20
26
|
"""
|
|
21
27
|
The string used as content is too short, it should be at least 25 characters long
|
|
22
28
|
"""
|
|
@@ -27,3 +33,14 @@ class ContentIsTooShort(Exception):
|
|
|
27
33
|
*args,
|
|
28
34
|
):
|
|
29
35
|
super().__init__(msg, *args)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class EarlyEnumerationVerificationError(WeLearnDatabaseException):
|
|
39
|
+
"""
|
|
40
|
+
SQLAlchemy detect an enumeration value that is not in the list of accepted values
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(
|
|
44
|
+
self, msg="Enumeration value is not in the list of accepted values", *args
|
|
45
|
+
):
|
|
46
|
+
super().__init__(msg, *args)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/alembic/script.py.mako
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/__init__.py
RENAMED
|
File without changes
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/agent_related.py
RENAMED
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/data/models/grafana.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/modules/text_cleaning.py
RENAMED
|
File without changes
|
{welearn_database-1.4.4 → welearn_database-1.4.5.dev0}/welearn_database/regular_expression.py
RENAMED
|
File without changes
|