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[source]

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: List[str] | None = None, exclude_private_fields: bool = True)[source]

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)[source]

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][source]

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

Returns:

Default tags which is idmtools version

idmtools.utils.entities.save_id_as_file_as_hook(item: Experiment | IWorkflowItem, platform: IPlatform)[source]

Predefined hook that will save ids to files for Experiment or WorkItems.

Parameters:
  • item

  • platform

Returns:

None