mirror of
https://github.com/TabbyML/tabby
synced 2024-11-23 18:22:21 +00:00
refactor(core): extract prod feature in tabby crate (#1797)
* refactor(core): extract prod feature in tabby crate * update * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
d6130c2969
commit
8e46b8e615
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@ -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:
|
||||
|
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4511,7 +4511,6 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"sql_query_builder",
|
||||
"sqlx",
|
||||
"tabby-common",
|
||||
"tabby-db-macros",
|
||||
"tokio",
|
||||
"uuid 1.6.1",
|
||||
|
@ -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" }
|
||||
|
@ -231,7 +231,12 @@ fn init_logging(otlp_endpoint: Option<String>) {
|
||||
};
|
||||
}
|
||||
|
||||
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}")
|
||||
};
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<Self> {
|
||||
tokio::fs::create_dir_all(path::db_file().parent().unwrap()).await?;
|
||||
pub async fn new(db_file: &Path) -> Result<Self> {
|
||||
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
|
||||
|
@ -6,7 +6,7 @@ authors.workspace = true
|
||||
homepage.workspace = true
|
||||
|
||||
[features]
|
||||
prod-db = ['tabby-db/prod-db']
|
||||
prod-db = []
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
@ -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 }
|
||||
|
@ -5,6 +5,7 @@ mod handler;
|
||||
mod hub;
|
||||
mod integrations;
|
||||
mod oauth;
|
||||
mod path;
|
||||
mod repositories;
|
||||
mod schema;
|
||||
mod service;
|
||||
|
Loading…
Reference in New Issue
Block a user