Skip to content

Commit

Permalink
Merge pull request #564 from yjunechoe/brief-recycle
Browse files Browse the repository at this point in the history
Recycle `brief` if validation expands into multiple steps
  • Loading branch information
rich-iannone authored Jan 22, 2025
2 parents 29ad2ec + be1b1ee commit a1ab25f
Show file tree
Hide file tree
Showing 38 changed files with 528 additions and 373 deletions.
14 changes: 5 additions & 9 deletions R/col_count_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,11 @@ col_count_match <- function(

agent <- x

if (is.null(brief)) {

brief <-
create_autobrief(
agent = agent,
assertion_type = "col_count_match",
values = count
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
preconditions = preconditions, values = count,
assertion_type = "col_count_match"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns = "column", agent)
Expand Down
12 changes: 7 additions & 5 deletions R/col_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,12 @@ col_exists <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(agent, columns, preconditions, values, "col_exists")
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_exists"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -309,7 +311,7 @@ col_exists <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_character.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ col_is_character <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_character"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_character"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -302,7 +302,7 @@ col_is_character <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ col_is_date <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_date"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_date"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -294,7 +294,7 @@ col_is_date <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ col_is_factor <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_factor"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_factor"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -300,7 +300,7 @@ col_is_factor <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ col_is_integer <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_integer"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_integer"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -298,7 +298,7 @@ col_is_integer <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_logical.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ col_is_logical <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_logical"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_logical"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -295,7 +295,7 @@ col_is_logical <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ col_is_numeric <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_numeric"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_numeric"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -295,7 +295,7 @@ col_is_numeric <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
14 changes: 7 additions & 7 deletions R/col_is_posix.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ col_is_posix <- function(

agent <- x

if (is.null(brief)) {
brief <-
generate_autobriefs(
agent, columns, preconditions, values, "col_is_posix"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns,
preconditions = preconditions, values = value,
assertion_type = "col_is_posix"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -295,7 +295,7 @@ col_is_posix <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[i],
brief = brief[[i]],
active = active
)
}
Expand Down
12 changes: 4 additions & 8 deletions R/col_schema_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,10 @@ col_schema_match <- function(

agent <- x

if (is.null(brief)) {

brief <-
create_autobrief(
agent = agent,
assertion_type = "col_schema_match"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
assertion_type = "col_schema_match"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns = "column", agent)
Expand Down
19 changes: 7 additions & 12 deletions R/col_vals_between.R
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,12 @@ col_vals_between <- function(
left <- as.list(left)
right <- as.list(right)

if (is.null(brief)) {

brief <-
generate_autobriefs(
agent = agent,
columns = columns,
preconditions = preconditions,
values = c(left, right),
assertion_type = "col_vals_between"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns, segments_list = segments_list,
preconditions = preconditions, values = c(left, right),
assertion_type = "col_vals_between"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -480,7 +475,7 @@ col_vals_between <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[i],
brief = brief[[i, j]],
active = active
)
}
Expand Down
19 changes: 7 additions & 12 deletions R/col_vals_decreasing.R
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,12 @@ col_vals_decreasing <- function(

agent <- x

if (is.null(brief)) {

brief <-
generate_autobriefs(
agent = agent,
columns = columns,
preconditions = preconditions,
values = increasing_tol,
assertion_type = "col_vals_decreasing"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns, segments_list = segments_list,
preconditions = preconditions, values = increasing_tol,
assertion_type = "col_vals_decreasing"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -460,7 +455,7 @@ col_vals_decreasing <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[i],
brief = brief[[i, j]],
active = active
)
}
Expand Down
19 changes: 7 additions & 12 deletions R/col_vals_equal.R
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,12 @@ col_vals_equal <- function(

agent <- x

if (is.null(brief)) {

brief <-
generate_autobriefs(
agent = agent,
columns = columns,
preconditions = preconditions,
values = value,
assertion_type = "col_vals_equal"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
columns = columns, segments_list = segments_list,
preconditions = preconditions, values = value,
assertion_type = "col_vals_equal"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns, agent)
Expand Down Expand Up @@ -412,7 +407,7 @@ col_vals_equal <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[i],
brief = brief[[i, j]],
active = active
)
}
Expand Down
16 changes: 7 additions & 9 deletions R/col_vals_expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,12 @@ col_vals_expr <- function(

agent <- x

if (is.null(brief)) {

brief <-
create_autobrief(
agent = agent,
assertion_type = "col_vals_expr"
)
}
brief <- resolve_brief(
brief = brief, agent = agent,
segments_list = segments_list,
preconditions = preconditions,
assertion_type = "col_vals_expr"
)

# Normalize any provided `step_id` value(s)
step_id <- normalize_step_id(step_id, columns = "column", agent)
Expand Down Expand Up @@ -409,7 +407,7 @@ col_vals_expr <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief,
brief = brief[[i]],
active = active
)
}
Expand Down
Loading

0 comments on commit a1ab25f

Please sign in to comment.