@hcikit/workflow
Version:
A workflow manager for running experiments.
107 lines (106 loc) • 5.19 kB
TypeScript
import { Configuration, UnfilledLog, ExperimentIndex } from "./types.js";
export { default as schema } from "./schemas.json";
export * from "./utils.js";
export * from "./types.js";
/**
* Given a configuration, determines whether the experiment is complete or not.
*
* @param {Configuration} configuration
* @returns {boolean} indicates whether an experiment is complete or not.
*/
export declare function experimentComplete(configuration: Configuration): boolean;
export declare function getTotalTasks(configuration: Configuration): number;
/**
* Finds all of the props for a given task based on which ones start with a lowercase value
* and then also the ones that match the task name (which must start with a capital letter).
*
* @param {Object} props
* @param {string} task
* @returns an object containing all of the props for a given task
*/
export declare function scopePropsForTask(props: Record<string, unknown>, task: string): Configuration;
/**
* This function reads the index of the configuration and outputs the current props for it.
* If there is no index it assumes the experiment is just beginning.
*
* @param {Configuration} configuration
* @returns the props for the current index of an experiment
*/
export declare function getCurrentProps(configuration: Configuration): Configuration;
/**
* Gets the props for an experiment with a given index.
*
* @param {ExperimentIndex} index
* @param {Configuration} configuration
* @param {boolean} deleteLogs whether to include the logs or not.
* @returns the props for a given index on a configuration.
*/
export declare function getPropsFor(configuration: Configuration, index: ExperimentIndex, deleteLogs?: boolean): Configuration;
/**
* Traverses down the tree to the requested index and then returns the config at that index.
*
* @param {ExperimentIndex} index
* @param {Configuration} initialConfiguration
* @returns {Configuration} the requested level of config
*/
export declare function getConfigurationAtIndex(initialConfiguration: Configuration, index: ExperimentIndex): Configuration;
/**
* Finds the nearest leaf index to a starting index by traversing down the tree and always choosing
* the first child.
* @param {ExperimentIndex} index
* @param {Configuration} configuration
* @returns {ExperimentIndex} the nearest leaf index.
*/
export declare function getLeafIndex(configuration: Configuration, index: ExperimentIndex): ExperimentIndex;
/**
* This function is a helper function to get the current index, or if the experiment hasn't started it returns [0]
*
* @param {Configuration} configuration
* @returns {ExperimentIndex} the current experiment index, or [0] if there is none.
*/
export declare function getCurrentIndex(configuration: Configuration): ExperimentIndex;
/**
* Takes an index and tells us what task number it is. This is useful for progress bars.
* One trick to using this is we can truncate a config and just take one of the children, then
* that gives us the progress within a certain section of an experiment.
* @param {Configuration} configuration
* @param {ExperimentIndex} index
* @returns {number}
*/
export declare function indexToTaskNumber(configuration: Configuration, index: ExperimentIndex): number;
/**
* Takes a task number and returns an index. This is useful for dev tools because it can let us
* move forward in the experiment.
* @param {Configuration} configuration
* @param {number} taskNumber
* @returns {ExperimentIndex}
*/
export declare function taskNumberToIndex(configuration: Configuration, taskNumber: number): ExperimentIndex;
/**
* Returns the next leaf index after this task is complete. The function is slightly misnamed because it doesn't actually change any indices.
*
* @param {Configuration} configuration
* @returns {ExperimentIndex}
*/
export declare function advanceConfiguration(configuration: Configuration, index?: ExperimentIndex): Configuration;
/**
* This function actually places a new log object on the config at the current index, or if the index isn't a leaf it finds the leaf index.
*
* @param {Configuration} configuration
* @param {Log | any} log
* @returns
*/
export declare function logToConfiguration(configuration: Configuration, log: UnfilledLog): Configuration;
/**
* Takes the config and actually modifies something about it according to the modified config.
* modifiedConfig is an object and all of the properties in it overwrite the current properties at the current leaf index.
*
* @param {Configuration} configuration
* @param {ExperimentIndex} index
* @param {Object} modifiedConfiguration
* @param {boolean} logResult
*/
export declare function modifyConfiguration(configuration: Configuration, modifiedConfiguration: Record<string, unknown>, index?: ExperimentIndex, logResult?: boolean): Configuration;
export declare function iterateConfiguration(configuration: Configuration): Generator<ExperimentIndex>;
export declare function flattenConfigurationWithProps(configuration: Configuration): Array<Record<string, unknown>>;
export declare function mergeArraysSpecial(object: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;