civet.abstract_data
Abstraction of command-line programs which produce data files.
1""" 2Abstraction of command-line programs which produce data files. 3""" 4import abc 5from os import PathLike 6from typing import Sequence, Union 7 8 9class AbstractDataCommand(abc.ABC): 10 """ 11 An `AbstractDataCommand` represents a command-line program which can produce 12 output data to a given path. 13 14 Subclasses of `AbstractDataCommand` must be 15 [hashable](https://docs.python.org/3/library/typing.html#typing.Hashable) 16 and immutable, because `AbstractDataCommand` objects are used as dictionary 17 keys by `civet.memoization.Memoizer`. It's recommended to use 18 [frozen dataclasses](https://docs.python.org/3/library/dataclasses.html#frozen-instances). 19 """ 20 21 @abc.abstractmethod 22 def command(self, output: str | PathLike) -> Sequence[Union[str, PathLike, 'AbstractDataCommand']]: 23 ... 24 25 @property 26 def preferred_suffix(self) -> str: 27 """ 28 Preferred output path suffix for this command. 29 """ 30 return ''
class
AbstractDataCommand(abc.ABC):
10class AbstractDataCommand(abc.ABC): 11 """ 12 An `AbstractDataCommand` represents a command-line program which can produce 13 output data to a given path. 14 15 Subclasses of `AbstractDataCommand` must be 16 [hashable](https://docs.python.org/3/library/typing.html#typing.Hashable) 17 and immutable, because `AbstractDataCommand` objects are used as dictionary 18 keys by `civet.memoization.Memoizer`. It's recommended to use 19 [frozen dataclasses](https://docs.python.org/3/library/dataclasses.html#frozen-instances). 20 """ 21 22 @abc.abstractmethod 23 def command(self, output: str | PathLike) -> Sequence[Union[str, PathLike, 'AbstractDataCommand']]: 24 ... 25 26 @property 27 def preferred_suffix(self) -> str: 28 """ 29 Preferred output path suffix for this command. 30 """ 31 return ''
An AbstractDataCommand
represents a command-line program which can produce
output data to a given path.
Subclasses of AbstractDataCommand
must be
hashable
and immutable, because AbstractDataCommand
objects are used as dictionary
keys by civet.memoization.Memoizer
. It's recommended to use
frozen dataclasses.
@abc.abstractmethod
def
command( self, output: str | os.PathLike) -> Sequence[Union[str, os.PathLike, civet.abstract_data.AbstractDataCommand]]: