def _render_expectation_types(cls, evrs, content_blocks):
        # NOTE: The evr-fetching function is an kinda similar to the code other_section_
        # renderer.ProfilingResultsOverviewSectionRenderer._render_expectation_types

        # type_counts = defaultdict(int)

        # for evr in evrs:
        #     type_counts[evr.expectation_config.expectation_type] += 1

        # bullet_list = sorted(type_counts.items(), key=lambda kv: -1*kv[1])

        bullet_list = [{
            "content_block_type": "string_template",
            "string_template": {
                "template": "$expectation_type $is_passing",
                "params": {
                    "expectation_type": evr.expectation_config.expectation_type,
                    "is_passing": str(evr.success),
                },
                "styling": {
                    "classes": ["list-group-item", "d-flex", "justify-content-between", "align-items-center"],
                    "params": {
                        "is_passing": {
                            "classes": ["badge", "badge-secondary", "badge-pill"],
                        }
                    },
                }
            }
        } for evr in evrs]

        content_blocks.append(RenderedBulletListContent(**{
            "content_block_type": "bullet_list",
            "header": RenderedStringTemplateContent(**{
                "content_block_type": "string_template",
                "string_template": {
                    "template": 'Expectation types <span class="mr-3 triangle"></span>',
                    "tag": "h6"
                }
            }),
            "bullet_list": bullet_list,
            "styling": {
                "classes": ["col-12", "mt-1"],
                "header": {
                    "classes": ["collapsed"],
                    "attributes": {
                        "data-toggle": "collapse",
                        "href": "#{{content_block_id}}-body",
                        "role": "button",
                        "aria-expanded": "true",
                        "aria-controls": "collapseExample",
                    },
                    "styles": {
                        "cursor": "pointer",
                    }
                },
                "body": {
                    "classes": ["list-group", "collapse"],
                },
            },
        }))
예제 #2
0
 def _get_bullet_list_content_block(cls, header="", subheader="", col=12):
     return RenderedBulletListContent(
         **{
             "content_block_type":
             "bullet_list",
             "header":
             header,
             "subheader":
             subheader,
             "bullet_list": [
                 "Aenean porttitor turpis.",
                 "Curabitur ligula urna.",
                 cls._get_header_content_block(
                     header="nested header content block",
                     subheader="subheader",
                     highlight=False,
                 ),
             ],
             "styling": {
                 "classes": [f"col-{col}"],
                 "styles": {
                     "margin-top": "20px"
                 },
             },
         })
    def _render_expectation_types(cls, evrs, content_blocks) -> None:

        type_counts = defaultdict(int)

        for evr in evrs.results:
            type_counts[evr.expectation_config.expectation_type] += 1

        bullet_list_items = sorted(type_counts.items(),
                                   key=lambda kv: -1 * kv[1])

        bullet_list_items = [
            RenderedStringTemplateContent(
                **{
                    "content_block_type": "string_template",
                    "string_template": {
                        "template": "$expectation_type $expectation_count",
                        "params": {
                            "expectation_type": tr[0],
                            "expectation_count": tr[1],
                        },
                        "styling": {
                            "classes": [
                                "list-group-item",
                                "d-flex",
                                "justify-content-between",
                                "align-items-center",
                            ],
                            "params": {
                                "expectation_count": {
                                    "classes": [
                                        "badge",
                                        "badge-secondary",
                                        "badge-pill",
                                    ],
                                }
                            },
                        },
                    },
                    "styling": {
                        "parent": {
                            "styles": {
                                "list-style-type": "none"
                            }
                        }
                    },
                }) for tr in bullet_list_items
        ]

        bullet_list = RenderedBulletListContent(
            **{
                "content_block_type": "bullet_list",
                "bullet_list": bullet_list_items,
                "styling": {
                    "classes": ["col-12", "mt-1"],
                    "body": {
                        "classes": ["list-group"],
                    },
                },
            })

        bullet_list_collapse = CollapseContent(
            **{
                "collapse_toggle_link": "Show Expectation Types...",
                "collapse": [bullet_list],
                "styling": {
                    "classes": ["col-12", "p-1"]
                },
            })

        content_blocks.append(bullet_list_collapse)
예제 #4
0
    def _generate_links_table_rows(cls, index_links_dict,
                                   link_list_keys_to_render):
        section_rows = []

        column_count = len(link_list_keys_to_render)
        validations_links = index_links_dict.get("validations_links")
        expectations_links = index_links_dict.get("expectations_links")

        if column_count:
            cell_width_pct = 100.0 / column_count

        if "expectations_links" in link_list_keys_to_render:
            for expectation_suite_link_dict in expectations_links:
                expectation_suite_row = []
                expectation_suite_name = expectation_suite_link_dict[
                    "expectation_suite_name"]

                expectation_suite_link = RenderedStringTemplateContent(
                    **{
                        "content_block_type": "string_template",
                        "string_template": {
                            "template": "$link_text",
                            "params": {
                                "link_text": expectation_suite_name
                            },
                            "tag": "a",
                            "styling": {
                                "attributes": {
                                    "href":
                                    expectation_suite_link_dict["filepath"]
                                },
                                "classes":
                                ["ge-index-page-table-expectation-suite-link"]
                            }
                        },
                        "styling": {
                            "parent": {
                                "styles": {
                                    "width": "{}%".format(cell_width_pct),
                                }
                            }
                        }
                    })
                expectation_suite_row.append(expectation_suite_link)

                if "validations_links" in link_list_keys_to_render:
                    sorted_validations_links = [
                        link_dict
                        for link_dict in sorted(validations_links,
                                                key=lambda x: x["run_id"],
                                                reverse=True)
                        if link_dict["expectation_suite_name"] ==
                        expectation_suite_name
                    ]
                    validation_link_bullets = [
                        RenderedStringTemplateContent(
                            **{
                                "content_block_type": "string_template",
                                "string_template": {
                                    "template":
                                    "${validation_success} $link_text",
                                    "params": {
                                        "link_text": link_dict["run_id"],
                                        "validation_success": ""
                                    },
                                    "tag": "a",
                                    "styling": {
                                        "attributes": {
                                            "href": link_dict["filepath"]
                                        },
                                        "params": {
                                            "validation_success": {
                                                "tag":
                                                "i",
                                                "classes": [
                                                    "fas", "fa-check-circle",
                                                    "text-success"
                                                ] if
                                                link_dict["validation_success"]
                                                else [
                                                    "fas", "fa-times",
                                                    "text-danger"
                                                ]
                                            }
                                        },
                                        "classes": [
                                            "ge-index-page-table-validation-links-item"
                                        ]
                                    }
                                },
                                "styling": {
                                    "parent": {
                                        "classes":
                                        ["hide-succeeded-validation-target"]
                                        if link_dict["validation_success"] else
                                        []
                                    }
                                }
                            }) for link_dict in sorted_validations_links
                        if link_dict["expectation_suite_name"] ==
                        expectation_suite_name
                    ]
                    validation_link_bullet_list = RenderedBulletListContent(
                        **{
                            "content_block_type": "bullet_list",
                            "bullet_list": validation_link_bullets,
                            "styling": {
                                "parent": {
                                    "styles": {
                                        "width": "{}%".format(cell_width_pct)
                                    }
                                },
                                "body": {
                                    "classes": [
                                        "ge-index-page-table-validation-links-list"
                                    ]
                                }
                            }
                        })
                    expectation_suite_row.append(validation_link_bullet_list)

                section_rows.append(expectation_suite_row)

        if not expectations_links and "validations_links" in link_list_keys_to_render:
            sorted_validations_links = [
                link_dict for link_dict in sorted(
                    validations_links, key=lambda x: x["run_id"], reverse=True)
            ]
            validation_link_bullets = [
                RenderedStringTemplateContent(
                    **{
                        "content_block_type": "string_template",
                        "string_template": {
                            "template": "${validation_success} $link_text",
                            "params": {
                                "link_text": link_dict["run_id"],
                                "validation_success": ""
                            },
                            "tag": "a",
                            "styling": {
                                "attributes": {
                                    "href": link_dict["filepath"]
                                },
                                "params": {
                                    "validation_success": {
                                        "tag":
                                        "i",
                                        "classes": [
                                            "fas", "fa-check-circle",
                                            "text-success"
                                        ]
                                        if link_dict["validation_success"] else
                                        ["fas", "fa-times", "text-danger"]
                                    }
                                },
                                "classes":
                                ["ge-index-page-table-validation-links-item"]
                            }
                        },
                        "styling": {
                            "parent": {
                                "classes":
                                ["hide-succeeded-validation-target"]
                                if link_dict["validation_success"] else []
                            }
                        }
                    }) for link_dict in sorted_validations_links
            ]
            validation_link_bullet_list = RenderedBulletListContent(
                **{
                    "content_block_type": "bullet_list",
                    "bullet_list": validation_link_bullets,
                    "styling": {
                        "parent": {
                            "styles": {
                                "width": "{}%".format(cell_width_pct)
                            }
                        },
                        "body": {
                            "classes":
                            ["ge-index-page-table-validation-links-list"]
                        }
                    }
                })
            section_rows.append([validation_link_bullet_list])

        return section_rows