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

Ensure at least one output type specified as required when a modeling task contains a required target #15

Open
annakrystalli opened this issue Apr 2, 2024 · 1 comment

Comments

@annakrystalli
Copy link
Member

If not it creates a problem down the line when hubData::expand_model_out_val_grid() is run with required_vals_only = TRUE.

e.g. with the following example config:

{
    "schema_version": "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/tasks-schema.json",
    "rounds": [
	{
            "round_id_from_variable": true,
            "round_id": "origin_date",
            "model_tasks": [
            {
               	"task_ids": {
                    "origin_date": {
                        "required": null,
                        "optional": [
                            "2023-11-12", "2023-11-19", "2023-11-26"
                            ]
                    },
                    "target": {
                        "required": null,
                        "optional": ["inc hosp"]
                    },
                    "horizon": {
                        "required": [1, 2],
                        "optional": [0]
                    },
                    "location": {
                        "required": null,
                        "optional": [
                                "US",
                                "01",
                                "02"
                            ]
                    },
                    "age_group":{
                        "required":["0-130"],
                        "optional":["0-0.99","1-4","5-17","5-64","18-49","50-64","65-130"]
		            }
                },
                "output_type": {
                    "quantile":{
                        "output_type_id":{
                            "required": [
                                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
                            ],
                            "optional":null
                        },
			            "value":{
	   		                "type":"double",
	   		                "minimum":0

			            }
                    }
                },
                "target_metadata": [
                    {
                       "target_id": "inc hosp",
                       "target_name": "Weekly incident RSV hospitalizations",
                       "target_units": "count",
                       "target_keys": {
                           "target": ["inc hosp"]
                       },
                       "target_type": "continuous",
                       "is_step_ahead": true,
                       "time_unit": "week"
                    }
                ]
		    },
            {
                "task_ids": {
                 "origin_date": {
                     "required": null,
                     "optional": [
                         "2023-11-12", "2023-11-19", "2023-11-26"
                         ]
                 },
                 "target": {
                     "required": ["peak time hosp"],
                     "optional": null
                 },
                 "horizon": {
                     "required": null,
                     "optional": null
                 },
                 "location": {
                     "required": null,
                     "optional": [
                             "US",
                             "01",
                             "02"
                         ]
                 },
                 "age_group":{
                     "required":["0-130"],
                     "optional":["0-0.99","1-4","5-17","5-64","18-49","50-64","65-130"]
                 }
                },
                "output_type": {
                    "cdf":{
                        "output_type_id":{
                            "required":null,
                            "optional":[1]
                        },
                        "value":{
                            "type":"double",
                            "minimum":0,
                            "maximum":1
                        }
                    }
                },
                "target_metadata": [
                 {
                    "target_id": "peak time hosp",
                    "target_name": "Peak timing of hospitalization",
                    "target_units": "population",
                    "target_keys": {
                        "target": ["peak time hosp"]
                    },
                    "target_type": "discrete",
                    "is_step_ahead": true,
                    "time_unit": "week"
                 }
                ]
            }
		],
       	"submissions_due": {
            "relative_to": "origin_date",
            "start": -6,
            "end": 100
        }
    }
    ]
}

The following error is returned:

Error in `purrr::map()` at hubData/R/expand_model_out_val_grid.R:199:5:In index: 2.
Caused by error in `value[[jvseq[[jjj]]]]`:
! subscript out of bounds
Run `rlang::last_trace()` to see where the error occurred.

from:

hubData::expand_model_out_val_grid(
  config_tasks,
  round_id = "2023-11-26",
  required_vals_only = TRUE
)

because the second modeling task has a required target but no required output type:

@annakrystalli
Copy link
Member Author

Perhaps we should also handle this exception somehow in the hubData::expand_model_out_val_grid()?

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

No branches or pull requests

1 participant