Skip to content

Commit 75aea29

Browse files
committed
Merge remote-tracking branch 'origin/main' into evan_answer_rework
2 parents 89c60db + cab7e60 commit 75aea29

File tree

65 files changed

+2244
-546
lines changed

Some content is hidden

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

65 files changed

+2244
-546
lines changed

.github/workflows/docker-build-push-model-server-container-on-tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ jobs:
118118
TRIVY_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-db:2"
119119
TRIVY_JAVA_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-java-db:1"
120120
with:
121-
image-ref: docker.io/onyxdotapp/onyx-model-server:${{ github.ref_name }}
121+
image-ref: docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}
122122
severity: "CRITICAL,HIGH"
123123
timeout: "10m"

.vscode/env_template.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# For local dev, often user Authentication is not needed
66
AUTH_TYPE=disabled
77

8+
# Skip warm up for dev
9+
SKIP_WARM_UP=True
810

911
# Always keep these on for Dev
1012
# Logs all model prompts to stdout

.vscode/launch.template.jsonc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,20 @@
355355
"PYTHONPATH": "."
356356
},
357357
},
358+
{
359+
"name": "Install Python Requirements",
360+
"type": "node",
361+
"request": "launch",
362+
"runtimeExecutable": "bash",
363+
"runtimeArgs": [
364+
"-c",
365+
"pip install -r backend/requirements/default.txt && pip install -r backend/requirements/dev.txt && pip install -r backend/requirements/ee.txt && pip install -r backend/requirements/model_server.txt"
366+
],
367+
"cwd": "${workspaceFolder}",
368+
"console": "integratedTerminal",
369+
"presentation": {
370+
"group": "3"
371+
}
372+
},
358373
]
359374
}

CONTRIBUTING.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ As an open source project in a rapidly changing space, we welcome all contributi
1212

1313
The [GitHub Issues](https://github.com/onyx-dot-app/onyx/issues) page is a great place to start for contribution ideas.
1414

15+
To ensure that your contribution is aligned with the project's direction, please reach out to Hagen (or any other maintainer) on the Onyx team
16+
via [Slack](https://join.slack.com/t/onyx-dot-app/shared_invite/zt-2twesxdr6-5iQitKZQpgq~hYIZ~dv3KA) /
17+
[Discord](https://discord.gg/TDJ59cGV2X) or [email](mailto:founders@onyx.app).
18+
1519
Issues that have been explicitly approved by the maintainers (aligned with the direction of the project)
1620
will be marked with the `approved by maintainers` label.
1721
Issues marked `good first issue` are an especially great place to start.
@@ -23,8 +27,8 @@ If you have a new/different contribution in mind, we'd love to hear about it!
2327
Your input is vital to making sure that Onyx moves in the right direction.
2428
Before starting on implementation, please raise a GitHub issue.
2529

26-
And always feel free to message us (Chris Weaver / Yuhong Sun) on
27-
[Slack](https://join.slack.com/t/danswer/shared_invite/zt-1w76msxmd-HJHLe3KNFIAIzk_0dSOKaQ) /
30+
Also, always feel free to message the founders (Chris Weaver / Yuhong Sun) on
31+
[Slack](https://join.slack.com/t/onyx-dot-app/shared_invite/zt-2twesxdr6-5iQitKZQpgq~hYIZ~dv3KA) /
2832
[Discord](https://discord.gg/TDJ59cGV2X) directly about anything at all.
2933

3034
### Contributing Code
@@ -42,7 +46,7 @@ Our goal is to make contributing as easy as possible. If you run into any issues
4246
That way we can help future contributors and users can avoid the same issue.
4347

4448
We also have support channels and generally interesting discussions on our
45-
[Slack](https://join.slack.com/t/danswer/shared_invite/zt-1w76msxmd-HJHLe3KNFIAIzk_0dSOKaQ)
49+
[Slack](https://join.slack.com/t/onyx-dot-app/shared_invite/zt-2twesxdr6-5iQitKZQpgq~hYIZ~dv3KA)
4650
and
4751
[Discord](https://discord.gg/TDJ59cGV2X).
4852

@@ -123,7 +127,47 @@ Once the above is done, navigate to `onyx/web` run:
123127
npm i
124128
```
125129

126-
#### Docker containers for external software
130+
## Formatting and Linting
131+
132+
### Backend
133+
134+
For the backend, you'll need to setup pre-commit hooks (black / reorder-python-imports).
135+
First, install pre-commit (if you don't have it already) following the instructions
136+
[here](https://pre-commit.com/#installation).
137+
138+
With the virtual environment active, install the pre-commit library with:
139+
140+
```bash
141+
pip install pre-commit
142+
```
143+
144+
Then, from the `onyx/backend` directory, run:
145+
146+
```bash
147+
pre-commit install
148+
```
149+
150+
Additionally, we use `mypy` for static type checking.
151+
Onyx is fully type-annotated, and we want to keep it that way!
152+
To run the mypy checks manually, run `python -m mypy .` from the `onyx/backend` directory.
153+
154+
### Web
155+
156+
We use `prettier` for formatting. The desired version (2.8.8) will be installed via a `npm i` from the `onyx/web` directory.
157+
To run the formatter, use `npx prettier --write .` from the `onyx/web` directory.
158+
Please double check that prettier passes before creating a pull request.
159+
160+
# Running the application for development
161+
162+
## Developing using VSCode Debugger (recommended)
163+
164+
We highly recommend using VSCode debugger for development.
165+
See [CONTRIBUTING_VSCODE.md](./CONTRIBUTING_VSCODE.md) for more details.
166+
167+
Otherwise, you can follow the instructions below to run the application for development.
168+
169+
## Manually running the application for development
170+
### Docker containers for external software
127171

128172
You will need Docker installed to run these containers.
129173

@@ -135,7 +179,7 @@ docker compose -f docker-compose.dev.yml -p onyx-stack up -d index relational_db
135179

136180
(index refers to Vespa, relational_db refers to Postgres, and cache refers to Redis)
137181

138-
#### Running Onyx locally
182+
### Running Onyx locally
139183

140184
To start the frontend, navigate to `onyx/web` and run:
141185

@@ -223,35 +267,6 @@ If you want to make changes to Onyx and run those changes in Docker, you can als
223267
docker compose -f docker-compose.dev.yml -p onyx-stack up -d --build
224268
```
225269

226-
### Formatting and Linting
227-
228-
#### Backend
229-
230-
For the backend, you'll need to setup pre-commit hooks (black / reorder-python-imports).
231-
First, install pre-commit (if you don't have it already) following the instructions
232-
[here](https://pre-commit.com/#installation).
233-
234-
With the virtual environment active, install the pre-commit library with:
235-
236-
```bash
237-
pip install pre-commit
238-
```
239-
240-
Then, from the `onyx/backend` directory, run:
241-
242-
```bash
243-
pre-commit install
244-
```
245-
246-
Additionally, we use `mypy` for static type checking.
247-
Onyx is fully type-annotated, and we want to keep it that way!
248-
To run the mypy checks manually, run `python -m mypy .` from the `onyx/backend` directory.
249-
250-
#### Web
251-
252-
We use `prettier` for formatting. The desired version (2.8.8) will be installed via a `npm i` from the `onyx/web` directory.
253-
To run the formatter, use `npx prettier --write .` from the `onyx/web` directory.
254-
Please double check that prettier passes before creating a pull request.
255270

256271
### Release Process
257272

CONTRIBUTING_VSCODE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# VSCode Debugging Setup
2+
3+
This guide explains how to set up and use VSCode's debugging capabilities with this project.
4+
5+
## Initial Setup
6+
7+
1. **Environment Setup**:
8+
- Copy `.vscode/.env.template` to `.vscode/.env`
9+
- Fill in the necessary environment variables in `.vscode/.env`
10+
2. **launch.json**:
11+
- Copy `.vscode/launch.template.jsonc` to `.vscode/launch.json`
12+
13+
## Using the Debugger
14+
15+
Before starting, make sure the Docker Daemon is running.
16+
17+
1. Open the Debug view in VSCode (Cmd+Shift+D on macOS)
18+
2. From the dropdown at the top, select "Clear and Restart External Volumes and Containers" and press the green play button
19+
3. From the dropdown at the top, select "Run All Onyx Services" and press the green play button
20+
4. Now, you can navigate to onyx in your browser (default is http://localhost:3000) and start using the app
21+
5. You can set breakpoints by clicking to the left of line numbers to help debug while the app is running
22+
6. Use the debug toolbar to step through code, inspect variables, etc.
23+
24+
## Features
25+
26+
- Hot reload is enabled for the web server and API servers
27+
- Python debugging is configured with debugpy
28+
- Environment variables are loaded from `.vscode/.env`
29+
- Console output is organized in the integrated terminal with labeled tabs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""add composite index for index attempt time updated
2+
3+
Revision ID: 369644546676
4+
Revises: 2955778aa44c
5+
Create Date: 2025-01-08 15:38:17.224380
6+
7+
"""
8+
from alembic import op
9+
from sqlalchemy import text
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "369644546676"
13+
down_revision = "2955778aa44c"
14+
branch_labels: None = None
15+
depends_on: None = None
16+
17+
18+
def upgrade() -> None:
19+
op.create_index(
20+
"ix_index_attempt_ccpair_search_settings_time_updated",
21+
"index_attempt",
22+
[
23+
"connector_credential_pair_id",
24+
"search_settings_id",
25+
text("time_updated DESC"),
26+
],
27+
unique=False,
28+
)
29+
30+
31+
def downgrade() -> None:
32+
op.drop_index(
33+
"ix_index_attempt_ccpair_search_settings_time_updated",
34+
table_name="index_attempt",
35+
)

backend/ee/onyx/db/analytics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ def fetch_assistant_unique_users_total(
345345
def user_can_view_assistant_stats(
346346
db_session: Session, user: User | None, assistant_id: int
347347
) -> bool:
348-
# If user is None, assume the user is an admin or auth is disabled
348+
# If user is None and auth is disabled, assume the user is an admin
349+
349350
if user is None or user.role == UserRole.ADMIN:
350351
return True
351352

backend/ee/onyx/db/token_limit.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sqlalchemy.orm import aliased
88
from sqlalchemy.orm import Session
99

10+
from onyx.configs.app_configs import DISABLE_AUTH
1011
from onyx.configs.constants import TokenRateLimitScope
1112
from onyx.db.models import TokenRateLimit
1213
from onyx.db.models import TokenRateLimit__UserGroup
@@ -20,10 +21,11 @@
2021
def _add_user_filters(
2122
stmt: Select, user: User | None, get_editable: bool = True
2223
) -> Select:
23-
# If user is None, assume the user is an admin or auth is disabled
24-
if user is None or user.role == UserRole.ADMIN:
24+
# If user is None and auth is disabled, assume the user is an admin
25+
if (user is None and DISABLE_AUTH) or (user and user.role == UserRole.ADMIN):
2526
return stmt
2627

28+
stmt = stmt.distinct()
2729
TRLimit_UG = aliased(TokenRateLimit__UserGroup)
2830
User__UG = aliased(User__UserGroup)
2931

@@ -46,6 +48,12 @@ def _add_user_filters(
4648
that the user isn't a curator for
4749
- if we are not editing, we show all token_rate_limits in the groups the user curates
4850
"""
51+
52+
# If user is None, this is an anonymous user and we should only show public token_rate_limits
53+
if user is None:
54+
where_clause = TokenRateLimit.scope == TokenRateLimitScope.GLOBAL
55+
return stmt.where(where_clause)
56+
4957
where_clause = User__UG.user_id == user.id
5058
if user.role == UserRole.CURATOR and get_editable:
5159
where_clause &= User__UG.is_curator == True # noqa: E712

backend/ee/onyx/external_permissions/confluence/doc_sync.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
def _get_server_space_permissions(
2525
confluence_client: OnyxConfluence, space_key: str
2626
) -> ExternalAccess:
27-
space_permissions = confluence_client.get_space_permissions(space_key=space_key)
27+
space_permissions = confluence_client.get_all_space_permissions_server(
28+
space_key=space_key
29+
)
2830

2931
viewspace_permissions = []
3032
for permission_category in space_permissions:
@@ -67,6 +69,13 @@ def _get_server_space_permissions(
6769
else:
6870
logger.warning(f"Email for user {user_name} not found in Confluence")
6971

72+
if not user_emails and not group_names:
73+
logger.warning(
74+
"No user emails or group names found in Confluence space permissions"
75+
f"\nSpace key: {space_key}"
76+
f"\nSpace permissions: {space_permissions}"
77+
)
78+
7079
return ExternalAccess(
7180
external_user_emails=user_emails,
7281
external_user_group_ids=group_names,

backend/onyx/background/celery/celery_utils.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from onyx.connectors.interfaces import SlimConnector
1515
from onyx.connectors.models import Document
1616
from onyx.db.connector_credential_pair import get_connector_credential_pair
17+
from onyx.db.enums import ConnectorCredentialPairStatus
1718
from onyx.db.enums import TaskStatus
1819
from onyx.db.models import TaskQueueState
1920
from onyx.indexing.indexing_heartbeat import IndexingHeartbeatInterface
@@ -41,14 +42,21 @@ def _get_deletion_status(
4142
return None
4243

4344
redis_connector = RedisConnector(tenant_id, cc_pair.id)
44-
if not redis_connector.delete.fenced:
45-
return None
46-
47-
return TaskQueueState(
48-
task_id="",
49-
task_name=redis_connector.delete.fence_key,
50-
status=TaskStatus.STARTED,
51-
)
45+
if redis_connector.delete.fenced:
46+
return TaskQueueState(
47+
task_id="",
48+
task_name=redis_connector.delete.fence_key,
49+
status=TaskStatus.STARTED,
50+
)
51+
52+
if cc_pair.status == ConnectorCredentialPairStatus.DELETING:
53+
return TaskQueueState(
54+
task_id="",
55+
task_name=redis_connector.delete.fence_key,
56+
status=TaskStatus.PENDING,
57+
)
58+
59+
return None
5260

5361

5462
def get_deletion_attempt_snapshot(

0 commit comments

Comments
 (0)