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.

input

The Input which gets Items.

Type

Input

batcher

The Batcher which batches filtered Items in to logical groups.

Type

Batcher

transformer

The Transformer which actually modifies files.

Type

Transformer

config

Any configuration needed by the schema so that it can run.

Type

SchemaConfig

filters

A list of Filters to apply to Items. Defaults to [].

Type

List[Filter], optional

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

batcher: Batcher
commands: List[Command]
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
  • batch (Batch) – The Batch to execute.

  • change (Optional[Change]) – An associated Change that is being updated.

Raises

ValidationError – If one of the Schema’s Validators fails raises an exception.

filters: List[Filter]
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

AutoTransformSchema

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

AutoTransformSchema

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]

input: Input
repo: Optional[Repo]
run()

Fully run a given Schema including getting and executing all Batches. Note: this function is not thread safe.

transformer: Transformer
validators: List[Validator]