Skip to content

manager_formulas

manager_formulas

Formulas manager for DomoDataset.

Provides access to beast mode (calculated field) templates that are persisted on a dataset — i.e., beast modes saved to the dataset level rather than defined on individual cards.

These dataset-level beast modes are referenced by their calculation_xxx legacy ID in card definitions but their formula text and column references live in the template API (/api/query/v1/functions/template/{id}).

Usage

await dataset.Formulas.get() dataset.Formulas.beast_modes # list[DomoBeastMode] dataset.Formulas.resolve_calculation_id("calculation_xxx") # BeastModeTemplate | None

DomoDataset_FormulasManager dataclass

DomoDataset_FormulasManager(
    parent: DomoEntity,
    beast_modes: list[DomoBeastMode] = list(),
)

Bases: DomoSubEntity

Manager for beast modes persisted on a dataset.

Provides typed access to dataset-level beast modes and resolution of calculation IDs used in card definitions.

Usage

await dataset.Formulas.get() dataset.Formulas.beast_modes # list[DomoBeastMode] dataset.Formulas.resolve_calculation_id("calculation_xxx")

formula_by_legacy_id property

formula_by_legacy_id: dict[str, BeastModeTemplate]

Lookup dict of templates by their legacy calculation ID.

get async

get(
    include_hidden: bool = False,
    is_resolve_domo_beast_mode_refs: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[DomoBeastMode]

Fetch beast modes saved to this dataset.

Retrieves the list of beast modes linked to this dataset, then optionally fetches each template definition.

Parameters:

Name Type Description Default
include_hidden bool

Fetch template definitions with ?hidden=true

False
is_resolve_domo_beast_mode_refs bool

Also resolve DOMO_BEAST_MODE(nnn) references in expressions by fetching the referenced templates

False
context RouteContext | None

Optional RouteContext for request configuration

None

Returns:

Type Description
list[DomoBeastMode]

List of DomoBeastMode instances with populated templates.

Source code in src/crew_dcs/classes/DomoDataset/manager_formulas.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
async def get(
    self,
    include_hidden: bool = False,
    is_resolve_domo_beast_mode_refs: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[DomoBeastMode]:
    """Fetch beast modes saved to this dataset.

    Retrieves the list of beast modes linked to this dataset,
    then optionally fetches each template definition.

    Args:
        include_hidden: Fetch template definitions with ?hidden=true
        is_resolve_domo_beast_mode_refs: Also resolve ``DOMO_BEAST_MODE(nnn)``
            references in expressions by fetching the referenced templates
        context: Optional RouteContext for request configuration

    Returns:
        List of DomoBeastMode instances with populated templates.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    bm_manager = DomoBeastModes(auth=self.auth)
    self.beast_modes = await bm_manager.get_by_dataset(
        dataset_id=self.parent.id,
        context=context,
    )

    # Fetch template definitions for each beast mode
    if include_hidden or self.beast_modes:
        for bm in self.beast_modes:
            try:
                await bm.Template.get(
                    include_hidden=include_hidden,
                    context=context,
                )
                # Resolve DOMO_BEAST_MODE refs if requested
                if is_resolve_domo_beast_mode_refs and bm.Template.template:
                    await bm.Template.template.resolve_domo_beast_mode_refs(
                        auth=self.auth,
                        context=context,
                    )
            except Exception:  # noqa: BLE001
                # Skip templates that fail to load
                pass

    return self.beast_modes

resolve_calculation_id

resolve_calculation_id(
    calculation_id: str,
) -> BeastModeTemplate | None

Resolve a calculation_xxx ID to its template definition.

Card definitions reference dataset-level beast modes by their legacyId (e.g., "calculation_628752ca-a54d-44c6-a24f-4f4b45c049ff"). This method looks up the template by that ID.

Parameters:

Name Type Description Default
calculation_id str

The calculation_xxx legacy ID

required

Returns:

Type Description
BeastModeTemplate | None

BeastModeTemplate if found, None otherwise

Source code in src/crew_dcs/classes/DomoDataset/manager_formulas.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
def resolve_calculation_id(self, calculation_id: str) -> BeastModeTemplate | None:
    """Resolve a calculation_xxx ID to its template definition.

    Card definitions reference dataset-level beast modes by their
    legacyId (e.g., "calculation_628752ca-a54d-44c6-a24f-4f4b45c049ff").
    This method looks up the template by that ID.

    Args:
        calculation_id: The calculation_xxx legacy ID

    Returns:
        BeastModeTemplate if found, None otherwise
    """
    for bm in self.beast_modes:
        if bm.Template and bm.Template.template:  # noqa: SIM102
            if bm.Template.template.legacy_id == calculation_id:
                return bm.Template.template
    return None