AutoTransformSchema (autotransform.schema.schema)
The heart of AutoTransform, AutoTransformSchemas represent all information required to fully execute a change.
- class autotransform.schema.schema.AutoTransformSchema(*, input: Input, batcher: Batcher, transformer: Transformer, config: SchemaConfig, filters: List[Filter] = None, validators: List[Validator] = None, commands: List[Command] = None, repo: Repo = None)
Bases:
ComponentModel
The 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: Optional[Change] = None) None
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.
- static from_console(prev_schema: Optional[AutoTransformSchema] = 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() List[Batch]
Runs the Input to get eligible Items, filters them, then batches them. Note: this function is not thread safe.
- Returns
The Batches for the change
- Return type
List[Batch]
- run()
Fully run a given Schema including getting and executing all Batches. Note: this function is not thread safe.
- transformer: Transformer