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

Support double nesting in nf-schema or required parameters #3437

Open
luisas opened this issue Jan 31, 2025 · 6 comments
Open

Support double nesting in nf-schema or required parameters #3437

luisas opened this issue Jan 31, 2025 · 6 comments

Comments

@luisas
Copy link

luisas commented Jan 31, 2025

Description of feature

I have a complicated structure for my required parameters, and I solved it by defining it this way in my nextflow_schema.json

            "oneOf": [
                {
                    "anyOf": [{ "required": ["seqs", "outdir"] }, { "required": ["pdbs_dir", "outdir"] }]
                },
                { "required": ["input", "outdir"] }
            ],

Yet I get the error:

CRITICAL Critical error: [✗] Pipeline schema does not follow nf-core specs:                                                                                                                                
          Default parameters are invalid: {'templates_suffix': '.pdb', 'calc_sim': True, 'calc_sp': True, 'calc_tc': True, 'calc_gaps': True, 'shiny_app': '${projectDir}/bin/shiny_app',                  
         'custom_config_version': 'master', 'custom_config_base': 'https://raw.githubusercontent.com/nf-core/configs/master', 'publish_dir_mode': 'copy', 'max_multiqc_email_size': '25.MB',               
         'validate_params': True, 'pipelines_testdata_base_path': 'https://raw.githubusercontent.com/nf-core/test-datasets/'} is not valid under any of the given schemas  

@mirpedrol mentioned it is because of the double nesting is not supported yet. Would it be possible to support it? Would be fantastic!

@awgymer
Copy link
Contributor

awgymer commented Feb 4, 2025

Is this actually the issue?

Based on your error message the deafult params are:

{
  "templates_suffix": ".pdb",
  "calc_sim": true,
  "calc_sp": true,
  "calc_tc": true,
  "calc_gaps": true,
  "shiny_app": "${projectDir}/bin/shiny_app",
  "custom_config_version": "master",
  "custom_config_base": "https://raw.githubusercontent.com/nf-core/configs/master",
  "publish_dir_mode": "copy",
  "max_multiqc_email_size": "25.MB",
  "validate_params": true,
  "pipelines_testdata_base_path": "https://raw.githubusercontent.com/nf-core/test-datasets/"
}

Which (correctly) is not considered valid against your schema.

You can test this.

Go to online schema validator
and enter your schema and test it against the above json params:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "anyOf": [
        {
          "required": [
            "seqs",
            "outdir"
          ]
        },
        {
          "required": [
            "pdbs_dir",
            "outdir"
          ]
        }
      ]
    },
    {
      "required": [
        "input",
        "outdir"
      ]
    }
  ]
}

@mirpedrol
Copy link
Member

The required parameters don't have a default, that's why we remove all the required from the schema when we validate the defaults in nf-core.
In this case, because there is nesting, we are not removing one of the required and that's why it fails

@mirpedrol
Copy link
Member

Here is the code, for reference

@awgymer
Copy link
Contributor

awgymer commented Feb 4, 2025

Ok, perhaps I was misled by the title of the issue. This is not an issue of support in nf-schema but rather support for something that nf-schema allows

@awgymer
Copy link
Contributor

awgymer commented Feb 5, 2025

Ok, after a little look and play around with some jsonschema code I think that we can actually do this without needing to modify the input schema at all.

Is anyone able to provide a minimal reproducible example of for the issue so that I can check it? (I guess I need a pipeline, a config, and a schema, but also to know which commands throw this error)

@awgymer
Copy link
Contributor

awgymer commented Feb 5, 2025

Ok, had to modify the schema still, but took a guess that this was about multiplesequencealign and added the oneOf to a copy of dev branch with a little fix to tools and...:

❯ nf-core pipelines schema lint


                                          ,--./,-.
          ___     __   __   __   ___     /,-._.--~\ 
    |\ | |__  __ /  ` /  \ |__) |__         }  {
    | \| |       \__, \__/ |  \ |___     \`-._,-`-,
                                          `._,._,'

    nf-core/tools version 3.2.0.dev0 - https://nf-co.re


INFO     [✓] Default parameters match schema validation                                                                            
INFO     [✓] Pipeline schema looks valid (found 47 params) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants