Skip to main content

Spec

Struct Spec 

Source
pub struct Spec {
Show 20 fields pub name: String, pub description: String, pub seed: u64, pub batch: u64, pub threads: usize, pub confidence: f64, pub grid: Grid, pub fiber: Option<Value>, pub link: Vec<Value>, pub metrics: Value, pub stop: Stop, pub progress: bool, pub skip_below: Option<SkipAfter>, pub profile: bool, pub csv: Option<PathBuf>, pub json: Option<PathBuf>, pub base_dir: Option<PathBuf>, pub expect: Vec<Value>, pub search: Option<SearchSpec>, pub source: Value,
}
Expand description

A parsed specification (see the module documentation for the format).

Fields§

§name: String

Name of the campaign (it enters the seeds of the trials).

§description: String

One-line description.

§seed: u64

Base seed.

§batch: u64

Trials per batch.

§threads: usize

Worker threads (0: all cores).

§confidence: f64

Confidence level of the reported intervals and of the precision targets of the stopping rule, in $(0, 1)$.

§grid: Grid

The conditions.

§fiber: Option<Value>

Defaults of the fibre blocks.

§link: Vec<Value>

The blocks of the link, before substitution.

§metrics: Value

The metrics, before substitution.

§stop: Stop

The stopping rule.

§progress: bool

Print one line per condition.

§skip_below: Option<SkipAfter>

Skip the rest of a sweep below an error floor (callbacks: {skip_below: …}).

§profile: bool

Time every block of every trial (see Link::trial).

§csv: Option<PathBuf>

CSV output.

§json: Option<PathBuf>

JSON output.

§base_dir: Option<PathBuf>

Directory of the specification file (relative paths of the blocks).

§expect: Vec<Value>

The expected results (see verify), the fibre of their gn_snr_db theories merged over the fiber of the specification.

§search: Option<SearchSpec>

The search of an operating point (see search), instead of the sweep.

§source: Value

The specification as parsed, recorded in the JSON report of every run.

Implementations§

Source§

impl Spec

Build the link of a condition: substitute the variables, build the blocks, train the blocks that are trained once, parse the metrics.

§Errors

Error::Config for an invalid block or metric; the errors of a training.

Source§

impl Spec

Source

pub fn runner(&self, opts: &RunOptions) -> Runner

The runner of the specification: its seed, batch, threads, stopping rule, confidence and source, its callbacks (the progress lines, skip_below) and its loggers (the CSV and JSON reports), each overridden by opts when it gives one. run runs it on the scenario of the specification; a front end that runs the trials otherwise (the Python chains with Python blocks) runs it on its own scenario.

§Examples
use comnum_spec::{RunOptions, Spec, SpecScenario};
let spec = Spec::from_yaml("name: t\nthreads: 2\nlink: [source]\nstop: {max_trials: 3}")?;
let opts = RunOptions { threads: Some(1), ..RunOptions::default() };
let r = spec.runner(&opts).run(&SpecScenario::new(&spec), &spec.grid)?;
assert_eq!(r[0].trials, 3);
Source§

impl Spec

Source

pub fn from_json(v: Json) -> Result<Spec>

Parse a specification from a JSON tree.

§Errors

Error::Config for a missing or unknown key, an invalid grid (a key given by a case and by an axis, see Grid::check) or rule.

Source

pub fn parse(text: &str, format: Format) -> Result<Spec>

Parse a specification text.

§Errors

Error::Config for a syntax error or an invalid specification.

§Examples
use comnum_spec::{Format, Spec};
let spec = Spec::parse(r#"{"name": "t", "grid": {"x": [1, 2]}, "link": ["source"]}"#, Format::Json)?;
assert_eq!(spec.conditions().len(), 2);
Source

pub fn from_yaml(text: &str) -> Result<Spec>

Parse a YAML specification.

§Errors

See Spec::parse.

Source

pub fn from_path(path: impl AsRef<Path>) -> Result<Spec>

Read a specification file (.yaml, .yml, .json or .toml).

§Errors

Error::Io if the file cannot be read, Error::Config otherwise.

Source

pub fn conditions(&self) -> Vec<Condition>

The conditions of the grid.

Trait Implementations§

Source§

impl Clone for Spec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Spec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Spec

§

impl Freeze for Spec

§

impl RefUnwindSafe for Spec

§

impl Send for Spec

§

impl Sync for Spec

§

impl Unpin for Spec

§

impl UnsafeUnpin for Spec

§

impl UnwindSafe for Spec

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.