Skip to content

Commit 2205bea

Browse files
authored
Merge pull request #349 from lmnr-ai/dev
Change ports, add clickhouse to lite version
2 parents 95118b1 + 7e0c51b commit 2205bea

30 files changed

+156
-169
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ RABBITMQ_DEFAULT_USER=admin
88
RABBITMQ_DEFAULT_PASS=adminpasswd
99

1010
CLICKHOUSE_USER=default
11+
POSTGRES_PORT=5433

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**/.env.local
22
**/.env
33
.DS_Store
4-
**/..DS_Store
4+
**/..DS_Store
5+
.idea

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ We do this to avoid legal issues and disputes, and to stay compliant with releva
2323

2424
Don't get overwhelmed by the number of docker-compose files. Here's a quick overview:
2525

26-
- `docker-compose.yml` is the simplest one that spins up frontend, app-server, and postgres. Good for quickstarts.
26+
- `docker-compose.yml` is the simplest one that spins up frontend, app-server, clickhouse, and postgres. Good for quickstarts.
2727
- `docker-compose-full.yml` is the one you want to use for running the full stack locally. This is the best
2828
for self-hosting.
2929
- `docker-compose-local-dev-full.yml` full file for local development. To be used when you make changes
3030
to the backend. It will only run the dependency services (postgres, qdrant, clickhouse, rabbitmq).
3131
You will need to run `cargo r`, `pnpm run dev`, and `python server.py` manually.
3232
- `docker-compose-local-dev.yml` is the one you want to use for local development. It will only
33-
run postgres and app-server. Good for frontend changes.
33+
run postgres, clickhouse, and app-server. Good for frontend changes.
3434
- `docker-compose-local-build.yml` will build the services from the source and run them in production mode. This is good for self-hosting with your own changes,
3535
or for testing the changes after developing on your own and before opening a PR.
3636

3737
| Service | docker-compose.yml | docker-compose-full.yml | docker-compose-local-dev-full.yml | docker-compose-local-dev.yml | docker-compose-local-build.yml |
3838
|---------|-------------------|------------------------|------------------------------|----------------------------|------------------------------|
3939
| postgres ||||||
4040
| qdrant ||||||
41-
| clickhouse | ||| ||
41+
| clickhouse | ||| ||
4242
| rabbitmq ||||||
4343
| app-server | ℹ️ || 💻 | ℹ️ | 🔧 |
4444
| frontend | ℹ️ || 💻 | 💻 | 🔧 |

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ cd lmnr
4848
docker compose up -d
4949
```
5050

51-
This will spin up a lightweight version of the stack with Postgres, app-server, and frontend. This is good for a quickstart
52-
or for lightweight usage. You can access the UI at http://localhost:3000 in your browser.
51+
This will spin up a lightweight version of the stack with Postgres, clickhouse, app-server, and frontend. This is good for a quickstart
52+
or for lightweight usage. You can access the UI at http://localhost:5667 in your browser.
5353

5454
For production environment, we recommend using our [managed platform](https://www.lmnr.ai/projects) or `docker compose -f docker-compose-full.yml up -d`.
5555

app-server/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SEMANTIC_SEARCH_URL=http://localhost:8080
22
# postgres://user:password@host:port/dbname
3-
DATABASE_URL="postgres://postgres:postgres_passwordabc@localhost:5432/postgres"
3+
DATABASE_URL="postgres://postgres:postgres_passwordabc@localhost:5433/postgres"
44

55
PORT=8000
66
GRPC_PORT=8001

app-server/src/api/v1/traces.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ pub async fn process_traces(
2929
project_api_key: ProjectApiKey,
3030
rabbitmq_connection: web::Data<Option<Arc<Connection>>>,
3131
db: web::Data<DB>,
32+
clickhouse: web::Data<clickhouse::Client>,
3233
cache: web::Data<crate::cache::Cache>,
3334
) -> ResponseResult {
3435
let db = db.into_inner();
3536
let cache = cache.into_inner();
37+
let clickhouse = clickhouse.into_inner().as_ref().clone();
3638
let request = ExportTraceServiceRequest::decode(body).map_err(|e| {
3739
anyhow::anyhow!("Failed to decode ExportTraceServiceRequest from bytes. {e}")
3840
})?;
@@ -57,6 +59,7 @@ pub async fn process_traces(
5759
project_api_key.project_id,
5860
rabbitmq_connection,
5961
db,
62+
clickhouse,
6063
cache,
6164
)
6265
.await?;

app-server/src/ch/evaluation_scores.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ use clickhouse::Row;
44
use serde::{Deserialize, Serialize, Serializer};
55
use uuid::Uuid;
66

7-
use crate::{
8-
evaluations::utils::EvaluationDatapointResult,
9-
features::{is_feature_enabled, Feature},
10-
};
11-
127
use super::utils::chrono_to_nanoseconds;
8+
use crate::evaluations::utils::EvaluationDatapointResult;
139

1410
fn serialize_timestamp<S>(timestamp: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
1511
where
@@ -78,10 +74,6 @@ pub async fn insert_evaluation_scores(
7874
return Ok(());
7975
}
8076

81-
if !is_feature_enabled(Feature::FullBuild) {
82-
return Ok(());
83-
}
84-
8577
let ch_insert = clickhouse.insert("evaluation_scores");
8678
match ch_insert {
8779
Ok(mut ch_insert) => {
@@ -284,9 +276,6 @@ pub async fn delete_evaluation_score(
284276
result_id: Uuid,
285277
label_id: Uuid,
286278
) -> Result<()> {
287-
if !is_feature_enabled(Feature::FullBuild) {
288-
return Ok(());
289-
}
290279
// Note, this does not immediately physically delete the data.
291280
// https://clickhouse.com/docs/en/sql-reference/statements/delete
292281
clickhouse

app-server/src/ch/events.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clickhouse::Row;
33
use serde::Serialize;
44
use uuid::Uuid;
55

6-
use crate::{db::events::Event, features::is_feature_enabled, Feature};
6+
use crate::db::events::Event;
77

88
use super::utils::chrono_to_nanoseconds;
99

@@ -30,9 +30,6 @@ impl CHEvent {
3030
}
3131

3232
pub async fn insert_events(clickhouse: clickhouse::Client, events: Vec<CHEvent>) -> Result<()> {
33-
if !is_feature_enabled(Feature::FullBuild) {
34-
return Ok(());
35-
}
3633
if events.is_empty() {
3734
return Ok(());
3835
}

app-server/src/ch/labels.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ use clickhouse::Row;
44
use serde::{Deserialize, Serialize};
55
use uuid::Uuid;
66

7-
use crate::{
8-
db::labels::LabelSource,
9-
features::{is_feature_enabled, Feature},
10-
};
7+
use crate::db::labels::LabelSource;
118

129
use super::utils::chrono_to_nanoseconds;
1310

@@ -76,10 +73,6 @@ pub async fn insert_label(
7673
value: f64,
7774
span_id: Uuid,
7875
) -> Result<()> {
79-
if !is_feature_enabled(Feature::FullBuild) {
80-
return Ok(());
81-
}
82-
8376
let label = CHLabel::new(
8477
project_id,
8578
class_id,
@@ -120,9 +113,6 @@ pub async fn delete_label(
120113
span_id: Uuid,
121114
id: Uuid,
122115
) -> Result<()> {
123-
if !is_feature_enabled(Feature::FullBuild) {
124-
return Ok(());
125-
}
126116
// Note, this does not immediately physically delete the data.
127117
// https://clickhouse.com/docs/en/sql-reference/statements/delete
128118
client

app-server/src/ch/spans.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use uuid::Uuid;
66

77
use crate::{
88
db::spans::{Span, SpanType},
9-
features::{is_feature_enabled, Feature},
109
traces::spans::SpanUsage,
1110
};
1211

@@ -97,9 +96,6 @@ impl CHSpan {
9796
}
9897

9998
pub async fn insert_span(clickhouse: clickhouse::Client, span: &CHSpan) -> Result<()> {
100-
if !is_feature_enabled(Feature::FullBuild) {
101-
return Ok(());
102-
}
10399
let ch_insert = clickhouse.insert("spans");
104100
match ch_insert {
105101
Ok(mut ch_insert) => {

0 commit comments

Comments
 (0)