MCPcopy Create free account
hub / github.com/Autoparallel/learner / build

Method build

crates/learner/src/lib.rs:527–551  ·  view source on GitHub ↗

Builds a new [`Learner`] instance with the configured options. This method: 1. Resolves configuration from provided sources 2. Ensures required directories exist 3. Opens database connection 4. Initializes paper retriever # Errors Returns error if: - Configuration loading fails - Directory creation fails - Database initialization fails - Retriever configuration fails

(self)

Source from the content-addressed store, hash-verified

525 /// - Database initialization fails
526 /// - Retriever configuration fails
527 pub async fn build(self) -> Result<Learner> {
528 let config = if let Some(config) = self.config {
529 config
530 } else if let Some(path) = self.config_path {
531 let config_file = path.join("config.toml");
532 let content = std::fs::read_to_string(config_file)?;
533 toml::from_str(&content).map_err(|e| LearnerError::Config(e.to_string()))?
534 } else {
535 Config::load()?
536 };
537
538 // Ensure paths exist
539 std::fs::create_dir_all(&config.retrievers_path)?;
540 if let Some(parent) = config.database_path.parent() {
541 std::fs::create_dir_all(parent)?;
542 }
543 std::fs::create_dir_all(&config.storage_path)?;
544
545 let database = Database::open(&config.database_path).await?;
546 database.set_storage_path(&config.storage_path).await?;
547
548 let retriever = Retriever::new().with_config_dir(&config.retrievers_path)?;
549
550 Ok(Learner { config, database, retriever })
551 }
552}
553
554impl Learner {

Callers 7

initFunction · 0.80
startMethod · 0.80
newMethod · 0.80
from_pathMethod · 0.80
with_configMethod · 0.80
test_learner_creationFunction · 0.80
create_test_learnerFunction · 0.80

Calls 3

ConfigClass · 0.85
set_storage_pathMethod · 0.80
with_config_dirMethod · 0.80

Tested by 2

test_learner_creationFunction · 0.64
create_test_learnerFunction · 0.64