grai_source_metabase
adapters

build_grai_metadata

@multimethod
def build_grai_metadata(current: Any, desired: Any) -> None

Build grai metadata for a given object.

Arguments:

  • current - The object to build grai metadata from.
  • desired - The desired format of the metadata.

Returns:

  • None - grai metadata object.

Raises:

  • NotImplementedError - If no adapter is available between the current and desired types.

build_grai_metadata_from_table

@build_grai_metadata.register
def build_grai_metadata_from_table(current: Column,
                                   version: Literal["v1"] = "v1"
                                   ) -> ColumnMetadata

Build grai metadata for a Table object.

Arguments:

  • current - The Table object to build grai metadata from.
  • version - The version of grai metadata to build. Defaults to "v1".

Returns:

  • TableMetadata - grai metadata object for the Table.

Raises:

None.

build_grai_metadata_from_table

@build_grai_metadata.register
def build_grai_metadata_from_table(current: Table,
                                   version: Literal["v1"] = "v1"
                                   ) -> TableMetadata

Build grai metadata for a Table object.

Arguments:

  • current - The Table object to build grai metadata from.
  • version - The version of grai metadata to build. Defaults to "v1".

Returns:

  • TableMetadata - grai metadata object for the Table.

Raises:

None.

build_grai_metadata_from_question

@build_grai_metadata.register
def build_grai_metadata_from_question(current: Question,
                                      version: Literal["v1"] = "v1"
                                      ) -> QueryMetadata

Build grai metadata for a Question object.

Arguments:

  • current Question - The Question object to build grai metadata from.
  • version Literal["v1"], optional - The version of grai metadata to build. Defaults to "v1".

Returns:

  • GenericNodeMetadataV1 - grai metadata object for the Question.

Raises:

None.

build_grai_metadata_from_collection

@build_grai_metadata.register
def build_grai_metadata_from_collection(
        current: Collection,
        version: Literal["v1"] = "v1") -> CollectionMetadata

Build grai metadata for a Collection object.

Arguments:

  • current - The Collection object to build grai metadata from.
  • version - The version of grai metadata to build. Defaults to "v1".

Returns:

  • GenericNodeMetadataV1 - grai metadata object for the Collection.

build_grai_metadata_from_edge

@build_grai_metadata.register
def build_grai_metadata_from_edge(current: Edge,
                                  version: Literal["v1"] = "v1"
                                  ) -> GenericEdgeMetadataV1

Build grai metadata for an Edge object.

Arguments:

  • current - The Edge object to build grai metadata from.
  • version - The version of grai metadata to build. Defaults to "v1".

Returns:

  • GenericEdgeMetadataV1 - grai metadata object for the Edge.

Raises:

None.

build_app_metadata

@multimethod
def build_app_metadata(current: Any, desired: Any) -> None

Build application-specific metadata for a given object.

Arguments:

  • current - The object to build application-specific metadata from.
  • desired - The desired format of the metadata.

Returns:

  • None - Application-specific metadata object.

Raises:

  • NotImplementedError - If no adapter is available between the current and desired types.

build_metadata_from_table

@build_app_metadata.register
def build_metadata_from_table(current: BaseModel,
                              version: Literal["v1"] = "v1") -> Dict

Build application-specific metadata for a Table object.

Arguments:

  • current - The Table object to build application-specific metadata from.
  • version - The version of the metadata to build. Defaults to "v1".

Returns:

  • Dict - Application-specific metadata object for the Table.

Raises:

None.

build_metadata_from_edge

@build_app_metadata.register
def build_metadata_from_edge(current: Edge,
                             version: Literal["v1"] = "v1") -> Dict

Build application-specific metadata for an Edge object.

Arguments:

  • current Edge - The Edge object to build application-specific metadata from.
  • version Literal["v1"], optional - The version of the metadata to build. Defaults to "v1".

Returns:

  • Dict - Application-specific metadata object for the Edge.

Raises:

None.

build_metadata

def build_metadata(obj, version) -> Dict[str, Dict]

Build metadata for a given object.

