spras.config package
Submodules
spras.config.config module
This config file is being used as a singleton. Because python creates a single instance of modules when they’re imported, we rely on the Snakefile instantiating the module. In particular, when the Snakefile calls init_config, it will reassign config to take the value of the actual config provided by Snakemake. After that point, any module that imports this module can access a config option by checking the object’s value. For example
import spras.config.config as config container_framework = config.config.container_settings.framework
will grab the top level registry configuration option as it appears in the config file
- class spras.config.config.Config(raw_config: dict[str, Any])
Bases:
object
- spras.config.config.attach_spras_revision(label: str) str
- spras.config.config.init_from_file(filepath)
- spras.config.config.init_global(config_dict)
- spras.config.config.spras_revision() str
Gets the revision of the current SPRAS repository. If this file is inside a .git repository, this uses the revision hash. Otherwise, this uses the package version.
spras.config.schema module
Contains the raw pydantic schema for the configuration file.
Using Pydantic as our backing config parser allows us to declaratively type our config, giving us more robust user errors with guarantees that parts of the config exist after parsing it through Pydantic.
We declare models using two classes here: - BaseModel (docs: https://docs.pydantic.dev/latest/concepts/models/) - CaseInsensitiveEnum (see ./util.py)
- class spras.config.schema.Algorithm(*, name: str, params: AlgorithmParams)
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str
- params: AlgorithmParams
- class spras.config.schema.AlgorithmParams(*, include: bool, directed: bool | None = None, **extra_data: Any)
Bases:
BaseModel- directed: bool | None
- include: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class spras.config.schema.Analysis(*, summary: ~spras.config.schema.SummaryAnalysis = SummaryAnalysis(include=False), cytoscape: ~spras.config.schema.CytoscapeAnalysis = CytoscapeAnalysis(include=False), ml: ~spras.config.schema.MlAnalysis = MlAnalysis(include=False, aggregate_per_algorithm=False, components=2, labels=True, kde=False, remove_empty_pathways=False, linkage=<MlLinkage.ward: 'ward'>, metric=<MlMetric.euclidean: 'euclidean'>), evaluation: ~spras.config.schema.EvaluationAnalysis = EvaluationAnalysis(include=False, aggregate_per_algorithm=False))
Bases:
BaseModel- cytoscape: CytoscapeAnalysis
- evaluation: EvaluationAnalysis
- ml: MlAnalysis
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- summary: SummaryAnalysis
- class spras.config.schema.CytoscapeAnalysis(*, include: bool)
Bases:
BaseModel- include: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class spras.config.schema.Dataset(*, label: ~typing.Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~spras.config.schema.label_validator.<locals>.validate)], node_files: list[str], edge_files: list[str], other_files: list[str], data_dir: str)
Bases:
BaseModel- data_dir: str
- edge_files: list[str]
- label: validate)]
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- node_files: list[str]
- other_files: list[str]
- class spras.config.schema.EvaluationAnalysis(*, include: bool, aggregate_per_algorithm: bool = False)
Bases:
BaseModel- aggregate_per_algorithm: bool
- include: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class spras.config.schema.GoldStandard(*, label: ~typing.Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~spras.config.schema.label_validator.<locals>.validate)], node_files: list[str] = [], edge_files: list[str] = [], data_dir: str, dataset_labels: list[str])
Bases:
BaseModel- data_dir: str
- dataset_labels: list[str]
- edge_files: list[str]
- label: validate)]
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- node_files: list[str]
- class spras.config.schema.Locations(*, reconstruction_dir: str)
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reconstruction_dir: str
- class spras.config.schema.MlAnalysis(*, include: bool, aggregate_per_algorithm: bool = False, components: int = 2, labels: bool = True, kde: bool = False, remove_empty_pathways: bool = False, linkage: MlLinkage = MlLinkage.ward, metric: MlMetric = MlMetric.euclidean)
Bases:
BaseModel- aggregate_per_algorithm: bool
- components: int
- include: bool
- kde: bool
- labels: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- remove_empty_pathways: bool
- class spras.config.schema.MlLinkage(value)
Bases:
CaseInsensitiveEnum- average = 'average'
- complete = 'complete'
- single = 'single'
- ward = 'ward'
- class spras.config.schema.MlMetric(value)
Bases:
CaseInsensitiveEnum- cosine = 'cosine'
- euclidean = 'euclidean'
- manhattan = 'manhattan'
- class spras.config.schema.RawConfig(*, containers: ~spras.config.container_schema.ContainerSettings, enable_profiling: bool = False, hash_length: int = 7, algorithms: list[~spras.config.schema.Algorithm], datasets: list[~spras.config.schema.Dataset], gold_standards: list[~spras.config.schema.GoldStandard] = [], analysis: ~spras.config.schema.Analysis = Analysis(summary=SummaryAnalysis(include=False), cytoscape=CytoscapeAnalysis(include=False), ml=MlAnalysis(include=False, aggregate_per_algorithm=False, components=2, labels=True, kde=False, remove_empty_pathways=False, linkage=<MlLinkage.ward: 'ward'>, metric=<MlMetric.euclidean: 'euclidean'>), evaluation=EvaluationAnalysis(include=False, aggregate_per_algorithm=False)), reconstruction_settings: ~spras.config.schema.ReconstructionSettings)
Bases:
BaseModel- containers: ContainerSettings
- enable_profiling: bool
- gold_standards: list[GoldStandard]
- hash_length: int
The length of the hash used to identify a parameter combination
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reconstruction_settings: ReconstructionSettings
- class spras.config.schema.ReconstructionSettings(*, locations: Locations)
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class spras.config.schema.SummaryAnalysis(*, include: bool)
Bases:
BaseModel- include: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- spras.config.schema.label_validator(name: str)
A validator takes in a label and ensures that it contains only letters, numbers, or underscores.
spras.config.util module
- class spras.config.util.CaseInsensitiveEnum(value)
Bases:
str,EnumWe prefer this over Enum to make sure the config parsing is more relaxed when it comes to string enum values.