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

Skip FileListPreprocessor for autofill=false parameters #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

imagejan
Copy link
Member

@imagejan imagejan commented May 13, 2021

This pull request is a work in progress.

This pull request changes the API of ModuleService and DefaultModuleService to include an optional parameter boolean acrossTypes that allows checking for solitary unresolved parameters within all inputs/outputs independent of their type, while maintaining the backwards-compatible method signatures.

This allows to replace some duplicated logic in helper methods of FilePreprocessor and FileListPreprocessor by a call to moduleService.getSingleInput(), which makes them respect an autoFill=false parameter annotation and avoid calling uiService.chooseFile/chooseFiles for those parameters.

The intended behavior is verified by two new tests that, before this PR, were failing on their last assertion.

NB: The tests added here call uiService.setHeadless(false) in order to set their custom default UI.

This commit changes the API of ModuleService and DefaultModuleService to include an optional parameter 'acrossTypes' that allows checking for solitary unresolved parameters within all inputs/outputs independent of their type, while maintaining the backwards compatible method signatures.

We can then replace some duplicated logic in helper methods of FilePreprocessor and FileListPreprocessor by a call to 'moduleService.getSingleInput()', which makes them respect an 'autoFill=false' parameter annotation and avoid calling uiService.chooseFile/chooseFiles for those parameters.

The intended behavior is verified by two new tests that, before this commit, are failing on their last assertion.
@imagejan imagejan force-pushed the fix-filelistpreprocessor-autofill-false branch from 2aa1968 to 4168b3e Compare May 16, 2021 18:13
return result;
}

private ModuleItem<?> getSingleItem(final Module module,
final Collection<Class<?>> types, final Iterable<ModuleItem<?>> items)
final Collection<Class<?>> types, final Iterable<ModuleItem<?>> items, boolean acrossTypes)
{
ModuleItem<?> result = null;

for (final ModuleItem<?> item : items) {
final String name = item.getName();
if (!item.isAutoFill()) continue; // skip unfillable inputs
if (module.isInputResolved(name)) continue; // skip resolved inputs
Copy link
Member Author

Choose a reason for hiding this comment

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

While working on this pull request, I noticed that the above line is specific to inputs only, so the method probably doesn't show the intended behavior when called with outputs.

The current unit tests seem to miss the method signatures specific to outputs (getSingleOutput).

I'll open a separate issue for this.

@ctrueden
Copy link
Member

Sorry it's taken me so long to look at this. I now have a dedicated PR review day per week, and this one is on my shortlist right now to review, but I'm trying to apply the 80/20 rule to do the easiest ones first. My hangup on this one is the addition of the acrossTypes parameter. I know it's optional, and does not break backwards compatibility, but it does complexify the API, so I'm going to have a think on whether we truly need it for this new feature. Maybe not this week, maybe not next week, but soon, and for the rest of our lives. 🏠🇪🇸

@ctrueden ctrueden self-assigned this Apr 13, 2022
@ctrueden ctrueden force-pushed the master branch 3 times, most recently from 53b6733 to 3dc99c9 Compare November 7, 2023 18:37
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