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

Hack to make "Output Module Inserter" support plugin-type names with : #88

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/confdb/gui/ConfigurationTreeActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public static boolean insertESSource(JTree tree, String templateName) {
ConfigurationTreeModel model = (ConfigurationTreeModel) tree.getModel();
Configuration config = (Configuration) model.getRoot();

if (templateName.indexOf(':') >= 0) {
if (templateName.indexOf(":") >= 0) {
String[] s = templateName.split(":");
Template template = config.release().essourceTemplate(s[1]);
Instance original = null;
Expand Down Expand Up @@ -326,7 +326,7 @@ public static boolean insertESModule(JTree tree, String templateName) {
ConfigurationTreeModel model = (ConfigurationTreeModel) tree.getModel();
Configuration config = (Configuration) model.getRoot();

if (templateName.indexOf(':') > 0) {
if (templateName.indexOf(":") > 0) {
String[] s = templateName.split(":");
Template template = config.release().esmoduleTemplate(s[1]);
Instance original = null;
Expand Down Expand Up @@ -2011,8 +2011,7 @@ private static Configuration getConfigurationCopy(Configuration sourceConf) {
index = 0;
while (ESMit.hasNext()) {
ESModuleInstance esmodule = ESMit.next();
ESModuleInstance NewModule = configurationCopy.insertESModule(index, esmodule.template().name(),
esmodule.name());
ESModuleInstance NewModule = configurationCopy.insertESModule(index, esmodule.template().name(), esmodule.name());
index++;
Iterator<Parameter> itP = esmodule.parameterIterator();
while (itP.hasNext()) {
Expand Down Expand Up @@ -3068,7 +3067,19 @@ public static boolean insertReference(JTree tree, String type, String name) {
return false;
reference = config.insertOutputModuleReference(parent, index, referencedOutput);
} else if (type.equalsIgnoreCase("Module")) {
String[] s = name.split(":");
// The "unlikely string" hack.
// Here, the variable "name" can presumably take values of the form
// "pluginType", "pluginType:moduleLabel", or "copy:pluginType:moduleLabel".
// Unfortunately, this convention does not take into account the fact that
// pluginType itself can contain the substring "::" (e.g. plugin types with namespace specification,
// like Alpaka plugins with explicit backend selection).
// The hack below consists in replacing "::" in "name" with "##", before "name" is split by ":".
// After that, the replacement of "::" with this unlikely string is undone in "templateName".
// NOTE.
// This hack assumes that plugin types in CMSSW will never
// have "##" in their name, since that would be invalid in C++.
String unlikelyStr = "##";
String[] s = name.replaceAll("::", unlikelyStr).split(":");
String templateName = "";
String instanceName = "";
boolean copy = false;
Expand All @@ -3083,7 +3094,9 @@ public static boolean insertReference(JTree tree, String type, String name) {
templateName = s[1];
instanceName = s[2];
}


templateName = templateName.replaceAll(unlikelyStr, "::");

ModuleTemplate template = config.release().moduleTemplate(templateName);

if (!copy) {
Expand Down