idmtools.utils.entities module

utilities for dataclasses.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

idmtools.utils.entities.get_dataclass_common_fields(src, dest, exclude_none: bool = True) Dict

Extracts fields from a dataclass source object who are also defined on destination object.

Useful for situations like nested configurations of data class options.

Parameters:
  • src – Source dataclass object

  • dest – Dest dataclass object

  • exclude_none – When true, values of None will be excluded

Returns:

Dictionary of common fields between source and destination object

idmtools.utils.entities.as_dict(src, exclude: Optional[List[str]] = None, exclude_private_fields: bool = True)

Converts a dataclass to a dict while also obeys rules for exclusion.

Parameters:
  • src

  • exclude – List of fields to exclude

  • exclude_private_fields – Should fields that star

Returns:

Data class as dict

idmtools.utils.entities.validate_user_inputs_against_dataclass(field_type, field_value)

Validates user entered data against dataclass fields and types.

Parameters:
  • field_type – Field type

  • field_value – Fields value

Returns:

Validates user values

idmtools.utils.entities.get_default_tags() Dict[str, str]

Get common default tags. Currently this is the version of idmtools.

Returns:

Default tags which is idmtools version