Skip to content

base_converter

base_converter

Shared base implementation for OSI semantic converters.

OsiConverter

Bases: SemanticConverter

Base class providing shared column-classification and build helpers.

Both DataModelConverter and DsvConverter inherit from this class. Subclasses must implement convert().

export_to_file

export_to_file(
    output: list[OsiSemanticModel],
    file_path: str,
    format: str = "yaml",
    **options
) -> None

Export list of OsiSemanticModels to YAML or JSON.

Parameters:

Name Type Description Default
output list[OsiSemanticModel]

Models from convert()

required
file_path str

Destination path

required
format str

"yaml" (default) or "json"

'yaml'
Source code in src/crew_dcs/integrations/osi/base_converter.py
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def export_to_file(
    self,
    output: list[OsiSemanticModel],
    file_path: str,
    format: str = "yaml",
    **options,
) -> None:
    """Export list of OsiSemanticModels to YAML or JSON.

    Args:
        output: Models from convert()
        file_path: Destination path
        format: "yaml" (default) or "json"
    """
    data = [m.to_dict() for m in output]
    os.makedirs(os.path.dirname(os.path.abspath(file_path)), exist_ok=True)
    with open(file_path, "w", encoding="utf-8") as f:
        if format == "json":
            json.dump(data, f, indent=2)
        else:
            yaml.dump(data, f, default_flow_style=False, allow_unicode=True)

UnresolvedBeastModeReferenceError

Bases: ValueError

Raised when a Beast Mode's DOMO_BEAST_MODE() reference can't be resolved.

Emitting an OSI metric with a dangling DOMO_BEAST_MODE(nnn) token would ship an expression that means nothing outside Domo. Callers must resolve refs via BeastModeTemplate.resolve_domo_beast_mode_refs() before converting — this error means that either wasn't done, or the resolution attempt itself failed to reach every referenced template.