-
Notifications
You must be signed in to change notification settings - Fork 596
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
Add registry for deprecated tools and annotations. #4505
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4505 +/- ##
===============================================
- Coverage 79.119% 78.891% -0.229%
- Complexity 16677 16775 +98
===============================================
Files 1051 1051
Lines 60285 60916 +631
Branches 9875 10060 +185
===============================================
+ Hits 47697 48057 +360
- Misses 8760 9014 +254
- Partials 3828 3845 +17
|
@@ -480,6 +481,10 @@ public static String getUnknownCommandMessage(final Set<Class<?>> classes, final | |||
int bestDistance = Integer.MAX_VALUE; | |||
int bestN = 0; | |||
|
|||
final String deprecationMessage = DeprecatedArtifactsRegistry.getToolDeprecationInfo(command); |
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.
Please, make this configurable outside the getUnknownCommandMessage
to override by downstream toolkits (if someone is trying to run IndelRealignment
on my toolkit, I would like to throw an error saying that it does not exists but not that it is not included in GATK4 but I would like still to have the code for searching for similar commands...
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.
Done.
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.
Thanks!
static { | ||
// Indicate version in which the tool disappeared, and recommended replacement in parentheses if applicable | ||
deprecatedTools.put("IndelRealigner", new Tuple2<>("4.0.0.0", "Please use GATK3 to run this tool")); | ||
deprecatedTools.put("RealignerTargetCreator", new Tuple2<>("4.0.0.0", "Please use GATK3 to run this tool")); |
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.
If these tools are going to be included after I implement them, saying that they are deprecated might be a strong statement: maybe a distinction between "not supported yet (but probably future support)" and "deprecated" is a better idea. Otherwise, if they are included again after version x.x.x.x, this message in previous version will be weird.
An idea might be to include a placeholder command line programs that just throw an "unsupported in the current version" for that kind of tools and annotated with @ExperimentalFeature
, for example. Anyway, I hope to have IndelRealignment
sooner than later...
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 these messages should reflect the current state, rather than speculate about the future. Hopefully we can get these tools ported; at that point we can remove them from this list.
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.
Fair enough.
* | ||
* @param toolName the tool class name (not the full package) to check | ||
*/ | ||
public static String getToolDeprecationInfo(final String toolName) { |
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.
Maybe instead of handle this here, a method to throw a new UserException
in main if it is in the deprecation registry may be more informative and will handle common message....
* be added to this list to issue a message when the user tries to run that tool. | ||
* | ||
* NOTE: Picard tools should be listed here as well, since by definition such tools will not be found in | ||
* the Picard jar. |
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.
Maybe a registry in Picard that can add on runtime values will be helpful. The same for dowsntream tools...
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.
Unfortunately we'll probably have to duplicate this in picard as well. If and when picard has such a thing we can consider integrating it here. for downstream toolkits, getUnknownCommand is overridable now, which I think will allow you the flexibility to do whatever integration you want.
|
||
// Mapping from tool name to string describing the major version number where the tool first disappeared and | ||
// optional recommended alternatives | ||
private static Map<String, Tuple2<String, String>> deprecatedTools = new HashMap<>(); |
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.
Use org.apache.commons.lang3.tuple.Pair
instead of Scala Tuple2
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.
Done.
deprecatedTools.put("RealignerTargetCreator", new Tuple2<>("4.0.0.0", "Please use GATK3 to run this tool")); | ||
} | ||
|
||
// Mapping from walker name to major version number where the walker first disappeared and optional replacement options |
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.
walker
-> annotation
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.
Removed completely.
} | ||
|
||
// Mapping from walker name to major version number where the walker first disappeared and optional replacement options | ||
private static Map<String, String> deprecatedAnnotations = new HashMap<>(); |
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.
Remove deprecatedAnnotations
for now until there's a formal request for this feature.
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.
Done.
*/ | ||
public static String getToolDeprecationInfo(final String toolName) { | ||
return deprecatedTools.containsKey(toolName) ? | ||
String.format("%s is no longer included in GATK as of version %s. (%s)", |
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.
(%s)
-> %s
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.
Done.
() -> new Main().instanceMain( new String[] {missingTool} ) | ||
); | ||
Assert.assertTrue(e.getMessage().contains(DeprecatedArtifactsRegistry.getToolDeprecationInfo(missingTool))); | ||
} |
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.
Add a second test for a tool that doesn't exist and is not in the registry.
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.
Done.
* NOTE: Picard tools should be listed here as well, since by definition such tools will not be found in | ||
* the Picard jar. | ||
*/ | ||
public class DeprecatedArtifactsRegistry { |
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.
MissingToolsRegistry
?
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.
Done.
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.
Review complete, back to @cmnbroad. Merge after addressing comments.
675b4aa
to
d789364
Compare
static { | ||
// Indicate version in which the tool disappeared, and recommended replacement in parentheses if applicable | ||
deprecatedTools.put("IndelRealigner", Pair.of("4.0.0.0", "Please use GATK3 to run this tool")); | ||
deprecatedTools.put("RealignerTargetCreator", Pair.of("4.0.0.0", "Please use GATK3 to run this tool")); |
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.
@vdauwera Anything else that you want on this list before I merge this PR ?
d789364
to
9bb5e39
Compare
We should be able to use this single implementation to satisfy both #4347 and #4351.
Questions: @vdauwera What other tools that were dropped from GATK3 should be added to the list now? GATK3 also has a deprecated annotations list, which is included here, but is empty. Are there any annotations that should be listed ? I can't really implement/test that part unless I populate it with something.
Also, trying to run a missing tool is currently handled as an error, and surfaces in the context of a usage message. Perhaps that hides it too much: