AutoTransformSchema (autotransform.schema.schema)
The heart of AutoTransform, AutoTransformSchemas represent all information required to fully execute a change.
- class autotransform.schema.schema.AutoTransformSchema(*, input: ~autotransform.input.base.Input, batcher: ~autotransform.batcher.base.Batcher, transformer: ~autotransform.transformer.base.Transformer, config: ~autotransform.schema.config.SchemaConfig, filters: ~typing.List[~autotransform.filter.base.Filter] = <factory>, validators: ~typing.List[~autotransform.validator.base.Validator] = <factory>, commands: ~typing.List[~autotransform.command.base.Command] = <factory>, repo: ~autotransform.repo.base.Repo | None = None)
Bases:
ComponentModelThe heart of AutoTransform, pulls together all components required to execute a transformation.
- transformer
The Transformer which actually modifies files.
- Type:
- config
Any configuration needed by the schema so that it can run.
- Type:
- validators
A list of Validators to ensure the changes did not break anything. Defaults to [].
- Type:
List[Validator], optional
- commands
A list of Commands that run post-processing on the changes. Defaults to [].
- Type:
List[Command], optional
- repo
A Repo to control submission of changes to version control or code review systems. Defaults to None.
- Type:
Optional[Repo], optional
- config: SchemaConfig
- execute_batch(batch: Batch, change: Change | None = None) bool
Executes changes for a batch, including setting up the Repo, running the Transformer, checking all Validators, running Commands, submitting changes if present, and rewinding the Repo if changes are submitted. Note: this function is not thread safe.
- Parameters:
- Raises:
ValidationError – If one of the Schema’s Validators fails raises an exception.
- Returns:
Whether the batch triggered a submission.
- Return type:
bool
- static from_console(prev_schema: AutoTransformSchema | None = None) AutoTransformSchema
Gets a AutoTransformSchema using console inputs.
- Parameters:
prev_schema (Optional[AutoTransformSchema], optional) – A previously input AutoTransformSchema. Defaults to None.
- Returns:
The input AutoTransformSchema.
- Return type:
- static from_data(data: Dict[str, Any]) AutoTransformSchema
Takes data from a source like JSON and produces the associated Schema.
- Parameters:
data (Dict[str, Any]) – The data representing the Schema.
- Returns:
The Schema represented by the data.
- Return type:
- get_batches(items: List[Item]) List[Batch]
Runs the Input to get eligible Items, filters them, then batches them. Note: this function is not thread safe.
- get_items() List[Item]
Runs the Input to get eligible Items and filters them. Note: this function is not thread safe.
- Returns:
The valid Items for the Schema.
- Return type:
List[Item]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- run()
Fully run a given Schema including getting and executing all Batches. Note: this function is not thread safe.
- transformer: Transformer