MCPcopy
hub / github.com/Kanaries/pygwalker / get_component

Function get_component

pygwalker/api/reflex.py:19–62  ·  view source on GitHub ↗

Get a Reflex component that renders Pygwalker.

(
    dataset: Union[DataFrame, Connector],
    gid: Union[int, str] = None,
    *,
    field_specs: Optional[List[FieldSpec]] = None,
    theme_key: IThemeKey = "g2",
    appearance: IAppearance = "media",
    spec: str = "",
    spec_io_mode: ISpecIOMode = "r",
    kernel_computation: Optional[bool] = None,
    kanaries_api_key: str = "",
    default_tab: Literal["data", "vis"] = "vis",
    **kwargs,
)

Source from the content-addressed store, hash-verified

17# pylint: disable=protected-access
18
19def get_component(
20 dataset: Union[DataFrame, Connector],
21 gid: Union[int, str] = None,
22 *,
23 field_specs: Optional[List[FieldSpec]] = None,
24 theme_key: IThemeKey = "g2",
25 appearance: IAppearance = "media",
26 spec: str = "",
27 spec_io_mode: ISpecIOMode = "r",
28 kernel_computation: Optional[bool] = None,
29 kanaries_api_key: str = "",
30 default_tab: Literal["data", "vis"] = "vis",
31 **kwargs,
32) -> rx.Component:
33 """Get a Reflex component that renders Pygwalker."""
34 check_expired_params(kwargs)
35
36 walker = PygWalker(
37 gid=gid,
38 dataset=dataset,
39 field_specs=field_specs if field_specs is not None else [],
40 spec=spec,
41 source_invoke_code="",
42 theme_key=theme_key,
43 appearance=appearance,
44 show_cloud_tool=False,
45 use_preview=False,
46 kernel_computation=isinstance(dataset, Connector) or kernel_computation,
47 use_save_tool="w" in spec_io_mode,
48 is_export_dataframe=False,
49 kanaries_api_key=kanaries_api_key,
50 default_tab=default_tab,
51 cloud_computation=False,
52 gw_mode="explore",
53 **kwargs,
54 )
55
56 props = walker._get_props("reflex")
57 props["communicationUrl"] = BASE_URL_PATH
58 comm = ReflexCommunication(str(walker.gid))
59 walker._init_callback(comm)
60
61 html = walker._get_render_iframe(props, True)
62 return rx.html(html)

Callers 1

pygwalker_demoFunction · 0.90

Calls 7

_get_propsMethod · 0.95
_init_callbackMethod · 0.95
_get_render_iframeMethod · 0.95
check_expired_paramsFunction · 0.90
ReflexCommunicationClass · 0.90
PygWalkerClass · 0.85
htmlMethod · 0.80

Tested by

no test coverage detected