Skip to content

Commit 78e1787

Browse files
authored
Fixes to support external applications (#340)
- Add implementations of `Send` and `Sync` to trane. - Add a `get_unit_score` to allow querying the final score of a unit.
1 parent e7a732a commit 78e1787

38 files changed

+469
-442
lines changed

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "trane"
3-
version = "0.23.0"
4-
edition = "2021"
3+
version = "0.23.1"
4+
edition = "2024"
55
description = "An automated system for learning complex skills"
66
license = "AGPL-3.0"
77
readme = "README.md"
@@ -18,7 +18,6 @@ fs_extra = "1.3.0"
1818
git2 = "0.20.0"
1919
hex = "0.4.3"
2020
indoc = "2.0.5"
21-
lazy_static = "1.5.0"
2221
mantra-miner = "0.1.1"
2322
parking_lot = { version = "0.12.3", features = ["hardware-lock-elision"] }
2423
r2d2 = "0.8.10"

src/blacklist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use parking_lot::RwLock;
1212
use r2d2::Pool;
1313
use r2d2_sqlite::SqliteConnectionManager;
1414
use rusqlite::params;
15-
use rusqlite_migration::{Migrations, M};
15+
use rusqlite_migration::{M, Migrations};
1616
use ustr::{Ustr, UstrMap};
1717

1818
use crate::{db_utils, error::BlacklistError};

src/course_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ pub mod knowledge_base_builder;
1111
#[cfg_attr(coverage, coverage(off))]
1212
pub mod music;
1313

14-
use anyhow::{ensure, Context, Result};
14+
use anyhow::{Context, Result, ensure};
1515
use serde::{Deserialize, Serialize};
1616
use std::{
17-
fs::{create_dir_all, File},
17+
fs::{File, create_dir_all},
1818
io::Write,
1919
path::{Path, PathBuf},
2020
};

src/course_builder/knowledge_base_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
//! hand. This module contains utilities to make it easier to generate these files, specially for
55
//! testing purposes.
66
7-
use anyhow::{ensure, Context, Result};
7+
use anyhow::{Context, Result, ensure};
88
use serde::{Deserialize, Serialize};
99
use std::{
1010
collections::{BTreeMap, HashSet},
11-
fs::{self, create_dir_all, File},
11+
fs::{self, File, create_dir_all},
1212
io::Write,
1313
path::{Path, PathBuf},
1414
};
@@ -17,7 +17,7 @@ use ustr::Ustr;
1717
use crate::{
1818
course_builder::AssetBuilder,
1919
course_library::COURSE_MANIFEST_FILENAME,
20-
data::{course_generator::knowledge_base::*, CourseManifest},
20+
data::{CourseManifest, course_generator::knowledge_base::*},
2121
};
2222

2323
/// A builder to generate a knowledge base exercise and associated assets.
@@ -415,7 +415,7 @@ mod test {
415415

416416
use crate::{
417417
course_builder::knowledge_base_builder::*,
418-
data::{course_generator::knowledge_base::KnowledgeBaseFile, ExerciseType},
418+
data::{ExerciseType, course_generator::knowledge_base::KnowledgeBaseFile},
419419
};
420420

421421
/// Creates a test lesson builder.

src/course_builder/music/circle_fifths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use anyhow::Result;
1111

1212
use crate::{
1313
course_builder::{AssetBuilder, CourseBuilder, LessonBuilder},
14-
data::{music::notes::*, CourseManifest, LessonManifestBuilder},
14+
data::{CourseManifest, LessonManifestBuilder, music::notes::*},
1515
};
1616

1717
/// Generates a course builder that contains a lesson per key and which follows the circle of

src/course_library.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! courses that the student wishes to practice together. Courses, lessons, and exercises are
55
//! defined by their manifest files (see [data](crate::data)).
66
7-
use anyhow::{anyhow, ensure, Context, Result};
7+
use anyhow::{Context, Result, anyhow, ensure};
88
use parking_lot::RwLock;
99
use serde::de::DeserializeOwned;
1010
use std::{
@@ -15,11 +15,11 @@ use std::{
1515
sync::Arc,
1616
};
1717
use tantivy::{
18+
Index, IndexReader, IndexWriter, ReloadPolicy, TantivyDocument,
1819
collector::TopDocs,
1920
doc,
2021
query::QueryParser,
21-
schema::{Field, Schema, Value, STORED, TEXT},
22-
Index, IndexReader, IndexWriter, ReloadPolicy, TantivyDocument,
22+
schema::{Field, STORED, Schema, TEXT, Value},
2323
};
2424
use ustr::{Ustr, UstrMap, UstrSet};
2525
use walkdir::WalkDir;

src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub mod filter;
77
#[cfg_attr(coverage, coverage(off))]
88
pub mod music;
99

10-
use anyhow::{bail, Result};
10+
use anyhow::{Result, bail};
1111
use derive_builder::Builder;
1212
use serde::{Deserialize, Serialize};
1313
use std::{collections::BTreeMap, path::Path};

src/data/course_generator/knowledge_base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Contains the logic to generate a Trane course based on a knowledge base of markdown files
22
//! representing the front and back of flashcard exercises.
33
4-
use anyhow::{anyhow, Context, Error, Result};
5-
use serde::{de::DeserializeOwned, Deserialize, Serialize};
4+
use anyhow::{Context, Error, Result, anyhow};
5+
use serde::{Deserialize, Serialize, de::DeserializeOwned};
66
use std::{
77
collections::{BTreeMap, HashMap, HashSet},
8-
fs::{read_dir, File},
8+
fs::{File, read_dir},
99
io::BufReader,
1010
path::Path,
1111
};

src/data/course_generator/literacy.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
//! how many they get right. Optionally, a dictation lesson can be generated where the student is
66
//! asked to write the examples and exceptions based on the tutor's dictation.
77
8-
use anyhow::{anyhow, Context, Error, Result};
9-
use serde::{de::DeserializeOwned, Deserialize, Serialize};
8+
use anyhow::{Context, Error, Result, anyhow};
9+
use serde::{Deserialize, Serialize, de::DeserializeOwned};
1010
use std::{
1111
collections::BTreeMap,
12-
fs::{read_dir, File},
12+
fs::{File, read_dir},
1313
io::{BufReader, Read},
1414
path::Path,
1515
};
16+
use strum::Display;
1617
use ts_rs::TS;
1718
use ustr::{Ustr, UstrMap, UstrSet};
1819

@@ -152,7 +153,7 @@ impl TryFrom<&str> for LiteracyFile {
152153
}
153154

154155
/// The types of literacy lessons that can be generated.
155-
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, TS)]
156+
#[derive(Clone, Debug, Deserialize, Display, PartialEq, Serialize, TS)]
156157
#[ts(export)]
157158
pub enum LiteracyLessonType {
158159
/// A lesson that takes examples and exceptions and asks the student to read them.
@@ -544,9 +545,9 @@ mod test {
544545
use ustr::{Ustr, UstrSet};
545546

546547
use crate::data::{
547-
course_generator::literacy::{LiteracyConfig, LiteracyLesson, LiteracyLessonType},
548548
BasicAsset, CourseGenerator, CourseManifest, ExerciseAsset, ExerciseManifest, ExerciseType,
549549
GenerateManifests, GeneratedCourse, LessonManifest, UserPreferences,
550+
course_generator::literacy::{LiteracyConfig, LiteracyLesson, LiteracyLessonType},
550551
};
551552

552553
/// Verifies that lesson IDs are generated correctly.

src/data/course_generator/transcription.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
pub mod constants;
99

10-
use anyhow::{anyhow, bail, Context, Result};
10+
use anyhow::{Context, Result, anyhow, bail};
1111
use indoc::formatdoc;
1212
use serde::{Deserialize, Serialize};
1313
use std::{

0 commit comments

Comments
 (0)