diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 170d9f84e..18d6789aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,50 +41,50 @@ jobs: - os: macos-latest target: aarch64-apple-darwin binary: aarch64-apple-darwin - build_args: --features prod-db + build_args: --features prod - os: dimerun-k3-ubuntu2204 target: x86_64-unknown-linux-gnu binary: x86_64-manylinux2014 container: quay.io/pypa/manylinux2014_x86_64 - build_args: --features static-ssl,prod-db + build_args: --features static-ssl,prod - os: dimerun-k3-ubuntu2204 target: x86_64-unknown-linux-gnu binary: x86_64-manylinux2014-cuda117 container: sameli/manylinux2014_x86_64_cuda_11.7 - build_args: --features static-ssl --features cuda,prod-db + build_args: --features static-ssl,cuda,prod - os: dimerun-k3-ubuntu2204 target: x86_64-unknown-linux-gnu binary: x86_64-manylinux2014-cuda122 container: sameli/manylinux2014_x86_64_cuda_12.2 - build_args: --features static-ssl --features cuda,prod-db + build_args: --features static-ssl,cuda,prod - os: dimerun-k3-ubuntu2204 target: x86_64-unknown-linux-gnu binary: x86_64-manylinux2014-vulkan container: quay.io/pypa/manylinux2014_x86_64 - build_args: --features static-ssl,vulkan,prod-db + build_args: --features static-ssl,vulkan,prod vulkan_sdk: '1.3.239.0' - os: windows-latest target: x86_64-pc-windows-msvc binary: x86_64-windows-msvc - build_args: --features prod-db + build_args: --features prod ext: .exe - os: windows-latest target: x86_64-pc-windows-msvc binary: x86_64-windows-msvc-vulkan ext: .exe - build_args: --features vulkan,prod-db + build_args: --features vulkan,prod vulkan_sdk: '1.3.280.0' - os: windows-latest target: x86_64-pc-windows-msvc binary: x86_64-windows-msvc-cuda117 ext: .exe - build_args: --features cuda,prod-db + build_args: --features cuda,prod windows_cuda: '11.7.1' - os: windows-latest target: x86_64-pc-windows-msvc binary: x86_64-windows-msvc-cuda122 ext: .exe - build_args: --features cuda,prod-db + build_args: --features cuda,prod windows_cuda: '12.2.0' env: diff --git a/Cargo.lock b/Cargo.lock index dbc02e25d..059262fe8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4511,7 +4511,6 @@ dependencies = [ "lazy_static", "sql_query_builder", "sqlx", - "tabby-common", "tabby-db-macros", "tokio", "uuid 1.6.1", diff --git a/crates/tabby/Cargo.toml b/crates/tabby/Cargo.toml index c14c17b57..6a0cd7d53 100644 --- a/crates/tabby/Cargo.toml +++ b/crates/tabby/Cargo.toml @@ -14,7 +14,7 @@ experimental-http = ["dep:http-api-bindings"] # architecture, enable this feature to compile OpenSSL as part of the build. # See https://docs.rs/openssl/#vendored for more. static-ssl = ['openssl/vendored'] -prod-db = ['tabby-webserver/prod-db'] +prod = ['tabby-webserver/prod-db'] [dependencies] tabby-common = { path = "../tabby-common" } diff --git a/crates/tabby/src/main.rs b/crates/tabby/src/main.rs index e4a87be0a..fc92e9399 100644 --- a/crates/tabby/src/main.rs +++ b/crates/tabby/src/main.rs @@ -231,7 +231,12 @@ fn init_logging(otlp_endpoint: Option) { }; } - let mut dirs = "tabby=info,axum_tracing_opentelemetry=info,otel=debug".to_owned(); + let mut dirs = if cfg!(feature = "prod") { + "tabby=info,axum_tracing_opentelemetry=info,otel=debug".into() + } else { + "tabby=debug,axum_tracing_opentelemetry=info,otel=debug".into() + }; + if let Ok(env) = std::env::var(EnvFilter::DEFAULT_ENV) { dirs = format!("{dirs},{env}") }; diff --git a/crates/tabby/src/services/completion.rs b/crates/tabby/src/services/completion.rs index cef35b44a..431cc6777 100644 --- a/crates/tabby/src/services/completion.rs +++ b/crates/tabby/src/services/completion.rs @@ -13,7 +13,6 @@ use tabby_common::{ }; use tabby_inference::{TextGeneration, TextGenerationOptions, TextGenerationOptionsBuilder}; use thiserror::Error; -use tracing::debug; use utoipa::ToSchema; use super::model; @@ -284,7 +283,6 @@ impl CompletionService { let (prompt, segments, snippets) = if let Some(prompt) = request.raw_prompt() { (prompt, None, vec![]) } else if let Some(segments) = request.segments.clone() { - debug!("PREFIX: {}, SUFFIX: {:?}", segments.prefix, segments.suffix); let snippets = self .build_snippets( &language, @@ -299,7 +297,6 @@ impl CompletionService { } else { return Err(CompletionError::EmptyPrompt); }; - debug!("PROMPT: {}", prompt); let text = self.engine.generate(&prompt, options).await; let segments = segments.map(|s| s.into()); diff --git a/docker/Dockerfile.cuda b/docker/Dockerfile.cuda index fb182d374..ed789d446 100644 --- a/docker/Dockerfile.cuda +++ b/docker/Dockerfile.cuda @@ -38,12 +38,12 @@ COPY . . RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/root/workspace/target \ - cargo build --features cuda,prod-db --release --package tabby && \ + cargo build --features cuda,prod --release --package tabby && \ cp target/release/tabby /opt/tabby/bin/ RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/root/workspace/target \ - cargo build --features prod-db --release --package tabby && \ + cargo build --features prod --release --package tabby && \ cp target/release/tabby /opt/tabby/bin/tabby-cpu FROM ${BASE_CUDA_RUN_CONTAINER} as runtime diff --git a/docker/Dockerfile.rocm b/docker/Dockerfile.rocm index f672e399f..61e064023 100644 --- a/docker/Dockerfile.rocm +++ b/docker/Dockerfile.rocm @@ -38,12 +38,12 @@ COPY . . RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/root/workspace/target \ - cargo build --features rocm,prod-db --release --package tabby && \ + cargo build --features rocm,prod --release --package tabby && \ cp target/release/tabby /opt/tabby/bin/ RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/root/workspace/target \ - cargo build --features prod-db --release --package tabby && \ + cargo build --features prod --release --package tabby && \ cp target/release/tabby /opt/tabby/bin/tabby-cpu FROM ${BASE_ROCM_RUN_CONTAINER} AS runtime diff --git a/ee/tabby-db/Cargo.toml b/ee/tabby-db/Cargo.toml index 9f8f28806..007a30e9b 100644 --- a/ee/tabby-db/Cargo.toml +++ b/ee/tabby-db/Cargo.toml @@ -7,7 +7,6 @@ homepage.workspace = true [features] testutils = [] -prod-db = [] [dependencies] tabby-db-macros = { path = "../tabby-db-macros" } @@ -17,7 +16,6 @@ hash-ids.workspace = true lazy_static.workspace = true sql_query_builder = { version = "2.1.0", features = ["sqlite"] } sqlx = { version = "0.7.3", features = ["sqlite", "chrono", "runtime-tokio", "macros"] } -tabby-common = { path = "../../crates/tabby-common" } tokio = { workspace = true, features = ["fs"] } uuid.workspace = true diff --git a/ee/tabby-db/src/lib.rs b/ee/tabby-db/src/lib.rs index 5c4c4422b..00aa64015 100644 --- a/ee/tabby-db/src/lib.rs +++ b/ee/tabby-db/src/lib.rs @@ -1,4 +1,4 @@ -use std::{ops::Deref, sync::Arc}; +use std::{ops::Deref, path::Path, sync::Arc}; use anyhow::anyhow; use cache::Cache; @@ -23,7 +23,6 @@ mod invitations; mod job_runs; mod oauth_credential; mod password_reset; -mod path; mod refresh_tokens; mod repositories; mod server_setting; @@ -99,10 +98,10 @@ impl DbConn { DbConn::init_db(pool).await } - pub async fn new() -> Result { - tokio::fs::create_dir_all(path::db_file().parent().unwrap()).await?; + pub async fn new(db_file: &Path) -> Result { + tokio::fs::create_dir_all(db_file.parent().unwrap()).await?; let options = SqliteConnectOptions::new() - .filename(path::db_file()) + .filename(db_file) .create_if_missing(true); let pool = SqlitePool::connect_with(options).await?; Self::init_db(pool).await diff --git a/ee/tabby-webserver/Cargo.toml b/ee/tabby-webserver/Cargo.toml index d59047df3..da92db36d 100644 --- a/ee/tabby-webserver/Cargo.toml +++ b/ee/tabby-webserver/Cargo.toml @@ -6,7 +6,7 @@ authors.workspace = true homepage.workspace = true [features] -prod-db = ['tabby-db/prod-db'] +prod-db = [] [dependencies] anyhow.workspace = true diff --git a/ee/tabby-webserver/src/handler.rs b/ee/tabby-webserver/src/handler.rs index 8ac832f6e..4a0c412c7 100644 --- a/ee/tabby-webserver/src/handler.rs +++ b/ee/tabby-webserver/src/handler.rs @@ -20,6 +20,7 @@ use tracing::{error, warn}; use crate::{ cron, hub, integrations, oauth, + path::db_file, repositories::{self, RepositoryCache}, schema::{auth::AuthenticationService, create_schema, Schema, ServiceLocator}, service::{create_service_locator, event_logger::create_event_logger}, @@ -33,7 +34,9 @@ pub struct WebserverHandle { impl WebserverHandle { pub async fn new(logger1: impl EventLogger + 'static) -> Self { - let db = DbConn::new().await.expect("Must be able to initialize db"); + let db = DbConn::new(db_file().as_path()) + .await + .expect("Must be able to initialize db"); let logger2 = create_event_logger(db.clone()); let logger = Arc::new(ComposedLogger::new(logger1, logger2)); WebserverHandle { db, logger } diff --git a/ee/tabby-webserver/src/lib.rs b/ee/tabby-webserver/src/lib.rs index f2c0ee9f5..d8d8f9db2 100644 --- a/ee/tabby-webserver/src/lib.rs +++ b/ee/tabby-webserver/src/lib.rs @@ -5,6 +5,7 @@ mod handler; mod hub; mod integrations; mod oauth; +mod path; mod repositories; mod schema; mod service; diff --git a/ee/tabby-db/src/path.rs b/ee/tabby-webserver/src/path.rs similarity index 100% rename from ee/tabby-db/src/path.rs rename to ee/tabby-webserver/src/path.rs