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

Fix test ci ignore input #892

Merged
merged 4 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
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
45 changes: 45 additions & 0 deletions nf_core/pipeline-template/lib/NfcoreSchema.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class NfcoreSchema {
// Validate parameters against the schema
InputStream inputStream = new File(jsonSchema).newInputStream()
JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream))

// Remove anything that's in params.schema_ignore_params
rawSchema = removeIgnoredParams(rawSchema, params)

Schema schema = SchemaLoader.load(rawSchema)

// Clean the parameters
Expand Down Expand Up @@ -185,6 +189,47 @@ class NfcoreSchema {
}
}

// Remove an element from a JSONArray
private static JSONArray removeElement(jsonArray, element){
def list = []
int len = jsonArray.length()
for (int i=0;i<len;i++){
list.add(jsonArray.get(i).toString())
}
list.remove(element)
JSONArray jsArray = new JSONArray(list)
return jsArray
}

private static JSONObject removeIgnoredParams(rawSchema, params){
// Remove anything that's in params.schema_ignore_params
params.schema_ignore_params.split(',').each{ ignore_param ->
if(rawSchema.keySet().contains('definitions')){
rawSchema.definitions.each { definition ->
for (key in definition.keySet()){
if (definition[key].get("properties").keySet().contains(ignore_param)){
// Remove the param to ignore
definition[key].get("properties").remove(ignore_param)
// If the param was required, change this
if (definition[key].has("required")) {
def cleaned_required = removeElement(definition[key].required, ignore_param)
definition[key].put("required", cleaned_required)
}
}
}
}
}
if(rawSchema.keySet().contains('properties') && rawSchema.get('properties').containsKey(ignore_param)) {
rawSchema.get("properties").remove(ignore_param)
}
if(rawSchema.keySet().contains('required') && rawSchema.required.contains(ignore_param)) {
def cleaned_required = removeElement(rawSchema.required, ignore_param)
rawSchema.put("required", cleaned_required)
}
}
return rawSchema
}

private static Map cleanParameters(params) {
def new_params = params.getClass().newInstance(params)
for (p in params) {
Expand Down
6 changes: 6 additions & 0 deletions nf_core/pipeline-template/nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@
"hidden": true,
"fa_icon": "fas fa-users-cog"
},
"config_profile_name": {
"type": "string",
"description": "Institutional config name.",
"hidden": true,
"fa_icon": "fas fa-users-cog"
},
"config_profile_description": {
"type": "string",
"description": "Institutional config description.",
Expand Down