Skip to content

manager_dataset

manager_dataset

Dataset manager for DomoCard.

DomoCard_DatasetsManager dataclass

DomoCard_DatasetsManager(
    auth: DomoAuth,
    parent: DomoCard_Default = None,
    datasets: list[Any] = list(),
)

Bases: DomoManager

Manager for datasets associated with a DomoCard.

Provides access to all datasets used by a card through its datasources. Inherits from DomoManager to follow standard entity manager patterns.

get async

get(
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    parent_auth_retrieval_fn: (
        Callable[[str], Any] | None
    ) = None,
    **context_kwargs
) -> list[Any]

Get all datasets associated with this card.

This retrieves datasets from the card's datasources and returns DomoDataset instances for each one.

Parameters:

Name Type Description Default
debug_api bool

Enable API debugging

False
session AsyncClient | None

Optional httpx session for request reuse

None

Returns:

Type Description
list[Any]

list[DomoDataset]: List of dataset objects associated with the card

Source code in src/crew_dcs/classes/DomoCard/manager_dataset.py
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 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
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
async def get(
    self,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    parent_auth_retrieval_fn: Callable[[str], Any] | None = None,
    **context_kwargs,
) -> list[Any]:  # Returns list[DomoDataset]
    """Get all datasets associated with this card.

    This retrieves datasets from the card's datasources and returns
    DomoDataset instances for each one.

    Args:
        debug_api: Enable API debugging
        session: Optional httpx session for request reuse

    Returns:
        list[DomoDataset]: List of dataset objects associated with the card
    """
    from ..DomoDataset import DomoDataset

    context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=1,
        **context_kwargs,
    )
    # Get datasources from card metadata if not already loaded
    if not self.parent.raw.get("datasources"):
        # Reload card with datasources
        res = await card_routes.get_card_metadata(
            auth=self.auth,
            card_id=self.parent.id,
            optional_parts="datasources",
            context=context,
        )
        self.parent.raw = res.response

    datasources = self.parent.raw.get("datasources", [])

    if not datasources:
        return []

    # Get dataset IDs from datasources
    dataset_ids = [
        ds.get("dataSourceId") for ds in datasources if ds.get("dataSourceId")
    ]

    if not dataset_ids:
        return []

    # Fetch all datasets concurrently
    # Auto-enable publish check and lineage tracing when parent_auth_retrieval_fn is provided
    datasets = await dmce.gather_with_concurrency(
        *[
            DomoDataset.get_by_id(
                auth=self.auth,
                dataset_id=dataset_id,
                check_if_published=bool(parent_auth_retrieval_fn),
                parent_auth_retrieval_fn=parent_auth_retrieval_fn,
                context=context,
            )
            for dataset_id in dataset_ids
        ],
        n=60,
    )

    self.datasets = datasets
    return datasets