-
Notifications
You must be signed in to change notification settings - Fork 3
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
[WIP] Refactoring and cleanup #49
base: master
Are you sure you want to change the base?
Conversation
fa4c988
to
f5e223a
Compare
Signed-off-by: Squareys <[email protected]>
public SettingsModelType getSettingsModelTypeFor(final ModuleItem<?> item) { | ||
|
||
// FIXME why do I need this check in case of scripts?... Why should you | ||
// not? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dietzc ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the question here was/is why I need the item.getWidgetStyle()!=null
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Context independent description of the problem:)
null
is default for getWidgetStyle()
in DefaultMutableModuleItem, see here. It is used as ModuleItems for ScriptInfo, => more proof, and is only set if a matching key exists in the parameter annotation in the script.
In the @Parameter
annotation style()
is default "", though, which is why getWidgetStyle()
is never null for CommandModule (also see this line ).
@ctrueden This is a slight inconsistency in Scijava. What is your oppinion about this? There seems to be no documentation about the getWidgetStyle()
method possibly returning null, so I guess the widget style should probably be initialized with ""
for DefaultMutableModuleItem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slight inconsistency in Scijava. What is your oppinion about this? There seems to be no documentation about the
getWidgetStyle()
method possibly returning null, so I guess the widget style should probably be initialized with""
for DefaultMutableModuleItem?
I agree this is inconsistent. However, it goes far beyond just widget style. Every attribute of the @Parameter
annotation has non-null defaults, because Java annotations do not allow null values whatsoever. However, that is inconsistent with SJC behavior in general, where null
—not ""
—is used to indicate no/default value/behavior.
I suppose my preferred solution to this conundrum is to change the PluginInfo
class to translate empty strings into nulls, as perverse as that seems...
Fixes the related FIXMEs. Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
We handle the single row output using the "enableManualPush" flag and a final flush() method which pushes a row only if manual push is not enabled. Manual push is enabled for modules with a output listener parameter. Signed-off-by: Squareys <[email protected]>
If `.createInstancesOfType(PreprocessorPlugin.class);` does not produce results, the returned list will be empty, but not null. Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
module.resolveInput(entry.getKey()); | ||
} | ||
|
||
// FIXME: do we need them all? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dietzc Does it matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depends how costly the preprocessors are. As we've no put the preprocessing logic outside the run logic it seems to be fine to take all preprocessors. However, there are preprocessors which are really useless in case of headless execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since they are only executed once per Node Execution, I doubt this will impact performance. What's your oppinion?
I think it is probably not worth the effort bisecting the preprocessors to find out which we need and which we don't. (Aka. premature opt... we can always revisit this if we see this is turning into a problem)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dietzc Are you ok with that? Then I would remove the FIXME.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the FIXME. If you object, I will add it back in.
- Comment seen.
Signed-off-by: Squareys <[email protected]>
Example: input type is "MyMultiOutputListener" (my subclass of MultiOutputListener), then the check would suceed, since I can assign this type to MultiOutputListener. When I try to assign NodeModuleOutputChangedListener, it would throw an IllegalArgumentException. If we would just simply switch to testing whether the item type is assignable from MultiOutputListener, it could also be Object, which would also resolve Object inputs with our logic here, which is not intended. A simple check for the class being exactly MultiOutputListener.class is therefore suficient. Signed-off-by: Squareys <[email protected]>
* if <code>true</code>, signals that the module handles | ||
* pushing rows. | ||
*/ | ||
public void enableManualPush(final boolean b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh, this is really state-driven now. can we avoid this method, e.g. by determining in the constructor if manual or not?! just asking, not saying it's nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, since it is only called immediately after the constructor, I can put it into the constructor, makes sense :)
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
ab41c9a
to
2bd9815
Compare
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
And fix a screw-up of mine for row push. Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
Signed-off-by: Squareys <[email protected]>
@dietzc I had this idea to split NodeModule and DefaultNodeModuleService into Scripting- and Command- to handle the slight differences (primarily "result" output module item atm). This could even be extended to more module info types than just My current attempt will not work, though, since the appropriate Service cannot be chosen depending on the module info type. Instead, I would introduce a new singleton plugin type which allows adding support for more ModuleInfo types in DefaultNodeModuleService (which will then handle those plugins). It would basically define two methods Does that sound sane? |
8ac4e28
to
2a5a238
Compare
Why does KNIME need to handle the "result" output specially?
|
@ctrueden each Either, we handle the One related issue: scijava/scijava-common#225 |
Ok great, I thought he was talking about the |
Actually, this one might be problematic, too. Is it also added to the |
Signed-off-by: Squareys <[email protected]>
After discussing this with @ctrueden in person we figured that we still should special case the |
More specifically, I would recommend: boolean hasSyntheticResult = info instanceof ScriptInfo &&
((ScriptInfo) info).isReturnValueAppended(); |
56398f7
to
255e9fc
Compare
Hello everybody!
This is @dietzc's work-in-progress which I will be doing a polishing pass on.
TODOs:
FIXME
sLogging
/Exception
handling (which is part ofFIXME
s)MissingValue
HandlingRegards,
Jonathan.
This is a work-in-progress pull request and not meant to be merged before [WIP] is removed from the title!