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(commands)!: Migrate command plugins to new plugin API #9507

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

mnonnenmacher
Copy link
Member

@mnonnenmacher mnonnenmacher commented Nov 26, 2024

Migrate the command plugins to the new plugin API.

Relates to #9403.

@mnonnenmacher mnonnenmacher force-pushed the cli-plugins branch 2 times, most recently from 5f22e1c to f1a85ce Compare November 26, 2024 19:48
@mnonnenmacher mnonnenmacher marked this pull request as ready for review November 26, 2024 19:49
@mnonnenmacher mnonnenmacher requested review from oheger-bosch and a team as code owners November 26, 2024 19:49
@mnonnenmacher mnonnenmacher enabled auto-merge (rebase) November 26, 2024 20:15
@@ -123,7 +124,8 @@ class OrtMain : CliktCommand(ORT_NAME) {
helpFormatter = { MordantHelpFormatter(context = it, REQUIRED_OPTION_MARKER, showDefaultValues = true) }
}

subcommands(OrtCommand.ALL.values)
// Commands are not configurable so we can pass an empty PluginConfig here.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I guess we should use passive voice here, too. Like "Pass an empty PluginConfig here as commands are not configurable."

Copy link
Member

Choose a reason for hiding this comment

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

Should we make the code self-explanatory to remove the need for this comment?
I guess the comment would be repeated over and over again.

We can put a constant PluginConfig.EMPTY, or similar, which would also avoid unnecessary instance creation.

Copy link
Member

Choose a reason for hiding this comment

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

I guess the comment would be repeated over and over again.

Do you mean for other plugin types? I'm not sure about that, as commands are really special in this regard.

However, I was also wondering whether we should allow factory.create() to take no arguments for this case instead of introducing PluginConfig.EMPTY.

Copy link
Member

Choose a reason for hiding this comment

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

I meant writing here: subcommands(OrtCommandFactory.ALL.map { (_, factory) -> factory.create(PluginConfig.EMPTY) })

And drop the code comment.

Copy link
Member

@sschuberth sschuberth Nov 28, 2024

Choose a reason for hiding this comment

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

Understood. But my question was: Where do you potentiality see the comment to "repeated over and over again"? In upcoming plugin migrations?

Copy link
Member

Choose a reason for hiding this comment

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

I didn't have any specific callers in mind. I just thought that this comment would need to be repeated for each create() call which passes PluginConfig() for consistency.

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 have updated the comment to not use passive voice.

However, I was also wondering whether we should allow factory.create() to take no arguments for this case instead of introducing PluginConfig.EMPTY.

I'd rather not introduce that option before all plugins are migrated to avoid forgetting to pass the config.

I meant writing here: subcommands(OrtCommandFactory.ALL.map { (_, factory) -> factory.create(PluginConfig.EMPTY) })
And drop the code comment.

That code still does not explain why it is ok to pass an empty config so I would keep the comment anyway.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.00%. Comparing base (ef538ee) to head (2e60641).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9507   +/-   ##
=========================================
  Coverage     68.00%   68.00%           
  Complexity     1291     1291           
=========================================
  Files           249      249           
  Lines          8819     8819           
  Branches        917      917           
=========================================
  Hits           5997     5997           
  Misses         2433     2433           
  Partials        389      389           
Flag Coverage Δ
funTest-docker 64.84% <ø> (ø)
funTest-non-docker 33.29% <ø> (ø)
test 35.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -123,7 +124,8 @@ class OrtMain : CliktCommand(ORT_NAME) {
helpFormatter = { MordantHelpFormatter(context = it, REQUIRED_OPTION_MARKER, showDefaultValues = true) }
}

subcommands(OrtCommand.ALL.values)
// Commands are not configurable so we can pass an empty PluginConfig here.
Copy link
Member

Choose a reason for hiding this comment

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

Should we make the code self-explanatory to remove the need for this comment?
I guess the comment would be repeated over and over again.

We can put a constant PluginConfig.EMPTY, or similar, which would also avoid unnecessary instance creation.

@fviernau fviernau dismissed their stale review November 28, 2024 12:11

I don'T mind

Migrate the command plugins to the new plugin API.

Relates to #9403.

Signed-off-by: Martin Nonnenmacher <[email protected]>
@mnonnenmacher mnonnenmacher merged commit b12f874 into main Dec 8, 2024
23 checks passed
@mnonnenmacher mnonnenmacher deleted the cli-plugins branch December 8, 2024 17:57
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.

3 participants