contract.utils¶
print_data_stream_tree ¶
print_data_stream_tree(
node: DataStream,
prefix: str = "",
is_last: bool = True,
parents: list[bool] = [],
show_params: bool = False,
show_type: bool = False,
show_missing_indicator: bool = True,
) -> str
Generates a tree representation of a data stream hierarchy.
Creates a formatted string displaying the hierarchical structure of a data stream and its children as a tree with branch indicators and icons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DataStream
|
The data stream node to start printing from. |
required |
prefix
|
str
|
Prefix string to prepend to each line, used for indentation. |
''
|
is_last
|
bool
|
Whether this node is the last child of its parent. |
True
|
parents
|
list[bool]
|
List tracking whether each ancestor was a last child, used for drawing branches. |
[]
|
show_params
|
bool
|
Whether to render parameters of the datastream. |
False
|
show_type
|
bool
|
Whether to render the class name of the datastream. |
False
|
show_missing_indicator
|
bool
|
Whether to render the missing data indicator. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A formatted string representing the data stream tree. |
Examples:
from contraqctor.contract import Dataset, csv, json
from contraqctor.contract.utils import print_data_stream_tree
csv_stream = csv.Csv("data", reader_params=csv.CsvParams(path="data.csv"))
json_stream = json.Json("config", reader_params=json.JsonParams(path="config.json"))
dataset = Dataset("experiment", [csv_stream, json_stream], version="1.0.0")
tree = print_data_stream_tree(dataset)
print(tree)
Source code in src/contraqctor/contract/utils.py
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 | |
print_data_stream_tree_html ¶
print_data_stream_tree_html(
node: DataStream,
is_last: bool = True,
parents: list[bool] | None = None,
show_params: bool = False,
show_type: bool = False,
show_missing_indicator: bool = True,
) -> str
Generates an HTML tree representation of a data stream hierarchy with tooltips.
Creates a formatted HTML string displaying the hierarchical structure of a data stream and its children as a tree with branch indicators, icons, and tooltips showing descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DataStream
|
The data stream node to start printing from. |
required |
is_last
|
bool
|
Whether this node is the last child of its parent. |
True
|
parents
|
list[bool] | None
|
List tracking whether each ancestor was a last child, used for drawing branches. |
None
|
show_params
|
bool
|
Whether to render parameters of the datastream. |
False
|
show_type
|
bool
|
Whether to render the class name of the datastream. |
False
|
show_missing_indicator
|
bool
|
Whether to render the missing data indicator. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A formatted HTML string representing the data stream tree with tooltips. |
Examples:
from contraqctor.contract import Dataset, csv, json
from contraqctor.contract.utils import print_data_stream_tree_html
csv_stream = csv.Csv("data", reader_params=csv.CsvParams(path="data.csv"))
json_stream = json.Json("config", reader_params=json.JsonParams(path="config.json"))
dataset = Dataset("experiment", [csv_stream, json_stream], version="1.0.0")
html = print_data_stream_tree_html(dataset)
with open("tree.html", "w") as f:
f.write(html)
Source code in src/contraqctor/contract/utils.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |