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

v5.0.0 #119

Merged
merged 13 commits into from
Jan 17, 2025
Merged

v5.0.0 #119

merged 13 commits into from
Jan 17, 2025

Conversation

annakrystalli
Copy link
Member

In this PR I've mainly just bumped the version to v5.0.0 instead on v4.0.1 to signify a breaking change in the schema

The major changes have been reviewed in #116 and #118 already but I've moved them to this PR instead.

I've also gone ahead and removed target_variable and target_outcome from the standard task IDs in the schema.

Going to move on to updating hubAdmin now.

Explicit validation of round_id format

This PR Resolves #112 by adding a regex pattern check to the round.round_id property when round.round_id_from_variable id false. This provides upfront validation of the expected format of manual round IDs (i.e. not from a variable). It contains no breaking changes (Hub's can change to the version without making any further changes to their configs)

When round.round_id_from_variable is true, validation will be handled dynamically in hubAdmin (hubverse-org/hubAdmin#68)

Validation of the checks can be found in the hubAdmin PR added tests: https://github.com/hubverse-org/hubAdmin/blob/30923f58bac47484fd80860ba491a334876a279e/tests/testthat/test-create_round.R#L371-L474 and associated test files and snaphots

Restrict target_keys to single key pair value

This PR also resolves #117 by restricting target_keys objects to contain only a single key value pair.

Successful validation is demonstrated in hubAdmin PR hubverse-org/hubAdmin#90 and more specifically in these tests using this and this test file.

@annakrystalli
Copy link
Member Author

/diff

Copy link

Here are your diffs for this pull request

admin-schema.json

--- v4.0.0/admin-schema.json	2025-01-17 08:49:21.225440986 +0000
+++ v5.0.0/admin-schema.json	2025-01-17 08:49:22.443440604 +0000
@@ -1,6 +1,6 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
-    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v4.0.0/admin-schema.json",
+    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v5.0.0/admin-schema.json",
     "title": "Schema for Modeling Hub administrative settings",
     "description": "This JSON file provides a schema for modeling hub administrative information.",
     "type": "object",

tasks-schema.json

--- v4.0.0/tasks-schema.json	2025-01-17 08:49:21.226440986 +0000
+++ v5.0.0/tasks-schema.json	2025-01-17 08:49:22.443440604 +0000
@@ -1,6 +1,6 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
-    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v4.0.0/tasks-schema.json",
+    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v5.0.0/tasks-schema.json",
     "title": "Schema for Modeling Hub model task definitions",
     "description": "This is the schema of the tasks.json configuration file that defines the tasks within a modeling hub.",
     "type": "object",
@@ -27,7 +27,7 @@
                     "round_id": {
                         "description": "Round identifier. If round_id_from_variable = true, round_id should be the name of a task id variable present in all sets of modeling task specifications",
                         "examples": [
-                            "round-1",
+                            "round_1",
                             "2022-11-05",
                             "origin_date"
                         ],
@@ -36,7 +36,7 @@
                     "round_name": {
                         "description": "An optional round name. This can be useful for internal referencing of rounds, for examples, when a date is used as round_id but hub maintainers and teams also refer to rounds as round-1, round-2 etc.",
                         "examples": [
-                            "round-1"
+                            "round 1"
                         ],
                         "type": "string"
                     },
@@ -341,106 +341,6 @@
                                             ],
                                             "additionalProperties": false
                                         },
-                                        "target_variable": {
-                                            "description": "An object containing arrays of required and optional unique identifiers for each valid target variable. Usually forms part of a pair of task ID target key variables (along with target_outcome) which combine to define individual targets.",
-                                            "type": "object",
-                                            "examples": [
-                                                {
-                                                    "required": null,
-                                                    "optional": [
-                                                        "hosp",
-                                                        "death",
-                                                        "case"
-                                                    ]
-                                                },
-                                                {
-                                                    "required": [
-                                                        "hosp"
-                                                    ],
-                                                    "optional": [
-                                                        "case"
-                                                    ]
-                                                }
-                                            ],
-                                            "properties": {
-                                                "required": {
-                                                    "description": "Array of target variable unique identifiers that must be present for submission to be valid. Can be null if no target variables are required and all valid target variables are specified in the optional property.",
-                                                    "type": [
-                                                        "array",
-                                                        "null"
-                                                    ],
-                                                    "uniqueItems": true,
-                                                    "items": {
-                                                        "type": "string"
-                                                    }
-                                                },
-                                                "optional": {
-                                                    "description": "Array of valid but not required unique target variable identifiers. Can be null if all target variables are required and are specified in the required property.",
-                                                    "type": [
-                                                        "array",
-                                                        "null"
-                                                    ],
-                                                    "uniqueItems": true,
-                                                    "items": {
-                                                        "type": "string"
-                                                    }
-                                                }
-                                            },
-                                            "required": [
-                                                "required",
-                                                "optional"
-                                            ],
-                                            "additionalProperties": false
-                                        },
-                                        "target_outcome": {
-                                            "description": "An object containing arrays of required and optional unique identifiers for each valid target outcome. Usually forms part of a pair of task ID target key variables (along with target_variable) which combine to define individual targets.",
-                                            "type": "object",
-                                            "examples": [
-                                                {
-                                                    "required": [
-                                                        "inc"
-                                                    ],
-                                                    "optional": null
-                                                },
-                                                {
-                                                    "required": [
-                                                        "inc"
-                                                    ],
-                                                    "optional": [
-                                                        "cum"
-                                                    ]
-                                                }
-                                            ],
-                                            "properties": {
-                                                "required": {
-                                                    "description": "Array of target outcome unique identifiers that must be present for submission to be valid. Can be null if no target outcomes are required and all valid target outcomes are specified in the optional property.",
-                                                    "type": [
-                                                        "array",
-                                                        "null"
-                                                    ],
-                                                    "uniqueItems": true,
-                                                    "items": {
-                                                        "type": "string"
-                                                    }
-                                                },
-                                                "optional": {
-                                                    "description": "Array of valid but not required unique target outcome identifiers. Can be null if all target outcomes are required and are specified in the required property.",
-                                                    "type": [
-                                                        "array",
-                                                        "null"
-                                                    ],
-                                                    "uniqueItems": true,
-                                                    "items": {
-                                                        "type": "string"
-                                                    }
-                                                }
-                                            },
-                                            "required": [
-                                                "required",
-                                                "optional"
-                                            ],
-                                            "additionalProperties": false
-                                        },
                                         "target_date": {
                                             "description": "An object containing arrays of required and optional unique target dates. For short-term forecasts, the target_date specifies the date of occurrence of the outcome of interest. For instance, if models are requested to forecast the number of hospitalizations that will occur on 2022-07-15, the target_date is 2022-07-15",
                                             "examples": [
@@ -1290,20 +1190,14 @@
                                                     {
                                                         "target": "peak week hosp"
                                                     },
-                                                    {
-                                                        "target_variable": "hosp",
-                                                        "target_outcome": "inc"
-                                                    },
-                                                    {
-                                                        "target_variable": "case",
-                                                        "target_outcome": "peak week"
-                                                    },
                                                     null
                                                 ],
                                                 "type": [
                                                     "object",
                                                     "null"
                                                 ],
+                                                "minProperties": 1,
+                                                "maxProperties": 1,
                                                 "additionalProperties": {
                                                     "type": "string"
                                                 }
@@ -1490,6 +1384,21 @@
                         }
                     }
                 },
+                "if": {
+                    "properties": {
+                        "round_id_from_variable": {
+                            "const": false
+                        }
+                    }
+                },
+                "then": {
+                    "properties": {
+                        "round_id": {
+                            "pattern": "^([0-9]{4}-[0-9]{2}-[0-9]{2})$|^[A-Za-z0-9_]+$",
+                            "errorMessage": "The 'round_id' must match either an ISO date format (YYYY-MM-DD) or alphanumeric characters separated by underscores."
+                        }
+                    }
+                },
                 "required": [
                     "round_id_from_variable",
                     "round_id",

Copy link
Contributor

@elray1 elray1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@zkamvar zkamvar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you also for updating the round_name example

@annakrystalli annakrystalli merged commit 4b545ca into main Jan 17, 2025
3 checks passed
@annakrystalli annakrystalli deleted the br-v5.0.0 branch January 17, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Only allow a single target_keys key value pair Add round_id regex validation pattern
3 participants