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

Fix issues with exe/floe and various combinations of workflow and input #174

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented Apr 16, 2024

This commit cleans up the exe/floe interface for bare workflow/input pairs when passed in combination with --workflow and --input. This commit also makes the --workflow and --input params no longer legacy but supported.

The following are now all accepted ways to pass these parameters:

# Single workflow
exe/floe workflow1.asl
exe/floe workflow1.asl '{"input":1}'
exe/floe workflow1.asl --input '{"input":1}'
exe/floe --workflow workflow1.asl --input '{"input":1}'

# Multiple workflows
exe/floe workflow1.asl '{"input":1}' workflow2.asl '{"input":2}'
exe/floe workflow1.asl workflow2.asl --input '{"input":1}' # input is dup'd for each workflow

The following will raise errors:

exe/floe workflow1.asl workflow2.asl               # ambiguous as to workflow/input pair or 2 workflows, and so requires input
exe/floe workflow1.asl --workflow workflow2.asl    # invalid mixing of bare workflows and parameter
exe/floe workflow1.asl workflow2.asl '{"input":1}' # mismatched workflow/input pairs
exe/floe --input '{"input":1}'                     # missing workflow
exe/floe                                           # no parameters

This commit cleans up the exe/floe interface for bare workflow/input pairs
when passed in combination with `--workflow` and `--input`. This commit
also makes the `--workflow` and `--input` params no longer legacy but
supported.

The following are now all accepted ways to pass these parameters:

```sh
# Single workflow
exe/floe workflow1.asl
exe/floe workflow1.asl '{"input":1}'
exe/floe workflow1.asl --input '{"input":1}'
exe/floe --workflow workflow1.asl --input '{"input":1}'

# Multiple workflows
exe/floe workflow1.asl '{"input":1}' workflow2.asl '{"input":2}'
exe/floe workflow1.asl workflow2.asl --input '{"input":1}' # input is dup'd for each workflow
```

The following will raise errors:

```sh
exe/floe workflow1.asl workflow2.asl               # ambiguous as to workflow/input pair or 2 workflows, and so requires input
exe/floe workflow1.asl --workflow workflow2.asl    # invalid mixing of bare workflows and parameter
exe/floe workflow1.asl workflow2.asl '{"input":1}' # mismatched workflow/input pairs
exe/floe --input '{"input":1}'                     # missing workflow
exe/floe                                           # no parameters
```
@Fryguy Fryguy requested a review from agrare as a code owner April 16, 2024 15:59
@Fryguy Fryguy added the bug Something isn't working label Apr 16, 2024
RSpec.describe "exe/floe" do
RSpec.describe "exe/floe", :slow => true do
Copy link
Member Author

@Fryguy Fryguy Apr 16, 2024

Choose a reason for hiding this comment

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

Thought this might be useful, since these tests are kinda slow, so they can be ignored in local dev with

--tag ~slow

Comment on lines +89 to +95
workflow
===
{"foo"=>1}

workflow
===
{"foo"=>2}
Copy link
Member Author

Choose a reason for hiding this comment

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

This was surprising to me (here and of course everywhere else), as I assumed the output would be JSON formatted and not Ruby formatted. So, the question is, should it be JSON? If so, it's an easy fix for a followup PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also expected either the workflow.asl file name or perhaps the workflow comment (or both), so just the word "workflow" was also surprising.

Copy link
Member

@kbrock kbrock Apr 16, 2024

Choose a reason for hiding this comment

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

I modified this to run multiple workflows.
Goals:

  • Run multiple workflows.
  • Run in a way similar to how the provider runs.
  • Allow easy migration to the non-polling code.
  • Easily determine that all workflows were run and their output status.

It did not take into consideration a computer parsing the output.
Modifying it sounds great.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't really thinking about post processing, but that would be useful in the single workflow case. Even so, it was more of an expectation thing...for some reason I expected a json output.

@agrare agrare self-assigned this Apr 16, 2024
@kbrock
Copy link
Member

kbrock commented Apr 16, 2024

also, can we drop --input and --workflow?
I left them in when introducing ARGV, but think it is time to drop them.

Don't see any reason to support multiple ways to specify these values.

Thoughts?

@Fryguy
Copy link
Member Author

Fryguy commented Apr 16, 2024

No this PR makes them a) permanent (I use them personally and prefer them) and b) input, specifically, is useful for multiple workflows that take the same input cause you only need to specify it once

@Fryguy
Copy link
Member Author

Fryguy commented Apr 17, 2024

I could see maybe removing --workflow in a future PR, but --input has a use case.

@miq-bot
Copy link
Member

miq-bot commented Apr 17, 2024

Checked commit Fryguy@7ecc3c7 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. ⭐

Comment on lines +28 to +42
# Create workflow/input pairs from the various combinations of paramaters
args =
if opts[:workflow_given]
Optimist.die("cannot specify both --workflow and bare workflows") if ARGV.any?

[opts[:workflow], opts.fetch(:input, "{}")]
elsif opts[:input_given]
Optimist.die("workflow(s) must be specified") if ARGV.empty?

ARGV.flat_map { |w| [w, opts[:input].dup] }
else
Optimist.die("workflow/input pairs must be specified") if ARGV.empty? || (ARGV.size > 1 && ARGV.size.odd?)

ARGV
end
Copy link
Member

@agrare agrare Apr 18, 2024

Choose a reason for hiding this comment

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

👍 like how this creates a consistent set of args regardless of how exe/floe was invoked and we don't need to do input || opts[:input] || "{}" below

@agrare agrare merged commit a33074f into ManageIQ:master Apr 18, 2024
5 checks passed
@Fryguy Fryguy deleted the exe_floe_params_bug branch April 18, 2024 14:18
agrare added a commit that referenced this pull request May 2, 2024
Fixed
- Ensure the local code is loaded in exe/floe (#173)
- Fix issues with exe/floe and various combinations of workflow and input (#174)

Added
- Add support for pluggable schemes (#169)

Changed
- Collapse some namespaces (#171)
- Pass workflow context into runner#run_async! (#177)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants