Skip to contents

Create Hub Repository from Template

The first step to setting up a Modeling Hub is to make a copy of the hubTemplate GitHub template repository and clone a local copy of it.

Configure Modeling Hub

Hubs are configured through two JSON config files which are used to validate new submissions as well as inform data users of available data.

  • admin.json: Contains Hub wide administrative configuration settings
  • tasks.json: Contains round-specific metadata of modeling tasks including task, target and output type metadata as well as details of submission windows. These files should live in a directory called hub-config/ in the root of the Hub repository.

For more details on these files, guidance on how to set them up and access to templates, please see our central hubDocs as well the JSON schema the config files should adhere to.

Validate Config files

You can use function validate_config() to check whether individual Hub config files are valid. To specify the file you want to validate you can either provide the path to the root of the Hub to argument hub_path (which assumes the config files are correctly located in directory hub-config/) or you can provide a direct path to a config file to argument config_path. You also need to specify the type of config file through argument config (one of "tasks" or "admin", defaults to "tasks").

The function will validate a given config file against a specific version of it’s schema, specified through argument schema_version. The default value of schema_version is "from_config" which uses the version specified in the schema_version property of the config file being validated.

validate_config(
  hub_path = system.file("testhubs/simple/", package = "hubUtils"),
  config = "tasks"
)
#> Loading required namespace: jsonvalidate
#>  Successfully validated config file /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json against schema <https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json>
#> [1] TRUE
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json
#> attr(,"schema_version")
#> [1] "v2.0.0"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json

If validation succeeds, the function returns TRUE. The path to the config file validated and the version and URL of the schema used for validation are also attached as attributes "config_path", "schema_version" and "schema_url" respectively.

You can validate a config file against the latest version of the schema by using "latest" or you can choose a specific version, e.g "v0.0.1".

The function defaults to using stable schema versions released to the main branch, but you can choose to validate against another branch (e.g. an upcoming development version) through argument branch.

validate_config(
  hub_path = system.file("testhubs/simple/", package = "hubUtils"),
  config = "tasks",
  schema_version = "v0.0.0.9"
)
#> Warning: Schema errors detected in config file
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json
#> validated against schema
#> <https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v0.0.0.9/tasks-schema.json>
#> [1] FALSE
#> attr(,"errors")
#>                                   instancePath
#> 1     /rounds/0/model_tasks/0/output_type/mean
#> 2 /rounds/0/model_tasks/0/output_type/quantile
#> 3     /rounds/1/model_tasks/0/output_type/mean
#> 4 /rounds/1/model_tasks/0/output_type/quantile
#>                                                                                                   schemaPath
#> 1     #/properties/rounds/items/properties/model_tasks/items/properties/output_type/properties/mean/required
#> 2 #/properties/rounds/items/properties/model_tasks/items/properties/output_type/properties/quantile/required
#> 3     #/properties/rounds/items/properties/model_tasks/items/properties/output_type/properties/mean/required
#> 4 #/properties/rounds/items/properties/model_tasks/items/properties/output_type/properties/quantile/required
#>    keyword missingProperty                               message         schema
#> 1 required         type_id must have required property 'type_id' type_id, value
#> 2 required         type_id must have required property 'type_id' type_id, value
#> 3 required         type_id must have required property 'type_id' type_id, value
#> 4 required         type_id must have required property 'type_id' type_id, value
#>   parentSchema.type
#> 1            object
#> 2            object
#> 3            object
#> 4            object
#>                                                    parentSchema.description
#> 1      Object defining the mean of the predictive distribution output type.
#> 2 Object defining the quantiles of the predictive distribution output type.
#> 3      Object defining the mean of the predictive distribution output type.
#> 4 Object defining the quantiles of the predictive distribution output type.
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        parentSchema.properties.type_id.description
#> 1 type_id is not meaningful for a mean output_type. The property is primarily used to determine whether mean is a required or optional output type through properties required and optional. If mean is a required output type, the required property must be an array containing the single string element 'NA' and the optional property must be set to null. If mean is an optional output type, the optional property must be an array containing the single string element 'NA' and the required property must be set to null
#> 2                                                                                                                                                                                                                                                                                                                                                                               Object containing required and optional arrays defining the probability levels at which quantiles of the predictive distribution will be recorded.
#> 3 type_id is not meaningful for a mean output_type. The property is primarily used to determine whether mean is a required or optional output type through properties required and optional. If mean is a required output type, the required property must be an array containing the single string element 'NA' and the optional property must be set to null. If mean is an optional output type, the optional property must be an array containing the single string element 'NA' and the required property must be set to null
#> 4                                                                                                                                                                                                                                                                                                                                                                               Object containing required and optional arrays defining the probability levels at which quantiles of the predictive distribution will be recorded.
#>                           parentSchema.properties.type_id.examples
#> 1                                                           NA, NA
#> 2 0.25, 0.50, 0.75, 0.10, 0.20, 0.30, 0.40, 0.60, 0.70, 0.80, 0.90
#> 3                                                           NA, NA
#> 4 0.25, 0.50, 0.75, 0.10, 0.20, 0.30, 0.40, 0.60, 0.70, 0.80, 0.90
#>   parentSchema.properties.type_id.type
#> 1                               object
#> 2                               object
#> 3                               object
#> 4                               object
#>                                                                                                                                                                                                                                                  parentSchema.properties.type_id.oneOf
#> 1 When mean is required, property set to single element 'NA' array, When mean is optional, property set to null, array, null, NA, NA, 1, NA, When mean is required, property set to null, When mean is optional, property set to single element 'NA' array, null, array, NA, NA, NA, 1
#> 2                                                                                                                                                                                                                                                                                 NULL
#> 3 When mean is required, property set to single element 'NA' array, When mean is optional, property set to null, array, null, NA, NA, 1, NA, When mean is required, property set to null, When mean is optional, property set to single element 'NA' array, null, array, NA, NA, NA, 1
#> 4                                                                                                                                                                                                                                                                                 NULL
#>   parentSchema.properties.type_id.required
#> 1                       required, optional
#> 2                       required, optional
#> 3                       required, optional
#> 4                       required, optional
#>                                                                                                                                                                  parentSchema.properties.type_id.properties.required.description
#> 1                                                                                                                                                                                                                           <NA>
#> 2 Array of unique probability levels between 0 and 1 that must be present for submission to be valid. Can be null if no probability levels are required and all valid probability levels are specified in the optional property.
#> 3                                                                                                                                                                                                                           <NA>
#> 4 Array of unique probability levels between 0 and 1 that must be present for submission to be valid. Can be null if no probability levels are required and all valid probability levels are specified in the optional property.
#>   parentSchema.properties.type_id.properties.required.type
#> 1                                                     NULL
#> 2                                              array, null
#> 3                                                     NULL
#> 4                                              array, null
#>   parentSchema.properties.type_id.properties.required.items.type
#> 1                                                           <NA>
#> 2                                                         number
#> 3                                                           <NA>
#> 4                                                         number
#>   parentSchema.properties.type_id.properties.required.items.minimum
#> 1                                                                NA
#> 2                                                                 0
#> 3                                                                NA
#> 4                                                                 0
#>   parentSchema.properties.type_id.properties.required.items.maximum
#> 1                                                                NA
#> 2                                                                 1
#> 3                                                                NA
#> 4                                                                 1
#>                                                                                             parentSchema.properties.type_id.properties.optional.description
#> 1                                                                                                                                                      <NA>
#> 2 Array of valid but not required unique probability levels. Can be null if all probability levels are required and are specified in the required property.
#> 3                                                                                                                                                      <NA>
#> 4 Array of valid but not required unique probability levels. Can be null if all probability levels are required and are specified in the required property.
#>   parentSchema.properties.type_id.properties.optional.type
#> 1                                                     NULL
#> 2                                              array, null
#> 3                                                     NULL
#> 4                                              array, null
#>   parentSchema.properties.type_id.properties.optional.items.type
#> 1                                                           <NA>
#> 2                                                         number
#> 3                                                           <NA>
#> 4                                                         number
#>   parentSchema.properties.type_id.properties.optional.items.minimum
#> 1                                                                NA
#> 2                                                                 0
#> 3                                                                NA
#> 4                                                                 0
#>   parentSchema.properties.type_id.properties.optional.items.maximum
#> 1                                                                NA
#> 2                                                                 1
#> 3                                                                NA
#> 4                                                                 1
#>   parentSchema.properties.value.type
#> 1                             object
#> 2                             object
#> 3                             object
#> 4                             object
#>                                                                             parentSchema.properties.value.description
#> 1                                                           Object defining the characteristics of valid mean values.
#> 2 Object defining the characteristics of valid quantiles of the predictive distribution at a given probability level.
#> 3                                                           Object defining the characteristics of valid mean values.
#> 4 Object defining the characteristics of valid quantiles of the predictive distribution at a given probability level.
#>   parentSchema.properties.value.examples
#> 1                             numeric, 0
#> 2                                   NULL
#> 3                             numeric, 0
#> 4                                   NULL
#>   parentSchema.properties.value.properties.type.description
#> 1                                 Data type of mean values.
#> 2                             Data type of quantile values.
#> 3                                 Data type of mean values.
#> 4                             Data type of quantile values.
#>   parentSchema.properties.value.properties.type.type
#> 1                                             string
#> 2                                             string
#> 3                                             string
#> 4                                             string
#>   parentSchema.properties.value.properties.type.enum
#> 1                           numeric, double, integer
#> 2                           numeric, double, integer
#> 3                           numeric, double, integer
#> 4                           numeric, double, integer
#>   parentSchema.properties.value.properties.type.examples
#> 1                                                   NULL
#> 2                                                numeric
#> 3                                                   NULL
#> 4                                                numeric
#>   parentSchema.properties.value.properties.minimum.description
#> 1                       The minimum inclusive valid mean value
#> 2       The minimum inclusive valid quantile value (optional).
#> 3                       The minimum inclusive valid mean value
#> 4       The minimum inclusive valid quantile value (optional).
#>   parentSchema.properties.value.properties.minimum.type
#> 1                                               integer
#> 2                                                number
#> 3                                               integer
#> 4                                                number
#>   parentSchema.properties.value.properties.minimum.examples
#> 1                                                      NULL
#> 2                                                         0
#> 3                                                      NULL
#> 4                                                         0
#>   parentSchema.properties.value.properties.maximum.description
#> 1                       the maximum inclusive valid mean value
#> 2       The maximum inclusive valid quantile value (optional).
#> 3                       the maximum inclusive valid mean value
#> 4       The maximum inclusive valid quantile value (optional).
#>   parentSchema.properties.value.properties.maximum.type
#> 1                                               integer
#> 2                                                number
#> 3                                               integer
#> 4                                                number
#>   parentSchema.properties.value.required parentSchema.required
#> 1                                   type        type_id, value
#> 2                                   type        type_id, value
#> 3                                   type        type_id, value
#> 4                                   type        type_id, value
#>                                                                                                                                      data.output_type_id.required
#> 1                                                                                                                                                            NULL
#> 2 0.010, 0.025, 0.050, 0.100, 0.150, 0.200, 0.250, 0.300, 0.350, 0.400, 0.450, 0.500, 0.550, 0.600, 0.650, 0.700, 0.750, 0.800, 0.850, 0.900, 0.950, 0.975, 0.990
#> 3                                                                                                                                                            NULL
#> 4 0.010, 0.025, 0.050, 0.100, 0.150, 0.200, 0.250, 0.300, 0.350, 0.400, 0.450, 0.500, 0.550, 0.600, 0.650, 0.700, 0.750, 0.800, 0.850, 0.900, 0.950, 0.975, 0.990
#>   data.output_type_id.optional data.value.type data.value.minimum
#> 1                           NA         integer                  0
#> 2                         NULL         integer                  0
#> 3                           NA         integer                  0
#> 4                         NULL         integer                  0
#>                                       dataPath
#> 1     /rounds/0/model_tasks/0/output_type/mean
#> 2 /rounds/0/model_tasks/0/output_type/quantile
#> 3     /rounds/1/model_tasks/0/output_type/mean
#> 4 /rounds/1/model_tasks/0/output_type/quantile
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json
#> attr(,"schema_version")
#> [1] "v0.0.0.9"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v0.0.0.9/tasks-schema.json
validate_config(
  hub_path = system.file("testhubs/simple/", package = "hubUtils"),
  config = "tasks",
  schema_version = "latest"
)
#>  Successfully validated config file /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json against schema <https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.1/tasks-schema.json>
#> [1] TRUE
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json
#> attr(,"schema_version")
#> [1] "v2.0.1"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.1/tasks-schema.json

Validation returning errors

If validation of the config file fails, the function returns FALSE. An additional list dataframe of errors returned by the ajv validation engine used is also attached as attribute "errors".

config_path <- system.file("error-schema/tasks-errors.json",
  package = "hubUtils"
)
validate_config(config_path = config_path, config = "tasks")
#> Warning: Hub configured using schema version v0.0.0.9. Support for schema earlier than
#> v2.0.0 was deprecated in hubUtils 0.0.0.9010.
#>  Please upgrade Hub config files to conform to, at minimum, version v2.0.0 as
#>   soon as possible.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: Schema errors detected in config file
#> /home/runner/work/_temp/Library/hubUtils/error-schema/tasks-errors.json
#> validated against schema
#> <https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v0.0.0.9/tasks-schema.json>
#> [1] FALSE
#> attr(,"errors")
#>                                       instancePath
#> 1 /rounds/0/model_tasks/0/task_ids/target/required
#> 2         /rounds/0/model_tasks/0/output_type/mean
#> 3     /rounds/0/model_tasks/0/output_type/quantile
#> 4                        /rounds/0/submissions_due
#> 5                  /rounds/0/submissions_due/start
#> 6                    /rounds/0/submissions_due/end
#> 7                        /rounds/0/submissions_due
#>                                                                                                              schemaPath
#> 1 #/properties/rounds/items/properties/model_tasks/items/properties/task_ids/properties/target/properties/required/type
#> 2                #/properties/rounds/items/properties/model_tasks/items/properties/output_type/properties/mean/required
#> 3            #/properties/rounds/items/properties/model_tasks/items/properties/output_type/properties/quantile/required
#> 4                                                 #/properties/rounds/items/properties/submissions_due/oneOf/0/required
#> 5                                    #/properties/rounds/items/properties/submissions_due/oneOf/1/properties/start/type
#> 6                                      #/properties/rounds/items/properties/submissions_due/oneOf/1/properties/end/type
#> 7                                                            #/properties/rounds/items/properties/submissions_due/oneOf
#>    keyword params.type params.missingProperty params.passingSchemas
#> 1     type array, null                   <NA>                    NA
#> 2 required        NULL                type_id                    NA
#> 3 required        NULL                type_id                    NA
#> 4 required        NULL            relative_to                    NA
#> 5     type      string                   <NA>                    NA
#> 6     type      string                   <NA>                    NA
#> 7    oneOf        NULL                   <NA>                    NA
#>                                     message
#> 1                        must be array,null
#> 2     must have required property 'type_id'
#> 3     must have required property 'type_id'
#> 4 must have required property 'relative_to'
#> 5                            must be string
#> 6                            must be string
#> 7    must match exactly one schema in oneOf
#>                                                                                                                                                                                                                                                                                                                                                      schema
#> 1                                                                                                                                                                                                                                                                                                                                               array, null
#> 2                                                                                                                                                                                                                                                                                                                                            type_id, value
#> 3                                                                                                                                                                                                                                                                                                                                            type_id, value
#> 4                                                                                                                                                                                                                                                                                                                                   relative_to, start, end
#> 5                                                                                                                                                                                                                                                                                                                                                    string
#> 6                                                                                                                                                                                                                                                                                                                                                    string
#> 7 Name of task id variable in relation to which submission start and end dates are calculated., NA, string, NA, Difference in days between start and origin date., Submission start date., integer, string, NA, date, Difference in days between end and origin date., Submission end date., integer, string, NA, date, relative_to, start, end, start, end
#>                                                                                                                                                                   parentSchema.description
#> 1 Array of target unique identifiers that must be present for submission to be valid. Can be null if no targets are required and all valid targets are specified in the optional property.
#> 2                                                                                                                     Object defining the mean of the predictive distribution output type.
#> 3                                                                                                                Object defining the quantiles of the predictive distribution output type.
#> 4                                                                                                                                                                                     <NA>
#> 5                                                                                                                                                                   Submission start date.
#> 6                                                                                                                                                                     Submission end date.
#> 7                                                                                                         Object defining the dates by which model forecasts must be submitted to the hub.
#>   parentSchema.type parentSchema.type
#> 1       array, null            string
#> 2            object              <NA>
#> 3            object              <NA>
#> 4              NULL              <NA>
#> 5            string              <NA>
#> 6            string              <NA>
#> 7            object              <NA>
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        parentSchema.properties.type_id.description
#> 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             <NA>
#> 2 type_id is not meaningful for a mean output_type. The property is primarily used to determine whether mean is a required or optional output type through properties required and optional. If mean is a required output type, the required property must be an array containing the single string element 'NA' and the optional property must be set to null. If mean is an optional output type, the optional property must be an array containing the single string element 'NA' and the required property must be set to null
#> 3                                                                                                                                                                                                                                                                                                                                                                               Object containing required and optional arrays defining the probability levels at which quantiles of the predictive distribution will be recorded.
#> 4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             <NA>
#> 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             <NA>
#> 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             <NA>
#> 7                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             <NA>
#>                           parentSchema.properties.type_id.examples
#> 1                                                             NULL
#> 2                                                           NA, NA
#> 3 0.25, 0.50, 0.75, 0.10, 0.20, 0.30, 0.40, 0.60, 0.70, 0.80, 0.90
#> 4                                                             NULL
#> 5                                                             NULL
#> 6                                                             NULL
#> 7                                                             NULL
#>   parentSchema.properties.type_id.type
#> 1                                 <NA>
#> 2                               object
#> 3                               object
#> 4                                 <NA>
#> 5                                 <NA>
#> 6                                 <NA>
#> 7                                 <NA>
#>                                                                                                                                                                                                                                                  parentSchema.properties.type_id.oneOf
#> 1                                                                                                                                                                                                                                                                                 NULL
#> 2 When mean is required, property set to single element 'NA' array, When mean is optional, property set to null, array, null, NA, NA, 1, NA, When mean is required, property set to null, When mean is optional, property set to single element 'NA' array, null, array, NA, NA, NA, 1
#> 3                                                                                                                                                                                                                                                                                 NULL
#> 4                                                                                                                                                                                                                                                                                 NULL
#> 5                                                                                                                                                                                                                                                                                 NULL
#> 6                                                                                                                                                                                                                                                                                 NULL
#> 7                                                                                                                                                                                                                                                                                 NULL
#>   parentSchema.properties.type_id.required
#> 1                                     NULL
#> 2                       required, optional
#> 3                       required, optional
#> 4                                     NULL
#> 5                                     NULL
#> 6                                     NULL
#> 7                                     NULL
#>                                                                                                                                                                  parentSchema.properties.type_id.properties.required.description
#> 1                                                                                                                                                                                                                           <NA>
#> 2                                                                                                                                                                                                                           <NA>
#> 3 Array of unique probability levels between 0 and 1 that must be present for submission to be valid. Can be null if no probability levels are required and all valid probability levels are specified in the optional property.
#> 4                                                                                                                                                                                                                           <NA>
#> 5                                                                                                                                                                                                                           <NA>
#> 6                                                                                                                                                                                                                           <NA>
#> 7                                                                                                                                                                                                                           <NA>
#>   parentSchema.properties.type_id.properties.required.type
#> 1                                                     NULL
#> 2                                                     NULL
#> 3                                              array, null
#> 4                                                     NULL
#> 5                                                     NULL
#> 6                                                     NULL
#> 7                                                     NULL
#>   parentSchema.properties.type_id.properties.required.items.type
#> 1                                                           <NA>
#> 2                                                           <NA>
#> 3                                                         number
#> 4                                                           <NA>
#> 5                                                           <NA>
#> 6                                                           <NA>
#> 7                                                           <NA>
#>   parentSchema.properties.type_id.properties.required.items.minimum
#> 1                                                                NA
#> 2                                                                NA
#> 3                                                                 0
#> 4                                                                NA
#> 5                                                                NA
#> 6                                                                NA
#> 7                                                                NA
#>   parentSchema.properties.type_id.properties.required.items.maximum
#> 1                                                                NA
#> 2                                                                NA
#> 3                                                                 1
#> 4                                                                NA
#> 5                                                                NA
#> 6                                                                NA
#> 7                                                                NA
#>                                                                                             parentSchema.properties.type_id.properties.optional.description
#> 1                                                                                                                                                      <NA>
#> 2                                                                                                                                                      <NA>
#> 3 Array of valid but not required unique probability levels. Can be null if all probability levels are required and are specified in the required property.
#> 4                                                                                                                                                      <NA>
#> 5                                                                                                                                                      <NA>
#> 6                                                                                                                                                      <NA>
#> 7                                                                                                                                                      <NA>
#>   parentSchema.properties.type_id.properties.optional.type
#> 1                                                     NULL
#> 2                                                     NULL
#> 3                                              array, null
#> 4                                                     NULL
#> 5                                                     NULL
#> 6                                                     NULL
#> 7                                                     NULL
#>   parentSchema.properties.type_id.properties.optional.items.type
#> 1                                                           <NA>
#> 2                                                           <NA>
#> 3                                                         number
#> 4                                                           <NA>
#> 5                                                           <NA>
#> 6                                                           <NA>
#> 7                                                           <NA>
#>   parentSchema.properties.type_id.properties.optional.items.minimum
#> 1                                                                NA
#> 2                                                                NA
#> 3                                                                 0
#> 4                                                                NA
#> 5                                                                NA
#> 6                                                                NA
#> 7                                                                NA
#>   parentSchema.properties.type_id.properties.optional.items.maximum
#> 1                                                                NA
#> 2                                                                NA
#> 3                                                                 1
#> 4                                                                NA
#> 5                                                                NA
#> 6                                                                NA
#> 7                                                                NA
#>   parentSchema.properties.value.type
#> 1                               <NA>
#> 2                             object
#> 3                             object
#> 4                               <NA>
#> 5                               <NA>
#> 6                               <NA>
#> 7                               <NA>
#>                                                                             parentSchema.properties.value.description
#> 1                                                                                                                <NA>
#> 2                                                           Object defining the characteristics of valid mean values.
#> 3 Object defining the characteristics of valid quantiles of the predictive distribution at a given probability level.
#> 4                                                                                                                <NA>
#> 5                                                                                                                <NA>
#> 6                                                                                                                <NA>
#> 7                                                                                                                <NA>
#>   parentSchema.properties.value.examples
#> 1                                   NULL
#> 2                             numeric, 0
#> 3                                   NULL
#> 4                                   NULL
#> 5                                   NULL
#> 6                                   NULL
#> 7                                   NULL
#>   parentSchema.properties.value.properties.type.description
#> 1                                                      <NA>
#> 2                                 Data type of mean values.
#> 3                             Data type of quantile values.
#> 4                                                      <NA>
#> 5                                                      <NA>
#> 6                                                      <NA>
#> 7                                                      <NA>
#>   parentSchema.properties.value.properties.type.type
#> 1                                               <NA>
#> 2                                             string
#> 3                                             string
#> 4                                               <NA>
#> 5                                               <NA>
#> 6                                               <NA>
#> 7                                               <NA>
#>   parentSchema.properties.value.properties.type.enum
#> 1                                               NULL
#> 2                           numeric, double, integer
#> 3                           numeric, double, integer
#> 4                                               NULL
#> 5                                               NULL
#> 6                                               NULL
#> 7                                               NULL
#>   parentSchema.properties.value.properties.type.examples
#> 1                                                   NULL
#> 2                                                   NULL
#> 3                                                numeric
#> 4                                                   NULL
#> 5                                                   NULL
#> 6                                                   NULL
#> 7                                                   NULL
#>   parentSchema.properties.value.properties.minimum.description
#> 1                                                         <NA>
#> 2                       The minimum inclusive valid mean value
#> 3       The minimum inclusive valid quantile value (optional).
#> 4                                                         <NA>
#> 5                                                         <NA>
#> 6                                                         <NA>
#> 7                                                         <NA>
#>   parentSchema.properties.value.properties.minimum.type
#> 1                                                  <NA>
#> 2                                               integer
#> 3                                                number
#> 4                                                  <NA>
#> 5                                                  <NA>
#> 6                                                  <NA>
#> 7                                                  <NA>
#>   parentSchema.properties.value.properties.minimum.examples
#> 1                                                      NULL
#> 2                                                      NULL
#> 3                                                         0
#> 4                                                      NULL
#> 5                                                      NULL
#> 6                                                      NULL
#> 7                                                      NULL
#>   parentSchema.properties.value.properties.maximum.description
#> 1                                                         <NA>
#> 2                       the maximum inclusive valid mean value
#> 3       The maximum inclusive valid quantile value (optional).
#> 4                                                         <NA>
#> 5                                                         <NA>
#> 6                                                         <NA>
#> 7                                                         <NA>
#>   parentSchema.properties.value.properties.maximum.type
#> 1                                                  <NA>
#> 2                                               integer
#> 3                                                number
#> 4                                                  <NA>
#> 5                                                  <NA>
#> 6                                                  <NA>
#> 7                                                  <NA>
#>   parentSchema.properties.value.required
#> 1                                   NULL
#> 2                                   type
#> 3                                   type
#> 4                                   NULL
#> 5                                   NULL
#> 6                                   NULL
#> 7                                   NULL
#>                                                parentSchema.properties.relative_to.description
#> 1                                                                                         <NA>
#> 2                                                                                         <NA>
#> 3                                                                                         <NA>
#> 4 Name of task id variable in relation to which submission start and end dates are calculated.
#> 5                                                                                         <NA>
#> 6                                                                                         <NA>
#> 7                                                                                         <NA>
#>   parentSchema.properties.relative_to.type
#> 1                                     <NA>
#> 2                                     <NA>
#> 3                                     <NA>
#> 4                                   string
#> 5                                     <NA>
#> 6                                     <NA>
#> 7                                     <NA>
#>           parentSchema.properties.start.description
#> 1                                              <NA>
#> 2                                              <NA>
#> 3                                              <NA>
#> 4 Difference in days between start and origin date.
#> 5                                              <NA>
#> 6                                              <NA>
#> 7                                              <NA>
#>   parentSchema.properties.start.type
#> 1                               <NA>
#> 2                               <NA>
#> 3                               <NA>
#> 4                            integer
#> 5                               <NA>
#> 6                               <NA>
#> 7                               <NA>
#>           parentSchema.properties.end.description
#> 1                                            <NA>
#> 2                                            <NA>
#> 3                                            <NA>
#> 4 Difference in days between end and origin date.
#> 5                                            <NA>
#> 6                                            <NA>
#> 7                                            <NA>
#>   parentSchema.properties.end.type   parentSchema.required parentSchema.format
#> 1                             <NA>                    NULL                <NA>
#> 2                             <NA>          type_id, value                <NA>
#> 3                             <NA>          type_id, value                <NA>
#> 4                          integer relative_to, start, end                <NA>
#> 5                             <NA>                    NULL                date
#> 6                             <NA>                    NULL                date
#> 7                             <NA>              start, end                <NA>
#>                            parentSchema.examples
#> 1                                           NULL
#> 2                                           NULL
#> 3                                           NULL
#> 4                                           NULL
#> 5                                           NULL
#> 6                                           NULL
#> 7 2022-06-07, -4, 2022-07-20, 2, NA, origin_date
#>                                                                                                                                                                                                                                                                                                                                          parentSchema.oneOf
#> 1                                                                                                                                                                                                                                                                                                                                                      NULL
#> 2                                                                                                                                                                                                                                                                                                                                                      NULL
#> 3                                                                                                                                                                                                                                                                                                                                                      NULL
#> 4                                                                                                                                                                                                                                                                                                                                                      NULL
#> 5                                                                                                                                                                                                                                                                                                                                                      NULL
#> 6                                                                                                                                                                                                                                                                                                                                                      NULL
#> 7 Name of task id variable in relation to which submission start and end dates are calculated., NA, string, NA, Difference in days between start and origin date., Submission start date., integer, string, NA, date, Difference in days between end and origin date., Submission end date., integer, string, NA, date, relative_to, start, end, start, end
#>                                                                                                                                            data
#> 1                                                                                                                               wk inc flu hosp
#> 2                                                                                                                            NA, NA, integer, 0
#> 3 0.01, 0.025, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.975, 0.99, integer, 0
#> 4                                                                                                                                         -6, 1
#> 5                                                                                                                                            -6
#> 6                                                                                                                                             1
#> 7                                                                                                                                         -6, 1
#>                                           dataPath
#> 1 /rounds/0/model_tasks/0/task_ids/target/required
#> 2         /rounds/0/model_tasks/0/output_type/mean
#> 3     /rounds/0/model_tasks/0/output_type/quantile
#> 4                        /rounds/0/submissions_due
#> 5                  /rounds/0/submissions_due/start
#> 6                    /rounds/0/submissions_due/end
#> 7                        /rounds/0/submissions_due
#> attr(,"config_path")
#> [1] "/home/runner/work/_temp/Library/hubUtils/error-schema/tasks-errors.json"
#> attr(,"schema_version")
#> [1] "v0.0.0.9"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v0.0.0.9/tasks-schema.json

Because the default output of the validator can be unwieldy and difficult to review, you can use function view_config_val_errors() to launch a more user friendly and concise version of the errors table in the Viewer panel in Rstudio.

validation <- validate_config(config_path = config_path, config = "tasks")
#> Warning: Schema errors detected in config file
#> /home/runner/work/_temp/Library/hubUtils/error-schema/tasks-errors.json
#> validated against schema
#> <https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v0.0.0.9/tasks-schema.json>
view_config_val_errors(validation)
hubUtils config validation error report
Report for file /home/runner/work/_temp/Library/hubUtils/error-schema/tasks-errors.json using schema version v0.0.0.9
Error location Schema details Config
instancePath schemaPath keyword message schema data

rounds1 └─model_tasks └──1 └───task_ids └────target └─────required

properties └rounds └─items └──properties └───model_tasks └────items └─────properties └──────task_ids └───────properties └────────target └─────────properties └──────────required └───────────type

type ❌ must be array,null

array, null

wk inc flu hosp

rounds1 └─model_tasks └──1 └───output_type └────mean

properties └rounds └─items └──properties └───model_tasks └────items └─────properties └──────output_type └───────properties └────────mean └─────────required

required ❌ must have required property 'type_id'

type_id, value

rounds1 └─model_tasks └──1 └───output_type └────quantile

properties └rounds └─items └──properties └───model_tasks └────items └─────properties └──────output_type └───────properties └────────quantile └─────────required

required ❌ must have required property 'type_id'

type_id, value

rounds1 └─submissions_due

properties └rounds └─items └──properties └───submissions_due └────oneOf

oneOf ❌ must match exactly one schema in oneOf

1 relative_to-description: Name of task id variable in relation to which submission start and end dates are calculated. relative_to-type: string start-description: Difference in days between start and origin date. start-type: integer start-format:‘NA’ end-description: Difference in days between end and origin date. end-type: integer end-format:‘NA’ required1: relative_to required2: start required3: end

2 relative_to-description:‘NA’ relative_to-type:‘NA’ start-description: Submission start date. start-type: string start-format: date end-description: Submission end date. end-type: string end-format: date required1: start required2: end

start: -6, end: 1
For more information, please consult the hubDocs documentation.

In the example above:

  • instancePath indicates the location of the validation error in the config file.
  • schemaPath indicates the location of the element in the schema which is failing validation.
  • keyword indicates the keyword causing the validation error.
  • message is the validation error message returned by the validator.
  • schema describes the valid schema values the failing keyword should conform to.
  • data is the value of the property in the config file which is failing validation.

Validating all Hub config files

To validate both admin.json and tasks.json in a single call, you can use function validate_hub_config(). This functions tests both files for validity and returns a list of the results of the validation checks for each file. By default it uses “from_config” as the schema_version argument and errors if both files are not using the same schema version.

validate_hub_config(
  hub_path = system.file("testhubs/simple/", package = "hubUtils")
)
#>  Hub correctly configured! 
#> admin.json, tasks.json and model-metadata-schema.json all valid.
#> $tasks
#> [1] TRUE
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json
#> attr(,"schema_version")
#> [1] "v2.0.0"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json
#> 
#> $admin
#> [1] TRUE
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/admin.json
#> attr(,"schema_version")
#> [1] "v2.0.0"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/admin-schema.json
#> 
#> $`model-metadata-schema`
#> [1] TRUE
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/model-metadata-schema.json
#> 
#> attr(,"config_dir")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config
#> attr(,"schema_version")
#> [1] "v2.0.0"
#> attr(,"schema_url")
#> [1] "https://github.com/Infectious-Disease-Modeling-Hubs/schemas/tree/main/v2.0.0"

You can also use the function to validate a Hub’s config against the latest version of the schema.

validate_config(
  hub_path = system.file("testhubs/simple/", package = "hubUtils"),
  schema_version = "latest"
)
#>  Successfully validated config file /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json against schema <https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.1/tasks-schema.json>
#> [1] TRUE
#> attr(,"config_path")
#> /home/runner/work/_temp/Library/hubUtils/testhubs/simple/hub-config/tasks.json
#> attr(,"schema_version")
#> [1] "v2.0.1"
#> attr(,"schema_url")
#> https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.1/tasks-schema.json

You can also use view_config_val_errors() on the output of validate_hub_config() to review any detected validation errors.