Example #1
0
class SettingsConfig(Form):
    """ The root Form of the whole settings inputs tree.
    This collects all settings from EpiViz-AT and adds default
    values when they are missing.

    A representation of the configuration form we expect to receive from EpiViz.
    The hope is that this form will do as much validation and precondition checking
    as is feasible within the constraint that it must be able to validate a full
    EpiViz parameter document in significantly less than one second. This is
    because it will be used as part of a web service which gates EpiViz submissions
    and must return in near real time.

    The Configuration class is the root of the form.

    Example
    -------
        >>> import json
        >>> input_data = json.loads(json_blob)
        >>> form = SettingsConfig(input_data)
        >>> errors = form.validate_and_normalize()
    """
    model: Model = Model(display="Model", validation_priority=5)
    policies: Policies = Policies(display="Policies")
    gbd_round_id: IntField = IntField(display="GBD Round ID")
    random_effect: FormList = FormList(Smoothing,
                                       nullable=True,
                                       display="Random effects")
    rate: FormList = FormList(Smoothing, display="Rates")
    country_covariate: FormList = FormList(CountryCovariate,
                                           display="Country covariates")
    study_covariate: FormList = FormList(StudyCovariate,
                                         display="Study covariates",
                                         nullable=True)
    eta: Eta = Eta(validation_priority=5)
    students_dof: StudentsDOF = StudentsDOF(validation_priority=5)
    log_students_dof: StudentsDOF = StudentsDOF(validation_priority=5)
    location_set_version_id: IntField = IntField(default=429, nullable=True)
    csmr_cod_output_version_id: IntField = IntField()
    csmr_mortality_output_version_id: Dummy = Dummy()
    min_cv: FormList = FormList(MinCV,
                                display="Minimum coefficient of variation",
                                nullable=False)
    min_cv_by_rate: FormList = FormList(
        MinCVRate,
        display="Minimum coefficient of variation by rate",
        nullable=True)
    re_bound_location: FormList = FormList(RandomEffectBound)
    derivative_test: DerivativeTest = DerivativeTest(display="Derivative test")
    max_num_iter: FixedRandomInt = FixedRandomInt(
        display="Max ipopt iterations")
    print_level: FixedRandomInt = FixedRandomInt(display="Print level")
    accept_after_max_steps: FixedRandomInt = FixedRandomInt(
        display="Max backtracking")
    tolerance: FixedRandomFloat = FixedRandomFloat(
        display="Desired relative convergence tolerance")
    data_cv_by_integrand: FormList = FormList(DataCV)
    data_eta_by_integrand: FormList = FormList(DataEta)
    data_density_by_integrand: FormList = FormList(DataDensity)
    config_version: StrField = StrField(nullable=True,
                                        display="Settings version")
Example #2
0
class SettingsConfig(Form):
    """ The root Form of the whole settings inputs tree.

    Example:
        >>> import json
        >>> input_data = json.loads(json_blob)
        >>> form = SettingsConfig(input_data)
        >>> errors = form.validate_and_normalize()
    """
    model = Model(display="Model", validation_priority=5)
    policies = Policies(display="Policies")
    gbd_round_id = IntField(display="GBD Round ID")
    random_effect = FormList(Smoothing,
                             nullable=True,
                             display="Random effects")
    rate = FormList(Smoothing, display="Rates")
    country_covariate = FormList(CountryCovariate,
                                 display="Country covariates")
    study_covariate = FormList(StudyCovariate,
                               display="Study covariates",
                               nullable=True)
    eta = Eta(validation_priority=5)
    students_dof = StudentsDOF(validation_priority=5)
    log_students_dof = StudentsDOF(validation_priority=5)
    location_set_version_id = IntField(default=429, nullable=True)
    csmr_cod_output_version_id = IntField()
    csmr_mortality_output_version_id = Dummy()
    min_cv = FormList(MinCV,
                      display="Minimum coefficient of variation",
                      nullable=False)
    min_cv_by_rate = FormList(
        MinCVRate,
        display="Minimum coefficient of variation by rate",
        nullable=True)
    re_bound_location = FormList(RandomEffectBound)
    derivative_test = DerivativeTest(display="Derivative test")
    max_num_iter = FixedRandomInt(display="Max ipopt iterations")
    print_level = FixedRandomInt(display="Print level")
    accept_after_max_steps = FixedRandomInt(display="Max backtracking")
    tolerance = FixedRandomFloat(
        display="Desired relative convergence tolerance")
    data_cv_by_integrand = FormList(DataCV)
    data_eta_by_integrand = FormList(DataEta)
    data_density_by_integrand = FormList(DataDensity)
    config_version = StrField(nullable=True, display="Settings version")
Example #3
0
class CountryCovariate(Form):
    country_covariate_id: IntField = IntField(display="Covariate")

    measure_id: StrField = StrField(display="Measure")
    mulcov_type: OptionField = OptionField(
        ["rate_value", "meas_value", "meas_noise"], display="Multiplier type")
    transformation: IntField = IntField(display="Transformation")
    age_time_specific: IntField = IntField(display="Age and Time specific")

    age_grid: StringListField = StringListField(constructor=float,
                                                nullable=True,
                                                display="Age grid")
    time_grid: StringListField = StringListField(constructor=float,
                                                 nullable=True,
                                                 display="Time grid")
    default: SmoothingPriorGroup = SmoothingPriorGroup(display="Defaults")
    mulstd: SmoothingPriorGroup = SmoothingPriorGroup(nullable=True,
                                                      display="MulStd")
    detail: SmoothingPrior = FormList(SmoothingPrior,
                                      nullable=True,
                                      display="Detail")

    custom_age_grid: Dummy = Dummy()
    custom_time_grid: Dummy = Dummy()
class DataDensity(Form):
    value = StrField(nullable=True)
    integrand_measure_id = IntField(nullable=True)
class Model(Form):
    modelable_entity_id = IntField()
    decomp_step_id = IntField()
    model_version_id = IntField(nullable=True)
    random_seed = IntField()
    minimum_meas_cv = FloatField(nullable=True, display="Data CV floor")
    add_csmr_cause = IntField(nullable=True, display="CSMR cause")
    title = StrField(nullable=True, display="Title")
    description = StrField(nullable=True, display="Description")
    crosswalk_version_id = IntField(nullable=False,
                                    display="Crosswalk version ID")
    bundle_id = IntField(nullable=True, display="Data bundle")
    drill = OptionField(["cascade", "drill"], display="Drill")
    drill_location = IntField(display="Drill location", nullable=True)
    drill_location_start = IntField(display="Drill location start",
                                    nullable=True)
    drill_location_end = NativeListField(display="Drill location end",
                                         nullable=True)
    drill_sex = OptionField([1, 2],
                            constructor=int,
                            nullable=True,
                            display="Drill sex")
    birth_prev = OptionField([0, 1],
                             constructor=int,
                             nullable=True,
                             default=0,
                             display="Prevalence at birth")
    default_age_grid = StringListField(constructor=float,
                                       display="(Cascade) Age grid")
    default_time_grid = StringListField(constructor=float,
                                        display="(Cascade) Time grid")
    constrain_omega = OptionField([0, 1],
                                  constructor=int,
                                  nullable=False,
                                  display="Constrain other cause mortality")
    exclude_data_for_param = ListField(constructor=int,
                                       nullable=True,
                                       display="Exclude data for parameter")
    ode_step_size = FloatField(display="ODE step size")
    addl_ode_stpes = StringListField(constructor=float,
                                     nullable=True,
                                     display="Advanced additional ODE steps")
    split_sex = OptionField(["most_detailed", "1", "2", "3", "4", "5"],
                            display="Split sex (Being used as Drill Start)")
    quasi_fixed = OptionField([0, 1],
                              default=0,
                              constructor=int,
                              nullable=True)
    zero_sum_random = ListField(nullable=True,
                                display="Zero-sum random effects")
    bound_frac_fixed = FloatField(
        default=1e-2,
        nullable=True,
        display="allowed modification to point to move it within bounds")
    bound_random = FloatField(
        nullable=True,
        display="allowed modification to point to move it within bounds")
    rate_case = StrField(nullable=False, display="The rate case")
    data_density = StrField(nullable=True, display="Data density")
    relabel_incidence = IntField(nullable=False, display="Relabel incidence")

    def _full_form_validation(self, root):
        errors = []

        if self.drill == "drill":
            if self.is_field_unset("drill_sex"):
                errors.append("For a drill, please specify Drill sex.")

        return errors
Example #6
0
class MinCVRate(Form):
    cascade_level_id: StrField = StrField(nullable=True)
    rate_measure_id: StrField = StrField(nullable=True)
    value: FloatField = FloatField(nullable=True)
Example #7
0
class MinCV(Form):
    cascade_level_id: StrField = StrField(nullable=True)
    value: FloatField = FloatField(nullable=True)