Skip to main content

from_plans()

Build an EditValidation from two known plans, without calling a model.

Usage

Source

from_plans(
    original,
    revised,
    instruction="Manual plan comparison",
)

This is a lightweight way to compare an original plan against a revised one and review the difference with diff(), changed_steps(), and review(). It is useful for reviewing the change between two saved versions of a plan (for example, in code review) and does not require an LLM provider, an API key, or the chatlas package.

Parameters

original: Any

The original plan. Accepts anything the validation= argument accepts: a Validate object, a code string, a YAML string, or a file path.

revised: Any

The revised plan, in any of the same forms as original.

instruction: str = "Manual plan comparison"
An optional label describing the comparison (shown as the subtitle in review()).

Returns

EditValidation
An EditValidation holding the code of the two plans, ready for diff(), changed_steps(), review(), and accept(). It has no data=, so pass the table to accept().

Examples

Two versions of a plan can be compared directly, here as Validate objects:

import pointblank as pb

small_table = pb.load_dataset("small_table")

v1 = pb.Validate(data=small_table).col_vals_gt(columns="d", value=100)
v2 = pb.Validate(data=small_table).col_vals_gt(columns="d", value=50)

comparison = pb.EditValidation.from_plans(v1, v2)

comparison.changed_steps()
[{'action': 'modify',
  'method': 'col_vals_gt',
  'old': "col_vals_gt(columns='d', value=100)",
  'new': "col_vals_gt(columns='d', value=50)"}]

The only change is the value= of the col_vals_gt() step, reported as a single modification. The plans can also be YAML configurations, which are converted to Python code before they’re compared:

v1_yaml = '''
tbl: small_table
steps:
  - col_vals_gt:
      columns: d
      value: 100
'''
v2_yaml = '''
tbl: small_table
steps:
  - col_vals_gt:
      columns: d
      value: 100
  - rows_distinct
'''

comparison = pb.EditValidation.from_plans(v1_yaml, v2_yaml)

comparison.changed_steps()
[{'action': 'add', 'method': 'rows_distinct', 'new': 'rows_distinct()'}]

The second version adds a rows_distinct() step. Since the inputs can be file paths too, this works well for checking a change to a saved plan before it’s merged.