casys.report.configurator

Submodule allowing to set and generate structured reports.

Functions

set_diag_name(param, diag_type, field_name)

Create a diagnostic name if not included in provided parameters.

Classes

DiagnosticConfiguration([section, ...])

Class representing a single diagnostic configuration.

FieldConfiguration([name, source, ...])

Class representing the configuration's information of a field.

ReportConfigurator(fields[, data_type, ...])

Class allowing to configure and generate reports.

ReportConfiguratorSchema(*[, only, exclude, ...])

Marshmallow schema for ReportConfigurator.

MultiMissionPolicy(value[, names, module, ...])

Different types of multi-mission display policies.

MultiMissionPolicyField(*[, load_default, ...])

Marshmallow MultiMissionPolicy field.

ReportProperties([common, templates, ...])

Class containing text properties (title and text) for different elements.

ReportPropertiesSchema(*[, only, exclude, ...])

ReportProperties' marshmallow schema.

SectionOrderType(value[, names, module, ...])

Different types of section naming policies.

SectionOrderTypeField(*[, load_default, ...])

Marshmallow SectionOrderType field.

SourceConfiguration(reference, source[, ...])

Data source specification.

SourceConfigurationSchema(*[, only, ...])

SourceConfiguration's marshmallow schema.

SectionConfiguration([section, properties, ...])

Class representing the configuration of a report's section.

SectionConfigurationSchema(*[, only, ...])

Marshmallow schema for SectionConfiguration.

ReportSources(database[, ges_table_dir, ...])

Report's sources configuration.

ReportSourcesSchema(*[, only, exclude, ...])

ReportSources' marshmallow schema.

PlotOperatorDiagnostic(field, *, operator, ...)

Diagnostic allowing to combine plots from different sources.

PlotOperatorDiagnosticSchema(*[, only, ...])

Marshmallow schema for the PlotOperatorDiagnostic class.

ReportDiagnostic(field)

Base class to create custom diagnostics usable in a ReportGenerator.

ReportDiagnosticBaseSchema(*[, only, ...])

ReportDiagnosticGenericSchema(**kwargs)

Exceptions

ReportConfiguratorError

Exception raised when a problem related to report configuration occurs.

class casys.report.configurator.DiagnosticConfiguration(section=None, properties=<factory>, parameters=<factory>, report=<factory>)

Bases: SectionBase

Class representing a single diagnostic configuration.

Parameters:
  • parameters (dict[str, Any]) – AltiData’s diagnostic parameters.

  • section (str | None) – Section of the report in which this diagnostic will be used.

  • properties (SectionProperties) – Section properties

  • report (list[SectionConfiguration]) – List of report’s section configuration where this diagnostic is used.

custom_conf(sources, nb, with_store=True)

Format provided diagnostic configuration as a custom diagnostic.

Parameters:
  • sources (list[SourceConfiguration]) – Sources on which we’re working.

  • nb (int) – Current source number.

  • with_store (bool) – Whether to add store operation to each data or not.

Return type:

tuple[str | None, str, dict[str, Any]]

Returns:

Diagnostic reference, key and configuration.

data_conf(source)

Dump the diagnostic configuration.

Parameters:

source (SourceConfiguration) – Source for which to generate the configuration.

Return type:

dict[str, Any]

Returns:

Diagnostic configuration as a dictionary.

property dtype: str
initialize(field, conf_report)

Initialize this diagnostic by sorting and expanding its sections.

Provided properties are propagated to expanded sections.

Parameters:
  • field (NamedSectionBase) – Field’s section properties.

  • conf_report (ReportProperties) – Report’s properties.

property name: str
property own_section: bool
parameters: dict[str, Any]
property path: SectionPath
properties: SectionProperties
report: list[SectionConfiguration]
report_chapters: dict[str, dict[str, SectionConfiguration]]
report_names: list[str]
report_properties: ReportProperties = None
section: str | None = None
validate_diagnostic_level()

Validate the properties defined at the diagnostic level.

Raises:

ReportConfiguratorError – If split_per_diag properties are defined.

class casys.report.configurator.FieldConfiguration(name=None, source=None, source_aux=None, subfields=None, unit=None, description='', interpolation=None, attributes=<factory>, section=None, properties=<factory>, diagnostics=<factory>)

Bases: NamedSectionBase, FieldBase

Class representing the configuration’s information of a field.

Parameters:
  • name (str | None) – Name of the field.

  • source (str | None) –

    Name of the field in the data source (can be a clip). WARNING: Clip’s operator syntax might change depending on the source’s type.

    • Dataset sources might require vector operator: :==, :!=, :<, :<=, :>, :>=

    • CLS Table sources require scalar operators: ==, !=, <, <=, >, >=

  • source_aux (str | None) – Alternative name of the field in the data source (can be a clip). This attribute might be used for multi-missions crossovers.

  • subfields (list[FieldBase] | None) – List of subfields used in the source of this field. This might be useful when creating fields as clip from a MultiReader. Each subfield have to belong to single reader and will be computed before any reader post-processing (such as interpolation).

  • unit (cfu_t.Unit | str | None) – Unit of the field.

  • description (str) – Description of the field.

  • interpolation (str | dict[str, Any] | InterpolationOptions | None) –

    Interpolation options. Can be provided using an InterpolationOptions object or a dictionary containing ‘mode’ and ‘noise_level’ keys: {‘mode’: ‘smoothing_spline’, noise_level: 0.1} or a string containing only the ‘mode’.

    mode

    Interpolation mode to use when interpolating along a reference track. Accepted values are linear, nearest or smoothing_spline.

    noise_level

    Only required for the smoothing_spline mode. Estimated noise level in the signal. Oscillations lower that this value will be removed by the smoothing spline.

  • attributes (dict[str, Any]) – Additional information.

  • section (str | None) – Section of the report in which this diagnostic will be used.

  • properties (SectionProperties) – Section properties

  • diagnostics (list[DiagnosticConfiguration]) – List of field’s related diagnostics’ configuration.

classmethod attribute_names()
Return type:

list[str]

attributes: dict[str, Any]
classmethod consolidate_sections(section)

Recursively set missing section configuration title when containing subsections.

Parameters:

section (SectionConfiguration) – SectionConfiguration object.

description: str = ''
diagnostics: list[DiagnosticConfiguration]
initialize(properties)

Initialize current field sections and properties.

Parameters:

properties (ReportProperties) – Additional properties to take into account.

interpolation: str | dict[str, Any] | InterpolationOptions | None = None
is_similar(field)

Test whether both fields are equivalent or not.

Similar fields have identical properties with an exception

Parameters:

field (Field)

Return type:

bool

name: str | None = None
classmethod normalize(field)
Parameters:

field (str | Field | None)

Return type:

Field | None

property own_section: bool
property path: SectionPath
properties: SectionProperties
report_names: list[str]
reports: dict[str, ReportContent]
section: str | None = None
source: str | None = None
source_aux: str | None = None
storage_field()

Storage (DiagnosticField) representation of this field.

Return type:

DiagnosticField

subfields: list[FieldBase] | None = None
unit: cfu_t.Unit | str | None = None
class casys.report.configurator.MultiMissionPolicy(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Different types of multi-mission display policies.

GRID = 4
NONE = 1
SEQUENTIAL = 2
STACK = 3
class casys.report.configurator.MultiMissionPolicyField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: BaseEnumField

Marshmallow MultiMissionPolicy field.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.report.configurator.PlotOperatorDiagnostic(field, *, operator, data_name, stat)

Bases: ReportDiagnostic

Diagnostic allowing to combine plots from different sources.

Parameters:
  • field (Field)

  • operator (str)

  • data_name (str)

  • stat (str)

REQUIRE_COMPUTE: ClassVar[bool] = False
REQUIRE_REPORT_CONTENT: ClassVar[bool] = True
compute(data)

Diagnostic computation.

Diagnostic results have to be stored into the class itself.

Parameters:

data (list[CommonData]) – Computed AltiData related to each source.

data_name: str
field: Field
classmethod get(name)
Parameters:

name (str)

Return type:

TypeVar(ReportDiagnosticType, bound= ReportDiagnostic)

classmethod load(name)

Load a previously stored diagnostic object.

Parameters:

name (str | Path) – Path and name of the stored diagnostic.

Return type:

TypeVar(ReportDiagnosticType, bound= ReportDiagnostic)

Returns:

The loaded diagnostic.

operator: str
report_content(data, template=None, data_params=None, plot_params=None, text_params=None, **kwargs)

Diagnostic representation. This method will generate the content displayed into a report’s section.

Parameters:
  • data (list[CommonData]) – Computed CommonData related to each source.

  • template (PlotTemplate) – Global plot’s template.

  • data_params (DataParams) – Plot’s data parameters.

  • plot_params (PlotParams) – Plot’s general parameters.

  • text_params (TextParams) – Plot’s text parameters.

  • kwargs – Additional parameters.

stat: str
store(name, overwrite=False)

Store this diagnostic object at the provided path.

Parameters:
  • name (str) – Path of the file.

  • overwrite (bool) – Whether to overwrite any existing file or not.

class casys.report.configurator.PlotOperatorDiagnosticSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: ReportDiagnosticBaseSchema

Marshmallow schema for the PlotOperatorDiagnostic class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

In addition to registering the custom diagnostic, this function generates schemas allowing the diagnostic to be used in reports (and dumped as code).

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.ReportConfigurator(fields, data_type=DataContainerType.NADIR, properties=<factory>, imports=None)

Bases: object

Class allowing to configure and generate reports.

Parameters:
chapters_diagnostics(report=None, chapters=None)

Diagnostics for the provided report including requested chapters. Diagnostics are sorted per chapters.

Parameters:
  • report (str | None) – Report name. Default to a report containing everything.

  • chapters (str | list[str] | None) – List of chapters to include (Default: all chapters)

Return type:

dict[str, list[DiagnosticConfiguration]]

Returns:

Dictionary of chapters with their diagnostics’ configuration.

compute_data(sources, date_start=None, date_end=None, report=None, chapters=None, dask_params=None)

Compute and store data for the provided source.

Parameters:
Return type:

dict[str, CommonData]

Returns:

Dictionary of source’s name for which the computation was completed associated to their computed data.

data_type: DataContainerType = 1
fields: list[FieldConfiguration]
imports: dict[str, Any] | None = None
initialize(properties=None)

Sets fields, diagnostics and report’s section.

Parameters:

properties (ReportProperties | None) – Additional properties to take into account.

classmethod load(conf, context=None, properties=None)

Generate a ReportConfigurator based on the provided configuration and properties.

Parameters:
  • conf (str | dict) – Configuration to load (as a dictionary or file name).

  • context (dict | None) – Jinja context used to read provided configuration file.

  • properties (ReportProperties | None) – Additional properties used by the ReportConfigurator. These properties have a lower priority than the ones included in the ‘conf’.

Return type:

ReportConfigurator

Returns:

A new, initialized, ReportConfigurator.

properties: ReportProperties
report_chapters(report=None)

List existing chapters for the provided report.

Parameters:

report (str | None) – Name of the report for which to get the list of chapters. Default to a report containing everything.

Return type:

list[str]

Returns:

List of chapter’s names.

report_content(sources, report=None, chapters=None, date_start=None, date_end=None)

Generate a report limited to the content part.

Parameters:
Return type:

ReportCasys

Returns:

Generated Casys’ report.

report_content_conf(sources, report=None, ch_names=None)

Generate the report’s content.

Parameters:
  • sources (list[SourceConfiguration]) – List of sources for which to generate configuration.

  • report (str | None) – Report name. Default to a report containing everything.

  • ch_names (str | list[str] | None) – List of chapters to include (Default: all chapters)

Return type:

dict[str, Any]

Returns:

Dictionary representing the report’s content configuration.

report_data(sources, date_start=None, date_end=None, report=None, chapters=None)

Generate a report limited to the data part.

Parameters:
Return type:

ReportCasys

Returns:

Generated Casys’ report.

report_data_conf(sources, date_start=None, date_end=None, report=None, ch_names=None, compute=True, store=True)

Generate the report’s data part.

Parameters:
  • sources (list[SourceConfiguration]) – Sources for which to generate data.

  • date_start (Any | None) – Starting date.

  • date_end (Any | None) – Ending date.

  • report (str | None) – Report’s name. Default to a report containing everything.

  • ch_names (str | list[str] | None) – Included chapters’ list (default to all chapters).

  • compute (bool) – Whether to add computation operation to each source or not.

  • store (bool) – Whether to add store operation to each data or not.

Return type:

dict[str, Any]

Returns:

Dictionary representing the report’s data configuration.

report_full(sources, date_start=None, date_end=None, report=None, chapters=None, store=False)

Generate a full report including the data and report’s content parts.

Parameters:
Return type:

ReportCasys

Returns:

Generated Casys’ report.

report_names: list[str]
reports: dict[str, ReportContent]
exception casys.report.configurator.ReportConfiguratorError

Bases: Exception

Exception raised when a problem related to report configuration occurs.

add_note(object, /)

Exception.add_note(note) – add a note to the exception

args
with_traceback(object, /)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class casys.report.configurator.ReportConfiguratorSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for ReportConfigurator.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.ReportDiagnostic(field)

Bases: ABC

Base class to create custom diagnostics usable in a ReportGenerator.

Parameters:

field (Field) – Automatically generated field.

REQUIRE_COMPUTE: ClassVar[bool] = True
REQUIRE_REPORT_CONTENT: ClassVar[bool] = True
compute(data)

Diagnostic computation.

Diagnostic results have to be stored into the class itself.

Parameters:

data (list[CommonData]) – Computed AltiData related to each source.

field: Field
classmethod get(name)
Parameters:

name (str)

Return type:

TypeVar(ReportDiagnosticType, bound= ReportDiagnostic)

classmethod load(name)

Load a previously stored diagnostic object.

Parameters:

name (str | Path) – Path and name of the stored diagnostic.

Return type:

TypeVar(ReportDiagnosticType, bound= ReportDiagnostic)

Returns:

The loaded diagnostic.

report_content(data, template=None, data_params=None, plot_params=None, text_params=None, *args, **kwargs)

Diagnostic representation. This method will generate the content displayed into a report’s section.

Parameters:
  • data (list[CommonData]) – Computed CommonData related to each source.

  • template (PlotTemplate) – Global plot’s template.

  • data_params (DataParams) – Plot’s data parameters.

  • plot_params (PlotParams) – Plot’s general parameters.

  • text_params (TextParams) – Plot’s text parameters.

  • kwargs – Additional parameters.

store(name, overwrite=False)

Store this diagnostic object at the provided path.

Parameters:
  • name (str) – Path of the file.

  • overwrite (bool) – Whether to overwrite any existing file or not.

class casys.report.configurator.ReportDiagnosticBaseSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: ReportDiagnosticSimpleBaseSchema

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

In addition to registering the custom diagnostic, this function generates schemas allowing the diagnostic to be used in reports (and dumped as code).

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.ReportDiagnosticGenericSchema(**kwargs)

Bases: RegistryGenericSchema

class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **kwargs)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.ReportProperties(common=<factory>, templates=<factory>, sections=<factory>, diagnostics=<factory>, frequencies=<factory>, statistics=<factory>)

Bases: object

Class containing text properties (title and text) for different elements.

Parameters:
  • common (SectionProperties) – Common report’s properties.

  • templates (dict[str, dict]) – Set of templates that will be registered and available in the generated report.

  • sections (dict[str, SectionProperties]) – Section’s properties. The order in which sections are defined is used to define the order of sections in reports.

  • diagnostics (dict[str, SectionProperties]) – Diagnostics type properties. Diagnostics type are ‘raw’, ‘temporal’, ‘geobox’, …

  • frequencies (dict[FreqType, SectionProperties]) – Frequencies properties. Frequencies are ‘cycle’, ‘pass’, ‘day’, …

  • statistics (dict[StatType, SectionProperties]) – Statistics properties. Statistics are ‘count’, ‘mean’, ‘med’, …

common: SectionProperties
diagnostic(diag)

Properties for the requested diagnostic. Default properties using the diag name as title are returned if not included.

Parameters:

diag (str) – Name of the diagnostic (raw, geobox, temporal, …)

Return type:

SectionProperties

Returns:

Text and plot properties.

diagnostics: dict[str, SectionProperties]
frequencies: dict[FreqType, SectionProperties]
frequency(freq)

Properties for the requested frequency. Default properties using the diag name as title are returned if not included.

Parameters:

freq (FrequencyHandler) – Name of the frequency (cycle, pass, day, …)

Return type:

SectionProperties

Returns:

Text and plot properties.

section(path)

Properties for the requested section’s path. Default properties are returned if not included.

Parameters:

path (SectionPath) – Path of the section.

Return type:

SectionProperties

Returns:

Text and plot properties.

sections: dict[str, SectionProperties]
statistic(stat)

Properties for the requested statistic. Default properties using the stat name as title are returned if not included.

Parameters:

stat (StatType | str) – Name of the statistic (mean, median, std, …)

Return type:

SectionProperties

Returns:

Text and plot properties.

statistics: dict[StatType, SectionProperties]
templates: dict[str, dict]
update(config)

Update report’s properties with the providing ones.

Parameters:

config (ReportProperties | None) – Properties from which to update.

class casys.report.configurator.ReportPropertiesSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

ReportProperties’ marshmallow schema.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.ReportSources(database, ges_table_dir=None, time_extension=None)

Bases: object

Report’s sources configuration.

Parameters:
database: dict[str, dict[str, SourceConfiguration]]
db_missions()

Return available missions.

Return type:

list[str]

db_source(mission, timeliness)

Return the requested data’s source.

Parameters:
  • mission (str) – Mission’s name.

  • timeliness (str) – Timeliness’ name.

Return type:

SourceConfiguration

Returns:

Corresponding data’s source.

db_timeliness(mission)

Return available mission’s timeliness.

Parameters:

mission (str)

Return type:

list[str]

ges_table_dir: str | None = None
classmethod load(conf, context=None)

Generate a ReportSources based on the provided configuration.

Parameters:
  • conf (str | dict) – Configuration to load (as a dictionary or file name).

  • context (dict | None) – Jinja context used to read provided configuration file.

Return type:

ReportSources

Returns:

A new, initialized, ReportConfigurator.

time_extension: bool | None = None
class casys.report.configurator.ReportSourcesSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

ReportSources’ marshmallow schema.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.SectionConfiguration(section=None, properties=<factory>, *, reports=<factory>, data_name=None, diag_type=None, parameters=<factory>, place_holder=False, report_properties=<factory>, default_report=True)

Bases: SectionBase

Class representing the configuration of a report’s section.

Parameters:
  • reports (list[str]) – List of reports’ name in which this section is included.

  • section (str | None) – Section of the report in which this diagnostic will be used.

  • properties (SectionProperties) – Section properties

  • data_name (str | None) – Diagnostic name.

  • diag_type (str | None) – Diagnostic type.

  • parameters (dict[str, Any]) – CasysPlot parameters.

  • place_holder (bool) – Whether this configuration is automatically generated or define with user parameters.

  • report_properties (ReportProperties)

  • default_report (InitVar)

add_section(section, level=0, allow_update=True)

Add provided section to this content.

Parameters:
  • section (SectionConfiguration) – Section to add.

  • level (int) – Current ReportSectionContent level.

  • allow_update (bool) – Whether to allow this section properties update or not.

data_name: str | None = None
default_report: InitVar = True
diag_type: str | None = None
full_report(ctype, sources, sorter=<function SectionConfiguration.<lambda>>)

Convert this sections with its subsections into their report representation.

Parameters:
Return type:

dict[str, Any]

Returns:

Report’s representation of this content.

property have_content: bool
holder_section(level)

Generate a new placeholder’s section configuration for the requested level.

Parameters:

level (int) – Level for which to create the configuration.

Return type:

SectionConfiguration

Returns:

Default SectionConfiguration for the requested level.

id: str = None
initialize(name, dtype, section, report)

Fill missing information from provided properties.

Parameters:
  • name (str) – Section’s data name.

  • dtype (str) – Section’s data type.

  • section (SectionProperties) – Section’s properties.

  • report (ReportProperties) – Report’s properties.

property is_visible: bool

A section is visible if any of its section is visible.

Returns:

Section visibility.

merge(s2)

Merge provided configuration into the current one.

Parameters:

s2 (SectionConfiguration) – Second section to merge.

Returns:

New ReportChapterContent containing both contents.

new_section(path, title, text)

Create a new section inhering current properties.

Parameters:
  • path (str) – Path of the section.

  • title (str) – Title.

  • text (str | None) – Text.

Return type:

SectionConfiguration

Returns:

New section.

property own_section: bool
parameters: dict[str, Any]
property path: SectionPath
path_sections(conf_field, conf_diag, diag_type, freq)

Generate the list of section required to build the path of the current one.

Parameters:
  • conf_field (NamedSectionBase) – Field’s configuration.

  • conf_diag (DiagnosticConfiguration) – Diagnostic configuration.

  • diag_type (str) – Type of diagnostic.

  • freq (FrequencyHandler | None) – Frequency of the diagnostic.

Return type:

list[SectionConfiguration]

Returns:

List of required section.

place_holder: bool = False
properties: SectionProperties
report_properties: ReportProperties
reports: list[str]
section: str | None = None
single_stat_sections(stat)

Create new report’s sections configuration specific to the provided statistic.

Parameters:

stat (str) – Statistic for which to set the configuration.

Return type:

list[SectionConfiguration]

Returns:

Sections required to include the requested statistic.

stats_sections(stats)

Create report’s sections configuration for the provided statistics.

Parameters:

stats (list[str]) – Statistics for which to set the configuration.

Return type:

list[SectionConfiguration]

Returns:

Sections required for the requested statistic.

sub_sections: dict[str, SectionConfiguration]
update_light(section)

Light merging: union of reports.

Parameters:

section (SectionConfiguration) – Section to merge.

update_section(section)

Update current section parameters by the provided one.

Parameters:

section (SectionConfiguration) – Section from which to get new parameters.

validate_report_level()

Validate the properties defined at the report level.

Raises:

ReportConfiguratorError – If text or split_per_diag properties are defined.

class casys.report.configurator.SectionConfigurationSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: SectionBaseSchema

Marshmallow schema for SectionConfiguration.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.report.configurator.SectionOrderType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Different types of section naming policies.

DIAG_FIRST = 3
FIELD_FIRST = 2
NONE = 1
class casys.report.configurator.SectionOrderTypeField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: BaseEnumField

Marshmallow SectionOrderType field.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.report.configurator.SourceConfiguration(reference, source, data_dir=None, store=None, time_extension=None, fields=<factory>, theoretical_orf=None, reference_track=None, name=None, plot_params=None)

Bases: object

Data source specification.

Parameters:
  • reference (str) – Source’s reference name when used in AltiData.

  • source (dict[str, Any]) – Source’s specifications.

  • time_extension (bool | None) – Whether to allow the extension of user defined time interval for specific diagnostic requirements or not.

  • data_dir (Path | str | None) – Directory into which to store data.

  • store (dict[str, str] | None) –

    Storage specifications.

    • store: store path

    • analyse_type: type of analyse (cycle, pass or custom).

    • analyse_date: for custom types, date to tag this analyse with

    • groups: dictionary of diagnostic names and their specific store’s group name

  • fields (dict[str, FieldBase]) – Mission’s fields definition. These field’s parameters will overwrite the ones from the report configuration.

  • theoretical_orf (str | None) – Theoretical orf name or path.

  • reference-track – Reference track name or path.

  • name (str | None) – Name used in multi-mission plots.

  • plot_params (PlotParams | None) – Mission specific plot parameters.

  • reference_track (str | None)

compute(data, diags)

Compute specified diagnostics with the provided AltiData.

Parameters:
  • data (CommonData) – AltiData representing this source.

  • diags (list[str] | None) –

    List of diagnostics to compute.

    • None: All diagnostics are computed.

    • []: No diagnostics are computed.

    • [‘x’, ‘y’]: x and y diagnostics are computed.

compute_custom_diag(data, section, diag_ref)

Compute provided custom diagnostic.

Parameters:
  • data (list[CommonData]) – List of computed AltiData available to the diagnostic.

  • section (ReportSection) – Report’s section containing the custom diagnostic specifications.

  • diag_ref (str) – Reference of the custom diagnostic.

compute_dask(data, diags, parameters)

Compute specified diagnostics using dask with the provided AltiData.

Parameters:
  • data (CommonData) – AltiData representing this source.

  • diags (list[str] | None) –

    List of diagnostics to compute.

    • None: All diagnostics are computed.

    • []: No diagnostics are computed.

    • [‘x’, ‘y’]: x and y diagnostics are computed.

  • parameters (dict[str, Any]) – Dask parameters to use for computation.

data_dir: Path | str | None = None
property data_file: str | None

Path of the pickled AltiData for this source.

data_path(name)

Generate the data path for the provided name.

Parameters:

name (str) – Data’s name.

Return type:

str | None

Returns:

Data path for the provided name.

fields: dict[str, FieldBase]
ges_table_dir: str | None = None
property is_automatic: bool

Test whether this source automatically add its own diagnostics or not.

property is_store: bool

Test whether this source is a stored source or not.

name: str | None = None
plot_params: PlotParams | None = None
reference: str
reference_track: str | None = None
report_configuration()

Source representation in a report only configuration.

Return type:

dict[str, Any]

set_environment()

Set source required environment variables.

set_plot_params(data, mtype)
Parameters:
source: dict[str, Any]
store: dict[str, str] | None = None
store_diagnostic_pickle(diag, diag_ref)

Store provided diagnostic as a pickle file. Nothing is done if this source’s data_file is not defined.

Parameters:
store_diagnostics(data)

Store provided data in a diagnostic store. Nothing is done if this source’s store is not defined.

Parameters:

data (CommonData) – Data to store.

store_pickle(data)

Store provided data as a pickle file. Nothing is done if this source’s data_file is not defined.

Parameters:

data (CommonData) – Data to store.

theoretical_orf: str | None = None
time_extension: bool | None = None
class casys.report.configurator.SourceConfigurationSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

SourceConfiguration’s marshmallow schema.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

casys.report.configurator.set_diag_name(param, diag_type, field_name)

Create a diagnostic name if not included in provided parameters.

‘param’ parameter might be modified.

Parameters:
  • param (dict[str, Any]) – Parameters in which to add the diagnostic name.

  • diag_type (str) – Diagnostic type.

  • field_name (str) – Field on which the diagnostic is applied.