Arguments:

  • obj - The object to build metadata from.
  • version - The version of the metadata to build.

Returns:

  • Dict - Metadata object containing both grai and application-specific metadata.

Raises:

None.

adapt_to_client

@multimethod
def adapt_to_client(current: Any, desired: Any)

Adapt a given object to the desired client format.

Arguments:

  • current Any - The object to adapt.
  • desired Any - The desired format to adapt to.

Returns:

  • None - Adapted object in the desired format.

Raises:

  • NotImplementedError - If no adapter is available between the current and desired types.

adapt_table_to_client

@adapt_to_client.register
def adapt_table_to_client(current: Union[Table, Column],
                          source: SourceSpec,
                          version: Literal["v1"] = "v1") -> SourcedNodeV1

Adapt a Table object to the desired client format.

Arguments:

  • current - The Table object to adapt.
  • source - The Source associated with the Table
  • version - The version of the client format to adapt to. Defaults to "v1".

Returns:

  • NodeV1 - Adapted Table object in the desired client format.

Raises:

None.

adapt_question_to_client

@adapt_to_client.register
def adapt_question_to_client(current: Question,
                             source: SourceSpec,
                             version: Literal["v1"] = "v1") -> SourcedNodeV1

Adapt a Question object to the desired client format.

Arguments:

  • current - The Question object to adapt.
  • source - The source associated with the Question
  • version - The version of the client format to adapt to. Defaults to "v1".

Returns:

  • NodeV1 - Adapted Question object in the desired client format.

Raises:

None.

adapt_collection_to_client

@adapt_to_client.register
def adapt_collection_to_client(current: Collection,
                               source: SourceSpec,
                               version: Literal["v1"] = "v1") -> SourcedNodeV1

Adapt a Collection object to the desired client format.

Arguments:

current: source: version:

make_name

def make_name(node1: NodeTypes, node2: NodeTypes) -> str

Creates a name for an edge based on the given nodes.

Arguments:

node1 (NodeTypes) node2 (NodeTypes)

Returns:

  • str - The name of the edge.

Raises:

None.

adapt_edge_to_client

@adapt_to_client.register
def adapt_edge_to_client(current: Edge,
                         source: SourceSpec,
                         version: Literal["v1"] = "v1") -> SourcedEdgeV1

Adapt an Edge object to the desired client format.

Arguments:

  • current - The Edge object to adapt.
  • source - The data source associated with the Edge
  • version - The version of the client format to adapt to. Defaults to "v1".

Returns:

  • EdgeV1 - Adapted Edge object in the desired client format.

Raises:

None.

adapt_seq_to_client

@adapt_to_client.register
def adapt_seq_to_client(objs: Sequence, source: SourceSpec,
                        version: Literal["v1"]) -> List[T]

Adapt a sequence of objects to the desired client format.

Arguments:

  • objs - The sequence of objects to adapt.
  • source - The source associated with each object in objs
  • version - The version of the client format to adapt to.

Returns:

List[Union[NodeV1, EdgeV1]]: Adapted sequence of objects in the desired client format.

Raises:

None.

adapt_list_to_client

@adapt_to_client.register
def adapt_list_to_client(objs: List, source: SourceSpec,
                         version: Literal["v1"]) -> List[T]

Adapt a list of objects to the desired client format.

Arguments:

  • objs - The list of objects to adapt.
  • source - The source associated with each object in objs
  • version - The version of the client format to adapt to.

Returns:

List[Union[NodeV1, EdgeV1]]: Adapted list of objects in the desired client format.

Raises:

None.

adapt_source_v1_to_client

@adapt_to_client.register
def adapt_source_v1_to_client(objs: Any, source: SourceV1,
                              version: Any) -> List[T]

Adapt a list of objects to the desired client format.

Arguments:

  • objs - The list of objects to adapt.
  • source - The source associated with each object in objs
  • version - The version of the client format to adapt to.

Returns:

List[Union[NodeV1, EdgeV1]]: Adapted list of objects in the desired client format.

Raises:

None.