Skip to content

Commit e244b1f

Browse files
author
GitHub CI
committed
feat/onboarding-new-user
1 parent 71ba6e7 commit e244b1f

File tree

336 files changed

+3980
-1838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+3980
-1838
lines changed

api/ee/databases/postgres/migrations/core/data_migrations/workspaces.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def create_default_project_for_workspaces(session: Connection):
5656
for workspace in workspaces:
5757
# Create a new default project for each workspace
5858
get_or_create_workspace_default_project(
59-
session=session,
60-
workspace=workspace, # type: ignore
59+
session=session, workspace=workspace # type: ignore
6160
)
6261

6362
# Commit the changes for the current batch

api/ee/databases/postgres/migrations/core/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ async def get_current_migration_head_from_db(engine: AsyncEngine):
7373

7474
async with engine.connect() as connection:
7575
try:
76-
result = await connection.execute(
77-
text("SELECT version_num FROM alembic_version")
78-
) # type: ignore
76+
result = await connection.execute(text("SELECT version_num FROM alembic_version")) # type: ignore
7977
except (asyncpg.exceptions.UndefinedTableError, ProgrammingError):
8078
# Note: If the alembic_version table does not exist, it will result in raising an UndefinedTableError exception.
8179
# We need to suppress the error and return a list with the alembic_version table name to inform the user that there is a pending migration \
@@ -85,9 +83,9 @@ async def get_current_migration_head_from_db(engine: AsyncEngine):
8583
return "alembic_version"
8684

8785
migration_heads = [row[0] for row in result.fetchall()]
88-
assert len(migration_heads) == 1, (
89-
"There can only be one migration head stored in the database."
90-
)
86+
assert (
87+
len(migration_heads) == 1
88+
), "There can only be one migration head stored in the database."
9189
return migration_heads[0]
9290

9391

api/ee/databases/postgres/migrations/tracing/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ async def get_current_migration_head_from_db(engine: AsyncEngine):
6666

6767
async with engine.connect() as connection:
6868
try:
69-
result = await connection.execute(
70-
text("SELECT version_num FROM alembic_version")
71-
) # type: ignore
69+
result = await connection.execute(text("SELECT version_num FROM alembic_version")) # type: ignore
7270
except (asyncpg.exceptions.UndefinedTableError, ProgrammingError):
7371
# Note: If the alembic_version table does not exist, it will result in raising an UndefinedTableError exception.
7472
# We need to suppress the error and return a list with the alembic_version table name to inform the user that there is a pending migration \
@@ -78,9 +76,9 @@ async def get_current_migration_head_from_db(engine: AsyncEngine):
7876
return "alembic_version"
7977

8078
migration_heads = [row[0] for row in result.fetchall()]
81-
assert len(migration_heads) == 1, (
82-
"There can only be one migration head stored in the database."
83-
)
79+
assert (
80+
len(migration_heads) == 1
81+
), "There can only be one migration head stored in the database."
8482
return migration_heads[0]
8583

8684

api/ee/src/apis/fastapi/billing/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
stripe.api_key = environ.get("STRIPE_API_KEY")
3737

38-
MAC_ADDRESS = ":".join(f"{(getnode() >> ele) & 0xFF:02x}" for ele in range(40, -1, -8))
38+
MAC_ADDRESS = ":".join(f"{(getnode() >> ele) & 0xff:02x}" for ele in range(40, -1, -8))
3939
STRIPE_WEBHOOK_SECRET = environ.get("STRIPE_WEBHOOK_SECRET")
4040
STRIPE_TARGET = environ.get("STRIPE_TARGET") or MAC_ADDRESS
4141
AGENTA_PRICING = loads(environ.get("AGENTA_PRICING") or "{}")

api/ee/src/core/subscriptions/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
stripe.api_key = environ.get("STRIPE_SECRET_KEY")
2727

28-
MAC_ADDRESS = ":".join(f"{(getnode() >> ele) & 0xFF:02x}" for ele in range(40, -1, -8))
28+
MAC_ADDRESS = ":".join(f"{(getnode() >> ele) & 0xff:02x}" for ele in range(40, -1, -8))
2929
STRIPE_TARGET = environ.get("STRIPE_TARGET") or MAC_ADDRESS
3030
AGENTA_PRICING = loads(environ.get("AGENTA_PRICING") or "{}")
3131

api/ee/src/services/db_manager_ee.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ async def remove_user_from_workspace(
645645
project = await db_manager.get_project_by_id(project_id=project_id)
646646

647647
async with engine.core_session() as session:
648-
if not user: # User is an invited user who has not yet created an account and therefore does not have a user object
648+
if (
649+
not user
650+
): # User is an invited user who has not yet created an account and therefore does not have a user object
649651
pass
650652
else:
651653
# Ensure that a user can not remove the owner of the workspace

api/ee/src/services/workspace_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ async def accept_workspace_invitation(
317317

318318
invitation = await check_valid_invitation(project_id, user.email, token)
319319
if invitation is not None:
320-
assert invitation.role is not None, (
321-
"Invitation does not have any workspace role"
322-
)
320+
assert (
321+
invitation.role is not None
322+
), "Invitation does not have any workspace role"
323323
await db_manager_ee.add_user_to_workspace_and_org(
324324
organization, workspace, user, project_id, invitation.role
325325
)

api/ee/src/utils/entitlements.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ class EntitlementsException(Exception):
3636
pass
3737

3838

39-
NOT_ENTITLED_RESPONSE: Callable[[Tracker], JSONResponse] = (
40-
lambda tracker=None: JSONResponse(
41-
status_code=403,
42-
content={
43-
"detail": (
44-
"You have reached your monthly quota limit. Please upgrade your plan to continue."
45-
if tracker == Tracker.COUNTERS
39+
NOT_ENTITLED_RESPONSE: Callable[
40+
[Tracker], JSONResponse
41+
] = lambda tracker=None: JSONResponse(
42+
status_code=403,
43+
content={
44+
"detail": (
45+
"You have reached your monthly quota limit. Please upgrade your plan to continue."
46+
if tracker == Tracker.COUNTERS
47+
else (
48+
"You have reached your quota limit. Please upgrade your plan to continue."
49+
if tracker == Tracker.GAUGES
4650
else (
47-
"You have reached your quota limit. Please upgrade your plan to continue."
48-
if tracker == Tracker.GAUGES
49-
else (
50-
"You do not have access to this feature. Please upgrade your plan to continue."
51-
if tracker == Tracker.FLAGS
52-
else "You do not have access to this feature."
53-
)
51+
"You do not have access to this feature. Please upgrade your plan to continue."
52+
if tracker == Tracker.FLAGS
53+
else "You do not have access to this feature."
5454
)
55-
),
56-
},
57-
)
55+
)
56+
),
57+
},
5858
)
5959

6060

@@ -163,7 +163,7 @@ async def check_entitlements(
163163

164164
# TODO: remove this line
165165
log.info(
166-
f"adjusting: {organization_id} | {(('0' if (meter.month != 0 and meter.month < 10) else '') + str(meter.month)) if meter.month != 0 else ' '}.{meter.year if meter.year else ' '} | {'allow' if check else 'deny '} | {meter.key}: {meter.value - meter.synced} [{meter.value}]"
166+
f"adjusting: {organization_id} | {(('0' if (meter.month != 0 and meter.month < 10) else '') + str(meter.month)) if meter.month != 0 else ' '}.{meter.year if meter.year else ' '} | {'allow' if check else 'deny '} | {meter.key}: {meter.value-meter.synced} [{meter.value}]"
167167
)
168168

169169
return check is True, meter, _

api/ee/src/utils/permissions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,17 @@ async def check_rbac_permission(
218218
bool: True if the user belongs to the workspace and has the specified permission, False otherwise.
219219
"""
220220

221-
assert project_id is not None, (
222-
"Project_ID is required to check object-level permissions"
223-
)
221+
assert (
222+
project_id is not None
223+
), "Project_ID is required to check object-level permissions"
224224

225225
# Assert that either permission or role is provided, but not both
226-
assert (permission is not None) or (role is not None), (
227-
"Either 'permission' or 'role' must be provided, but neither is provided"
228-
)
229-
assert not ((permission is not None) and (role is not None)), (
230-
"'permission' and 'role' cannot both be provided at the same time"
231-
)
226+
assert (permission is not None) or (
227+
role is not None
228+
), "Either 'permission' or 'role' must be provided, but neither is provided"
229+
assert not (
230+
(permission is not None) and (role is not None)
231+
), "'permission' and 'role' cannot both be provided at the same time"
232232

233233
if project_id is not None:
234234
project = await db_manager.get_project_by_id(project_id)
@@ -281,9 +281,9 @@ async def check_project_has_role_or_permission(
281281
if not check:
282282
return True
283283

284-
assert role is not None or permission is not None, (
285-
"Either role or permission must be provided"
286-
)
284+
assert (
285+
role is not None or permission is not None
286+
), "Either role or permission must be provided"
287287

288288
project_members = await db_manager_ee.get_project_members(
289289
project_id=str(project.id)

api/oss/databases/postgres/migrations/core/data_migrations/projects.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ def add_default_evaluators_to_project(session: Session, project_id: str):
131131
}
132132

133133
for setting_name, default_value in settings_values.items():
134-
assert default_value != "", (
135-
f"Default value for ground truth key '{setting_name}' in Evaluator is empty"
136-
)
134+
assert (
135+
default_value != ""
136+
), f"Default value for ground truth key '{setting_name}' in Evaluator is empty"
137137

138-
assert hasattr(evaluator, "name") and hasattr(evaluator, "key"), (
139-
f"'name' and 'key' does not exist in the evaluator: {evaluator}"
140-
)
138+
assert hasattr(evaluator, "name") and hasattr(
139+
evaluator, "key"
140+
), f"'name' and 'key' does not exist in the evaluator: {evaluator}"
141141

142142
evaluator_config = EvaluatorConfigDB(
143143
project_id=uuid.UUID(project_id),

0 commit comments

Comments
 (0)