Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(server): standardize on variableassignment for mutations #1164

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Edge: FC<Modal> = ({ data }) => {
<span className="rounded bg-green-300 p-1 text-xs">{mutation.operation}</span>
<NodeOutput nodeOutput={mutation.nodeOutput} />
<LiteralValue literalValue={mutation.literalValue} />
<SourceVariable sourceVariable={mutation.sourceVariable} />
<RhsAssignment rhsAssignment={mutation.rhsAssignment} />
</div>
))}
</DialogContent>
Expand All @@ -41,12 +41,12 @@ const NodeOutput: FC<Pick<VariableMutation, 'nodeOutput'>> = ({ nodeOutput }) =>
)
}

const SourceVariable: FC<Pick<VariableMutation, 'sourceVariable'>> = ({ sourceVariable }) => {
if (!sourceVariable) return <></>
const RhsAssignment: FC<Pick<VariableMutation, 'rhsAssignment'>> = ({ rhsAssignment }) => {
if (!rhsAssignment) return <></>
return (
<>
<span className="rounded bg-gray-200 p-1 text-xs">Source Variable</span>
<span className="rounded bg-gray-100 p-1 font-mono text-xs text-orange-500">{getVariable(sourceVariable)}</span>
<span className="rounded bg-gray-200 p-1 text-xs">RHS Assignment</span>
<span className="rounded bg-gray-100 p-1 font-mono text-xs text-orange-500">{getVariable(rhsAssignment)}</span>
</>
)
}
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/08-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ they are writing their own WfSpec SDK.
| `lhs_name` | | string | The name of the variable to mutate |
| `lhs_json_path` | optional| string | For JSON_ARR and JSON_OBJ variables, this allows you to optionally mutate a specific sub-field of the variable. |
| `operation` | | [VariableMutationType](#variablemutationtype) | Defines the operation that we are executing. |
| `source_variable` | oneof `rhs_value`| [VariableAssignment](#variableassignment) | Set the source_variable as the RHS to use another variable from the workflow to as the RHS/ |
| `literal_value` | oneof `rhs_value`| [VariableValue](#variablevalue) | Use a literal value as the RHS. |
| `node_output` | oneof `rhs_value`| [VariableMutation.NodeOutputSource](#variablemutationnodeoutputsource) | Use the output of the current node as the RHS. |
| `rhs_assignment` | oneof `rhs_value`| [VariableAssignment](#variableassignment) | Assigns the value to be used as the RHS of the mutation. |
| `literal_value` | oneof `rhs_value`| [VariableValue](#variablevalue) | Use a literal value as the RHS. DEPRECATED: use rhs_assignment.literal_value instead. |
| `node_output` | oneof `rhs_value`| [VariableMutation.NodeOutputSource](#variablemutationnodeoutputsource) | Use the output of the current node as the RHS. DEPRECATED: use rhs_assignment.node_output instead. |
<!-- end Fields -->
<!-- end HasFields -->

Expand Down
4 changes: 2 additions & 2 deletions docs/static/img/protobuf-docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2307,10 +2307,10 @@ <h3 id="littlehorse.VariableMutation">VariableMutation</h3>
</tr>

<tr>
<td>source_variable</td>
<td>rhs_assignment</td>
<td><a href="#littlehorse.VariableAssignment">VariableAssignment</a></td>
<td></td>
<td><p>Set the source_variable as the RHS to use another variable from the workflow to
<td><p>Set the rhs_assignment as the RHS to use another variable from the workflow to
as the RHS/ </p></td>
</tr>

Expand Down
16 changes: 10 additions & 6 deletions schemas/littlehorse/common_wfspec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,20 @@ message VariableMutation {
// Defines the operation that we are executing.
VariableMutationType operation = 3;

// The RHS of the mutation; i.e. what is operated _with_.
// The RHS of the mutation; i.e. what is operated _with_. Note the values other
// than `rhs_assignment` are deprecated and will be removed in 2.0.
//
// As of 0.12.0, the SDK's only use rhs_assignment.
oneof rhs_value {
// Set the source_variable as the RHS to use another variable from the workflow to
// as the RHS/
VariableAssignment source_variable = 4;
// Assigns the value to be used as the RHS of the mutation.
VariableAssignment rhs_assignment = 4;

// Use a literal value as the RHS.
// Use a literal value as the RHS. DEPRECATED: use rhs_assignment.literal_value
// instead.
VariableValue literal_value = 5;

// Use the output of the current node as the RHS.
// Use the output of the current node as the RHS. DEPRECATED: use
// rhs_assignment.node_output instead.
NodeOutputSource node_output = 6;
}
}
Expand Down
299 changes: 151 additions & 148 deletions sdk-go/lhproto/common_wfspec.pb.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions sdk-go/littlehorse/wf_lib_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,17 +709,17 @@ func (t *WorkflowThread) mutate(
},
}
case WfRunVariable:
mutation.RhsValue = &lhproto.VariableMutation_SourceVariable{
SourceVariable: &lhproto.VariableAssignment{
mutation.RhsValue = &lhproto.VariableMutation_RhsAssignment{
RhsAssignment: &lhproto.VariableAssignment{
JsonPath: r.jsonPath,
Source: &lhproto.VariableAssignment_VariableName{
VariableName: r.Name,
},
},
}
case *WfRunVariable:
mutation.RhsValue = &lhproto.VariableMutation_SourceVariable{
SourceVariable: &lhproto.VariableAssignment{
mutation.RhsValue = &lhproto.VariableMutation_RhsAssignment{
RhsAssignment: &lhproto.VariableAssignment{
JsonPath: r.jsonPath,
Source: &lhproto.VariableAssignment_VariableName{
VariableName: r.Name,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading