bug(python-sdk): auto-versioning
grutt opened this issue · 1 comments
grutt commented
Problem: existing code in the admin client has incorrect logic for determining the strategy for putting and versioning a workflow.
If auto_version isn't set, should_put
should be true if the workflow.version
does not equal existing_workflow.versions[0].version
, or if there is no existing_workflow. So perhaps something like:
def determine_workflow_update(auto_version, workflow, existing_workflow):
if not auto_version and existing_workflow and existing_workflow.versions:
return workflow.version != existing_workflow.versions[0].version, workflow.version
if workflow.version == "":
return True, "v0.1.0"
if existing_workflow and existing_workflow.versions:
new_version = bump_minor_version(
existing_workflow.versions[0].version)
should_put = new_version != workflow.version
return [should_put, new_version]
return [True, workflow.version]
This seems to match up much better with the Go SDK:
shouldPut := opts.autoVersion
if err != nil {
// if not found, create
if statusErr, ok := status.FromError(err); ok && statusErr.Code() == codes.NotFound {
shouldPut = true
} else {
return fmt.Errorf("could not get workflow: %w", err)
}
if workflow.Version == "" && opts.autoVersion {
req.Opts.Version = "0.1.0"
}
} else {
// if there are no versions, exit
if len(apiWorkflow.Versions) == 0 {
return fmt.Errorf("found workflow, but it has no versions")
}
// get the workflow version to determine whether to update
if apiWorkflow.Versions[0].Version != workflow.Version {
shouldPut = true
}
if workflow.Version == "" && opts.autoVersion {
req.Opts.Version, err = bumpMinorVersion(apiWorkflow.Versions[0].Version)
if err != nil {
return fmt.Errorf("could not bump version: %w", err)
}
}
}
Originally posted by @abelanger5 in #122 (comment)
abelanger5 commented
Fixed by #129