Skip to content

Commit fa92fd3

Browse files
committed
[owl] Make email_verified API updateable ; Bug fixes for parent ID checks (#889)
Backend - owl (API server) - Allow `email_verified` to be updated via API - Fix Cache `_ex_jitter` logic - Add metadata to transaction error logging - Bug fixes: - Ensure that parent ID exists when creating or importing table, and new table ID cannot be the same as parent ID - Drop table will now fail if there are child tables - Creating, duplicating, and importing tables will fail if its parent table is a child table - Project schema creation will now take a project-scoped Postgres advisory transaction lock to prevent concurrent creation - Close file handlers after reading - Improve `mask_content` Misc - Add script to switch tier
1 parent 6e6c8e4 commit fa92fd3

16 files changed

Lines changed: 431 additions & 118 deletions

File tree

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*.js* text
2323
*.md text
2424
*.py text
25-
*.sh text
2625

2726
# These files are binary and should be left untouched
2827
# `binary` is a built-in macro for `-text` `-diff` (ie unset `text` and `diff`)

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,10 @@ venv/
3030
**/.coverage*
3131
/junit
3232
/htmlcov
33-
/coverage.xml
3433

3534
# ruff
3635
.ruff_cache/
3736

38-
# OS
39-
thumbs.db
40-
.DS_Store
41-
4237
# javascript compiled code
4338
clients/typescript/**/*.js*
4439
clients/typescript/dist/**

clients/python/src/jamaibase/types/db.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,12 @@ class _UserBase(_BaseModel):
896896
"",
897897
description="User's email.",
898898
)
899+
# Allow this to be updated by the frontend service
900+
# NOTE: We should consider moving auth into backend to avoid this
901+
email_verified: bool = Field(
902+
False,
903+
description="Whether the email address is verified.",
904+
)
899905
picture_url: AnyUrl | None = Field(
900906
None,
901907
description="User picture URL.",
@@ -984,9 +990,6 @@ class User_(_UserBase, _TableBase):
984990
default_factory=uuid7_str,
985991
description="User ID.",
986992
)
987-
email_verified: bool = Field(
988-
description="Whether the email address is verified.",
989-
)
990993
password_hash: Annotated[str | None, BeforeValidator(_obscure_password_hash)] = Field(
991994
description="Password hash.",
992995
)

clients/python/src/jamaibase/utils/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,29 @@ def mask_string(x: str | None, *, include_len: bool = True) -> str | None:
4444
if x is None or x == "":
4545
return x
4646
str_len = len(x)
47-
if str_len < 4:
48-
return f"{'*' * str_len} ({str_len=})"
47+
if str_len < 5:
48+
return f"{'*' * str_len}"
4949
visible_len = min(100, str_len // 5)
5050
x = f"{x[:visible_len]}***{x[-visible_len:]}"
5151
return f"{x} ({str_len=})" if include_len else x
5252

5353

5454
def mask_content(x: str | list | dict | np.ndarray | Any) -> str | list | dict | None:
55+
if x is None:
56+
return x
57+
if isinstance(x, bool):
58+
return x
5559
if isinstance(x, str):
60+
if x == "":
61+
return x
5662
return mask_string(x)
5763
if isinstance(x, list):
5864
return [mask_content(v) for v in x]
5965
if isinstance(x, dict):
6066
return {k: mask_content(v) for k, v in x.items()}
6167
if isinstance(x, np.ndarray):
6268
return f"array(shape={x.shape}, dtype={x.dtype})"
63-
return None
69+
return mask_string(str(x))
6470

6571

6672
def merge_dict(d: dict | Any, update: dict | Any):

clients/python/src/jamaibase/utils/io.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import csv
2-
import logging
32
import pickle
43
from collections import OrderedDict
54
from io import StringIO
@@ -13,12 +12,11 @@
1312
import pandas as pd
1413
import toml
1514
import yaml
15+
from loguru import logger
1616
from PIL import ExifTags, Image
1717

1818
from jamaibase.types.common import JSONInput, JSONOutput
1919

20-
logger = logging.getLogger(__name__)
21-
2220
EMBED_WHITE_LIST = {
2321
"application/pdf": [".pdf"],
2422
"application/xml": [".xml"],

0 commit comments

Comments
 (0)