Skip to content

✨ Add optional description parameter to #run and #in_parallel#44

Open
danielvdao wants to merge 2 commits into
doximity:masterfrom
danielvdao:dvd-add-descriptions
Open

✨ Add optional description parameter to #run and #in_parallel#44
danielvdao wants to merge 2 commits into
doximity:masterfrom
danielvdao:dvd-add-descriptions

Conversation

@danielvdao

Copy link
Copy Markdown

When adding jobs to our orchestration, we've had difficulty understanding which part of the flow we're on. Our workflow is long and we thought it would be nice to be able to add more descriptions to the steps.

This adds an optional description parameter and also adds a few tests alongside that. Would love any opinions and appreciate the contribution to the community for this gem.

@danielvdao

danielvdao commented Mar 11, 2026

Copy link
Copy Markdown
Author

Hello @TheMetalCode and @lucaslazzaris! I noticed you two are owners and recently contributed. Is there any way I can have eyes on this PR? Thank you.

@austenmadden

Copy link
Copy Markdown
Member

@danielvdao Hey, sorry for the delay; I'll try to get some 👀 on this (my own or others). Thanks for your patience!

@danielvdao

Copy link
Copy Markdown
Author

@austenmadden much appreciated and looking forward to hearing back!

@danielvdao

Copy link
Copy Markdown
Author

Hi @austenmadden, any updates? Wanted to check in here.

@austenmadden austenmadden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielvdao really appreciate taking the time to invest in the gem and the idea is great!

I've had the same problems with understanding how the batch correlates to a workflow step. This is definitely a rough spot in the gem. That said, I think changing the internal data structure this dramatically for this feature is an issue.

Couple paths forward:

  • Finding a way to implement this feature that doesn't result in a breaking change to the internal data structure of Orchestration.
  • Perhaps reflecting on the jobs/step definition to create a more meaningful auto generated batch name than just the step index?

Comment thread CHANGELOG.md

## [1.1.0]
* Add a new parameter for descriptions to `#run` and `#in_parallel`
[#43](https://github.com/doximity/simplekiq/pull/44)

@austenmadden austenmadden Mar 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the link is broken here unfortunately (references #43 but PR is #44)

@parallel_workflow = []
yield
serial_workflow << @parallel_workflow if @parallel_workflow.any?
serial_workflow << {parallel: @parallel_workflow, description: description} if @parallel_workflow.any?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it this change would break existing workflows in flight? That'd be a fairly major issue for us internally. Changing the internal data structure like this IMO would require a major version update... which IMO isn't ideal for a feature of this nature.

So I suppose my challenge would be can you implement this feature without breaking the internal structure we have here?

step.map do |(job, *args)|
@serialized_workflow ||= serial_workflow.map do |item|
result = if item[:parallel]
jobs = item[:parallel].map do |entry|

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly we ignore descriptions for run calls inside a parallel group?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context "when run steps inside in_parallel have descriptions" do
  before do
    orchestration.in_parallel do
      orchestration.run OrcTest::JobA, "syn", description: "Job A description"
      orchestration.run OrcTest::JobB, "ack", description: "Job B description"
    end
  end

  it "includes the descriptions in the serialized jobs" do
    expect(subject).to eq [
      {
        "jobs" => [
          {"description" => "Job A description", "klass" => "OrcTest::JobA", "args" => ["syn"]},
          {"description" => "Job B description", "klass" => "OrcTest::JobB", "args" => ["ack"]}
        ]
      }
    ]
  end
end

Here's an example test that demonstrates what I'm getting at. Currently fails on this branch.

end

def run(*step)
def run(*step, description: nil)

@austenmadden austenmadden Mar 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sorta obscure but there could be a collision here if someones job happened to accept a description as a named argument. Somewhat bad practice to design jobs like that in Sidekiq IMO but it does happen.

A solution to that would be a more explicit argument name like step_description or simplekiq_step_description. Not perfect but dramatically reduces the chance vs just description.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I can change it 👍🏽

@danielvdao

Copy link
Copy Markdown
Author

@austenmadden thanks for taking a look, I appreciate it. I agree that this would break in-flight jobs, that's a miss on my part. Let me take a stab at reflecting on this one more. Would appreciate any suggestions you have as well in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants