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 = 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: 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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'batcher': FieldInfo(annotation=Batcher, required=True), 'commands': FieldInfo(annotation=List[Command], required=False, default_factory=list), 'config': FieldInfo(annotation=SchemaConfig, required=True), 'filters': FieldInfo(annotation=List[Filter], required=False, default_factory=list), 'input': FieldInfo(annotation=Input, required=True), 'repo': FieldInfo(annotation=Union[Repo, NoneType], required=False), 'transformer': FieldInfo(annotation=Transformer, required=True), 'validators': FieldInfo(annotation=List[Validator], required=False, default_factory=list)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- run()
Fully run a given Schema including getting and executing all Batches. Note: this function is not thread safe.
- transformer: Transformer