use crate::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const GROOVE_PACK: Pack = Pack {
name: "groove",
version: "1.0.0",
license: "CC-BY-4.0",
files: &[PackFile {
name: "groove-v1.0.0-midionly.zip",
size: 3_260_318,
shake256: "d52d9a1b1aa16a2dee606304c0dc3e81e805261de9c26698c556a6b28f811399",
urls: &[
"https://storage.googleapis.com/magentadata/datasets/groove/groove-v1.0.0-midionly.zip",
],
}],
};
pub const DEFAULT_SEQ_LEN: usize = 25;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum GrooveSplit {
#[default]
Train,
Validation,
Test,
}
#[derive(Clone, Debug)]
pub struct GrooveConfig {
pub split: GrooveSplit,
pub seq_len: usize,
pub cache_dir: Option<PathBuf>,
}
impl Default for GrooveConfig {
fn default() -> Self {
Self {
split: GrooveSplit::Train,
seq_len: DEFAULT_SEQ_LEN,
cache_dir: None,
}
}
}
impl GrooveConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::Groove {
#[inline]
pub fn load(config: &GrooveConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &GrooveConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &GrooveConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}