Base Step Class#
Warning
This class is an abstract implementation using ABC. It serves as an interface for other Steps classes to build upon. You should never import BaseStep to use as Step to add to your pipeline.
- class expectmine.steps.base_step.BaseStep(**kwargs: Dict[Any, Any])[source]#
Bases:
ABCBase class for processing steps the pipeline can use.
- abstract classmethod can_run(input_files: list[str]) bool[source]#
Indicates weather the step can run on a given list of inputs. This method is used for the autosuggestion of possible next steps.
- Parameters:
input_files (list[str]) β List of input files for the step
- Example:
>>> can_run(["test.mzml", "test2.mzml", "data.txt"]) False
>>> can_run(["test.mzml", "test2.mzml"]) True
- abstract classmethod citation_and_disclaimer() str[source]#
Generates all necessary citations and disclaimers.
- Returns:
A multiline string with necessary citation and disclaimers.
- Return type:
string
- abstract install(persistent_store: BaseStore, io: BaseIo, logger: BaseLogger) None[source]#
Verifies that all necessary prerequisites to the method have been properly installed. If not the method can take action and install the files, methods or executables on its own.
- Parameters:
persistent_store (BaseStore) β Persistent store which saves all step necessary parameters. The data stored will be available to all executions of the same step.
io (BaseIo) β Gives the step access to query data from the user.
logger (BaseLogger) β Gives the step access to log information about its execution.
- Example:
>>> install(Store(...), Io(...), Logger(...))
- abstract metadata(persistent_store: BaseStore, volatile_store: BaseStore) dict[str, object][source]#
Produces metadata about the past run.
- Parameters:
persistent_store β Persistent store which saves all step necessary parameters. The data stored will be available to all executions of the same step.
volatile_store (BaseStore) β Volatile store which saves all step necessary execution parameters. The data stored will only be available to this instance of the step.
- Returns:
Dict with all metadata in it.
- Return type:
dict[str, object]
- Example:
>>> metadata(Store(...), Store(...)) { "python": 3.10 }
- abstract classmethod output_filetypes(input_files: list[str]) list[str][source]#
Returns a list of possible output file-extensions.
NOTE: This method currently under development and can return an over or under-defined set of file extensions. Also, we currently do not rely on internal state to narrow the list of possible output file formats
- Parameters:
input_files (list[str]) β List of input files for the step
- Returns:
A list of output files for the step.
- Return type:
list[str]
- Example:
>>> output_filetypes(["test.mzml", "test2.mzml"]) ["test.txt", "test2.txt"]
- abstract run(input_files: list[Path], output_path: Path, persistent_store: BaseStore, volatile_store: BaseStore, logger: BaseLogger) list[Path][source]#
Processes the input_files given the parameters set in install and setup. The step will write to output_path.
- Parameters:
input_files (list[Path]) β List of input files for the step.
output_path (Path) β Scoped folder where step will write to.
persistent_store β Persistent store which saves all step necessary parameters. The data stored will be available to all executions of the same step.
volatile_store (BaseStore) β Volatile store which saves all step necessary execution parameters. The data stored will only be available to this instance of the step.
logger (BaseLogger) β Gives the step access to log information about its execution.
- Returns:
List of all files produced.
- Return type:
list[Path]
- Example:
>>> run(["foo.txt, bar.txt"], Path(), Store(...), Store(...), Logger(...))
- abstract setup(volatile_store: BaseStore, io: BaseIo, logger: BaseLogger) None[source]#
Sets the step up to run with a specific configuration only available to this step instance. Purpose of this method is to set parameters for the step to correctly process the input data.
- Parameters:
volatile_store (BaseStore) β Volatile store which saves all step necessary execution parameters. The data stored will only be available to this instance of the step.
io (BaseIo) β Gives the step access to query data from the user.
logger (BaseLogger) β Gives the step access to log information about its execution.
- Example:
>>> setup(Store(...), Io(...), Logger(...))