Skip to content

Commit

Permalink
document all entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkeldenker committed Dec 4, 2024
1 parent daff4d0 commit 558f58e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
11 changes: 6 additions & 5 deletions crates/core/src/entrypoint/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use tokio::fs::File;
use tokio::io;
use tokio_stream::StreamExt;
use tracing::{debug, info};
use tracing::info;

use crate::config::{
defaults, IndexerConfig, IndexerDualEncoderConfig, IndexerGraphConfig, LocalConfig,
Expand Down Expand Up @@ -73,7 +73,7 @@ fn download_files() {
}

fn build_spellchecker() -> Result<()> {
debug!("Building spellchecker");
info!("Building spellchecker");
let spellchecker_path = Path::new(DATA_PATH).join("web_spell");

if !spellchecker_path.exists() {
Expand All @@ -97,7 +97,7 @@ fn build_spellchecker() -> Result<()> {
}

fn create_webgraph() -> Result<()> {
debug!("Creating webgraph");
info!("Creating webgraph");
let out_path = Path::new(DATA_PATH).join("webgraph");

if out_path.exists() {
Expand Down Expand Up @@ -128,7 +128,7 @@ fn create_webgraph() -> Result<()> {
}

fn calculate_centrality() {
debug!("Calculating centrality");
info!("Calculating centrality");
let webgraph_path = Path::new(DATA_PATH).join("webgraph");
let out_path = Path::new(DATA_PATH).join("centrality");

Expand All @@ -144,7 +144,7 @@ fn calculate_centrality() {
}

fn create_inverted_index() -> Result<()> {
debug!("Creating inverted index");
info!("Creating inverted index");
let out_path = Path::new(DATA_PATH).join("index");

if out_path.exists() {
Expand Down Expand Up @@ -209,6 +209,7 @@ fn create_inverted_index() -> Result<()> {
}

fn create_entity_index() -> Result<()> {
info!("Creating entity index");
let out_path = Path::new(DATA_PATH).join("entity");
if out_path.exists() {
std::fs::remove_dir_all(&out_path)?;
Expand Down
60 changes: 24 additions & 36 deletions crates/core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,14 @@ enum Commands {
},

/// Deploy the search server.
SearchServer {
config_path: String,
},
SearchServer { config_path: String },

/// Deploy the entity search server.
EntitySearchServer {
config_path: String,
},
EntitySearchServer { config_path: String },

/// Deploy the json http api. The api interacts with
/// the search servers, webgraph servers etc. to provide the necesarry functionality.
Api {
config_path: String,
},
Api { config_path: String },

/// Deploy the crawler.
Crawler {
Expand All @@ -102,23 +96,19 @@ enum Commands {
ml: bool,
},

// Commands for the live index.
/// Commands for the live index.
LiveIndex {
#[clap(subcommand)]
options: LiveIndex,
},

// Build spell correction model.
WebSpell {
config_path: String,
},
/// Build spell correction model.
WebSpell { config_path: String },

// Compute statistics for sites.
SiteStats {
config_path: String,
},
/// Compute statistics for sites.
SiteStats { config_path: String },

// Commands to compute distributed graph algorithms.
/// Commands to compute distributed graph algorithms.
Ampc {
#[clap(subcommand)]
options: AmpcOptions,
Expand Down Expand Up @@ -155,20 +145,22 @@ enum AmpcOptions {

#[derive(Subcommand)]
enum AdminOptions {
Init {
host: SocketAddr,
},
/// Create the admin config file. Run this before any other admin commands so the client knows where to connect.
Init { host: SocketAddr },

/// Print the reachable cluster members and which service they are running.
Status,
TopKeyphrases {
top: usize,
},

/// Export the top most common phrases in the index.
TopKeyphrases { top: usize },

/// Get statistics about the index.
#[clap(subcommand)]
Index(AdminIndexOptions),
IndexStats(AdminIndexStatsOptions),
}

#[derive(Subcommand)]
enum AdminIndexOptions {
enum AdminIndexStatsOptions {
/// Get the size of the index
Size,
}
Expand Down Expand Up @@ -251,9 +243,7 @@ enum WebgraphOptions {
#[derive(Subcommand)]
enum IndexingOptions {
/// Create the search index.
Search {
config_path: String,
},
Search { config_path: String },

/// Merge multiple search indexes into a single index.
MergeSearch {
Expand All @@ -267,10 +257,8 @@ enum IndexingOptions {
output_path: String,
},

// Create an index of canonical urls.
Canonical {
config_path: String,
},
/// Create an index of canonical urls.
Canonical { config_path: String },
}

fn load_toml_config<T: DeserializeOwned, P: AsRef<Path>>(path: P) -> T {
Expand Down Expand Up @@ -511,8 +499,8 @@ fn main() -> Result<()> {
.block_on(entrypoint::admin::top_keyphrases(top))?;
}

AdminOptions::Index(index_options) => match index_options {
AdminIndexOptions::Size => {
AdminOptions::IndexStats(index_options) => match index_options {
AdminIndexStatsOptions::Size => {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?
Expand Down

0 comments on commit 558f58e

Please sign in to comment.