Skip to content

Commit

Permalink
debug logs for initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ggordonhall committed Oct 10, 2023
1 parent 7670890 commit fdbe7fc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
5 changes: 4 additions & 1 deletion server/bleep/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ pub async fn init(config: &Configuration) -> Result<SqlitePool> {
let data_dir = config.index_dir.to_string_lossy();

match connect(&data_dir).await {
Ok(pool) => Ok(pool),
Ok(pool) => {
debug!("successfully connected to DB");
Ok(pool)
}
Err(e) => {
warn!(
?e,
Expand Down
15 changes: 14 additions & 1 deletion server/bleep/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,25 @@ impl Application {

// Wipe existing dbs & caches if the schema has changed
if config.source.index_version_mismatch() {
debug!("schema version mismatch, resetting state");

Indexes::reset_databases(&config).await?;
debug!("resetting caches");

cache::FileCache::new(sql.clone(), semantic.clone())
.reset(&repo_pool)
.await?;

debug!("resetting semantic index");
semantic.reset_collection_blocking().await?;

debug!("state reset complete");
}

debug!("saving index version");
config.source.save_index_version()?;

debug!("initializing indexes");
let indexes = Indexes::new(&config).await?.into();

// Enforce capabilies and features depending on environment
Expand All @@ -170,7 +180,10 @@ impl Application {

// Analytics backend
let analytics = match initialize_analytics(&config, tracking_seed, analytics_options) {
Ok(analytics) => Some(analytics),
Ok(analytics) => {
debug!("analytics initialized");
Some(analytics)
}
Err(err) => {
warn!(?err, "failed to initialize analytics");
None
Expand Down
19 changes: 18 additions & 1 deletion server/bleep/src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use embedder::Embedder;
use embedder::LocalEmbedder;
use schema::{create_collection, EMBEDDING_DIM};
pub use schema::{Embedding, Payload};
use tracing_subscriber::field::debug;

#[derive(Error, Debug)]
pub enum SemanticError {
Expand Down Expand Up @@ -189,10 +190,13 @@ impl Semantic {
qdrant_url: &str,
config: Arc<Configuration>,
) -> Result<Self, SemanticError> {
debug!(qdrant_url, "initializing qdrant client");
let qdrant = QdrantClient::new(Some(QdrantClientConfig::from_url(qdrant_url))).unwrap();

match qdrant.has_collection(&config.collection_name).await {
Ok(false) => {
debug!(name = config.collection_name, "creating qdrant collection");

let CollectionOperationResponse { result, time } =
create_collection(&config.collection_name, &qdrant)
.await
Expand All @@ -207,14 +211,25 @@ impl Semantic {

assert!(result);
}
Ok(true) => {}
Ok(true) => {
debug!(
name = config.collection_name,
"qdrant collection already exists"
);
}
Err(_) => return Err(SemanticError::QdrantInitializationError),
}

create_indexes(&config.collection_name, &qdrant).await?;

debug!(name = config.collection_name, "qdrant indexes created");

if let Some(dylib_dir) = config.dylib_dir.as_ref() {
init_ort_dylib(dylib_dir);
debug!(
dylib_dir = dylib_dir.to_string_lossy().as_ref(),
"initialized ORT dylib"
);
}

#[cfg(feature = "ee")]
Expand All @@ -227,6 +242,8 @@ impl Semantic {
#[cfg(not(feature = "ee"))]
let embedder: Arc<dyn Embedder> = Arc::new(LocalEmbedder::new(model_dir)?);

debug!("initialized embedder");

Ok(Self {
qdrant: qdrant.into(),
embedder,
Expand Down

0 comments on commit fdbe7fc

Please sign in to comment.