o
    -wi                      @  sd   d dl mZ d dlmZ d dlmZ d dlZeG dd dZeG dd dZ			ddddZ	dS )    )annotations)	dataclass)AnyNc                   @  st   e Zd ZU ded< ded< ded< dZded< dZded	< d
Zded< edddZedddZ	edddZ
dS )CustomChartSpecstr	spec_namedict[str, Any]fieldsstring_fields keyVega2
panel_typeFboolsplit_tablereturnc                 C  s0   | j std| jrd| j  dS | j  dS )Nz)Key for the custom chart spec is not set.zCustom Chart Tables/_table)r   wandbErrorr   self r   T/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/plot/custom_chart.py	table_key   s
   
zCustomChartSpec.table_keyc                 C  sd   | j | j| j| jddidddddgdg ddg dd	g dd
d| jdgg dgdgiddS )NnametableWithLeafColNamesqueryFieldsrunSetsz
${runSets})r   valueid)r   r	   _defaultColorIndexsummaryTabletableKey)r   argsr	   )
panelDefIdfieldSettingsstringSettings	transform	userQuery)r   panel_config)r   r   r	   r
   r   r   r   r   r   config_value   s0   
zCustomChartSpec.config_valuetuple[str, str, str]c                 C  s   dd| j fS )N_wandb	visualize)r   r   r   r   r   
config_key=      zCustomChartSpec.config_keyN)r   r   )r   r   )r   r+   )__name__
__module____qualname____annotations__r   r   r   propertyr   r*   r.   r   r   r   r   r   	   s   
 "r   c                   @  s(   e Zd ZU ded< ded< d
ddZd	S )CustomChartwandb.Tabletabler   specr   r   c                 C  s   || j _dS )z?Sets the key for the spec and updates dependent configurations.N)r8   r   )r   r   r   r   r   set_keyG   r/   zCustomChart.set_keyN)r   r   )r0   r1   r2   r3   r9   r   r   r   r   r5   B   s   
 r5   Fvega_spec_namer   
data_tabler6   r	   r   r
   dict[str, Any] | Noner   r   r   c                 C  s>   t |tjstdt|j t|t| ||pi |ddS )ax  Creates a custom charts using a Vega-Lite specification and a `wandb.Table`.

    This function creates a custom chart based on a Vega-Lite specification and
    a data table represented by a `wandb.Table` object. The specification needs
    to be predefined and stored in the W&B backend. The function returns a custom
    chart object that can be logged to W&B using `wandb.log()`.

    Args:
        vega_spec_name (str): The name or identifier of the Vega-Lite spec
            that defines the visualization structure.
        data_table (wandb.Table): A `wandb.Table` object containing the data to be
            visualized.
        fields (dict[str, Any]): A mapping between the fields in the Vega-Lite spec and the
            corresponding columns in the data table to be visualized.
        string_fields (dict[str, Any] | None): A dictionary for providing values for any string constants
            required by the custom visualization.
        split_table (bool): Whether the table should be split into a separate section
            in the W&B UI. If `True`, the table will be displayed in a section named
            "Custom Chart Tables". Default is `False`.

    Returns:
        CustomChart: A custom chart object that can be logged to W&B. To log the
            chart, pass it to `wandb.log()`.

    Raises:
        wandb.Error: If `data_table` is not a `wandb.Table` object.
    z<Expected `data_table` to be `wandb.Table` type, instead got )r   r	   r
   r   )r7   r8   )
isinstancer   Tabler   typer0   r5   r   )r:   r;   r	   r
   r   r   r   r   
plot_tableL   s   #r@   )NF)r:   r   r;   r6   r	   r   r
   r<   r   r   r   r5   )

__future__r   dataclassesr   typingr   r   r   r5   r@   r   r   r   r   <module>   s    8