MCPcopy Create free account
hub / github.com/PAIR-code/lit / RenderConfig

Class RenderConfig

lit_nlp/notebook.py:61–87  ·  view source on GitHub ↗

Config options for widget rendering.

Source from the content-addressed store, hash-verified

59
60@attr.s(auto_attribs=True, kw_only=True)
61class RenderConfig(object):
62 """Config options for widget rendering."""
63 tab: Optional[str] = None
64 upper_tab: Optional[str] = None
65 layout: Optional[str] = None
66 dataset: Optional[str] = None
67 models: Optional[Sequence[str]] = None
68 datapoints: Optional[Sequence[JsonDict]] = None
69
70 def get_query_str(self):
71 """Convert config object to query string for LIT URL."""
72 def _encode(v):
73 if isinstance(v, (list, tuple)):
74 return ','.join(v)
75 return v
76
77 string_params = {
78 k: _encode(v)
79 for k, v in attr.asdict(self).items()
80 if (v is not None and k != 'datapoints')
81 }
82 if self.datapoints:
83 for i, ex in enumerate(self.datapoints):
84 for field in ex:
85 string_params[f'data{i}_{field}'] = _encode(ex[field])
86
87 return '?' + urllib.parse.urlencode(string_params)
88
89
90class LitWidget(object):

Callers 1

renderMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected