Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

ConfigSpecs

A typed schema (dict of ParamSpec) plus value-management helpers.

The helpers (strip_computed_keys, validate_values, merge_computed, diff_values) operate on a values dict shaped by these specs.

ITEM_ID_KEY is the reserved per-row key on ParamSet items. ParamSet.validate mints, preserves, and restores it; nothing else in ConfigSpecs writes it.

Attributes
ITEM_ID_KEY: ClassVarMAX_KEY_LENGTH: ClassVarinvalid_reason: str | Noneis_valid: boolspecs: dict
Functions
__init__

Define the spec of a task or a view Example: ConfigSpecs({ "param1": IntParam(human_name="Param 1", default_value=1), "param2": StrParam(human_name="Param 2", default_value="Hello") })

specs : dict[str, gws_core.config.param.param_spec.ParamSpec] | None
_description_
_skip_key_validation : bool - False
add_or_update_spec
spec_name : str
spec : ParamSpec
add_spec
spec_name : str
spec : ParamSpec
all_config_are_optional

Check if all the config are optional

Return type : bool
assert_valid

Raise if this ConfigSpecs was built with an invalid definition.

Explicit fail-fast hook for runtime/non-class-body callers. The constructor itself never raises (see is_valid).

build_config_params

Build the ConfigParams from the param_specs and param_values. ConfigParam is supposed to be used directly not stored. Check the param_values with params_specs and return ConfigParams if ok. ConfigParams contains all value and default value if not provided.

Computed params (accepts_user_input=False) are evaluated after validation and merged into the returned ConfigParams.

param_values : dict
[description]
Return type : ConfigParams
check_config_specs

Check that the config specs are valid.

Validates spec keys (shape + length) and types, and delegates to ComputedParamGraphChecker for cycle detection and reference validation across computed expressions (which already recurses into ParamSets). Key validation also recurses into ParamSet inner specs.

check_spec_exists
spec_name : str
compute_values

Evaluate all entries with accepts_user_input=False over the provided values and return (computed_values, errors_by_key).

Thin delegator to ComputedParamResolver.compute_all — see that method for the full contract.

values : dict
evaluator : Any
Return type : tuple
format_field_errors

Render a {field_key: message} map as a sorted list of "Label: message" strings (labels via :meth:format_field_key).

Centralizes what every save/test surface used to do inline so the order and format are consistent across them.

errors : dict
Return type : list
format_field_key

Translate an internal field-key into a human-readable label using spec.human_name (falling back to the raw key when no human name is set).

Outputs:

  • "total_mass""Total mass"
  • "samples[].density""Samples[].Density" (formula on a ParamSet inner key — applies to every row)
  • "samples[2].mass""Samples[2].Mass" (a single row)

Used by save/test surfaces to turn validation- and computed-error keys into messages a user can read; the same shape is also handy for any other UI that needs a label for a stored field path.

field_key : str
Return type : str
get_and_check_values

Check and validate all values based on spec Returns all the parameters including default value if not provided

raises MissingConfigsException: If one or more mandatory params where not provided it raises a MissingConfigsException

param_values : dict
Return type : dict
get_default_values
Return type : dict
get_missing_mandatory_paths

Return paths of every missing mandatory field, recursing into ParamSet rows.

Path format uses human_name (with spec key as fallback):

  • top-level scalar: Mass
  • ParamSet row field: Samples[0].Mass (0-based row index)

Empty list means all mandatories are set. Used by the form save flow to surface a precise list of what is missing on the SUBMITTED gate.

param_values : dict
Return type : list
get_spec
spec_name : str
Return type : ParamSpec
get_specs_as_dict

Return a copy of the specs dictionary.

Useful for unpacking specs into a new ConfigSpecs, e.g.: ConfigSpecs({ "my_param": StrParam(...), **other_config_specs.get_specs_as_dict(), })

Return type : dict
has_spec
spec_name : str
Return type : bool
has_specs
Return type : bool
has_visible_config_specs

Check if the config has visible specs

Return type : bool
mandatory_values_are_set

check that all mandatory configs are provided

param_values : dict
Return type : bool
merge_computed

Merge the outer-scope computed dict into user_values and return the union.

Per-row ParamSet computed cells are populated in-place by compute_values itself, so this only needs to handle outer-scope keys. The result is the single dict the caller persists.

user_values : dict
computed : dict
Return type : dict
merge_specs

Merge two ConfigSpecs objects

specs2 : ConfigSpecs
Return type : ConfigSpecs
remove_spec
spec_name : str
strip_computed_keys

Drop keys whose spec.accepts_user_input is False (currently ComputedParam). Recurses into ParamSet rows.

Defensive input-side strip: clients must not write to computed keys; the evaluator owns those values.

values : dict
Return type : dict
to_dto

convert the config specs to json

skip_private : bool - True
Return type : dict
to_json_dict

convert the config specs to json

skip_private : bool - True
Return type : dict
update_spec
spec_name : str
spec : ParamSpec
validate_values

Run leaf-level ParamSpec.validate(...) on every provided value.

Lenient on two axes:

  • missing mandatories DO NOT raise (use mandatory_values_are_set as a separate gate when required);
  • per-leaf ParamSpec.validate failures are collected into the returned errors dict instead of aborting the whole pass. The offending value is dropped from the result so downstream consumers (computed evaluation, persistence) don't see invalid data.

Error keys mirror computed errors:

  • "<key>" for outer-scope leaves;
  • "<paramset>[<row_index>].<inner>" for ParamSet rows (row index included because a range failure is per-row data, unlike computed errors which apply uniformly across rows).

For ParamSets, ParamSet.validate_lenient mints __item_id per row and the result carries it back. Callers that want the old raise-on-error contract should use :meth:validate_values_or_raise.

values : dict
Return type : ValidateValuesResult
validate_values_or_raise

Raise-on-error wrapper around :meth:validate_values.

Aggregates every leaf-validation failure into a single BadRequestException (rather than the old fail-fast behavior where the first invalid field aborted). Use from non-form callers that want the legacy raising contract; the form pipeline uses validate_values directly so it can render per-field diagnostics.

values : dict
Return type : dict
from_dto @classmethod

Create a config specs from a dto

dict_ : dict
Return type : ConfigSpecs
from_json @classmethod

Create a config specs from a json

dict_ : dict
Return type : ConfigSpecs
diff_scalar @staticmethod

Diff a single non-ParamSet value into 0 or 1 ConfigChangeEntry.

Public so ParamSet.diff_values can reuse it for inner-field diffing.

path : str
old_val : Any
new_val : Any
in_old : bool
in_new : bool
Return type : list
diff_values @staticmethod

Recursive diff producing one ConfigChangeEntry per leaf change.

Field-path shape:

  • top-level scalar: mass
  • ParamSet item field: samples[item_id=<uuid>].mass
  • whole item add/remove: samples[item_id=<uuid>]

Reorder = REMOVED + ADDED for the same __item_id. Pure reorders (no inner field changes) produce no entries. Workflow-level events like form status transitions are appended by the caller.

ParamSet diffing is delegated to ParamSet.diff_values (it owns the per-row identity model). This entry point only handles dispatch.

old : dict[str, typing.Any] | None
new : dict[str, typing.Any] | None
Return type : list
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.