Skip to content

report_factory

Definition of the metadata (DB schema) for the artifact store.

create_report_model(report_orm)

Creates the internal model object from the corresponding DB object.

Source code in mlte/store/artifact/underlying/rdbs/report_factory.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def create_report_model(report_orm: DBReport) -> ReportModel:
    """Creates the internal model object from the corresponding DB object."""
    negotiation_card = card_factory.create_card_model(
        report_orm.negotiation_card
    )
    test_suite = suite_factory.create_suite_model(report_orm.test_suite)
    test_results = result_factory.create_results_model(report_orm.test_results)

    body = ReportModel(
        negotiation_card_id=report_orm.negotiation_card_identifier,
        negotiation_card=negotiation_card,
        test_suite_id=report_orm.test_suite_identifier,
        test_suite=test_suite,
        test_results_id=report_orm.test_results_identifier,
        test_results=test_results,
        comments=[
            CommentDescriptor(content=comment.content)
            for comment in report_orm.comments
            if comment.content is not None
        ],
    )
    return body

create_report_orm(report, session)

Creates the DB object from the corresponding internal model.

Source code in mlte/store/artifact/underlying/rdbs/report_factory.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def create_report_orm(
    report: ReportModel,
    session: Session,
) -> DBReport:
    """Creates the DB object from the corresponding internal model."""
    # Create the internal card, suite and results ORMs that will be preserved as a copy.
    # Note that they will not be stored as independent artifacts, thus the None artifac_orm param.
    card_orm = card_factory.create_card_orm(
        report.negotiation_card, session=session
    )
    suite_orm = suite_factory.create_suite_orm(report.test_suite)
    results_orm = result_factory.create_results_orm(report.test_results)

    # Create the actual object.
    report_orm = DBReport(
        negotiation_card_identifier=report.negotiation_card_id,
        negotiation_card=card_orm,
        test_suite_identifier=report.test_suite_id,
        test_suite=suite_orm,
        test_results_identifier=report.test_results_id,
        test_results=results_orm,
        comments=[],
    )

    # Create list of comment objects.
    for comment in report.comments:
        comment_orm = DBCommentDescriptor(content=comment.content)
        report_orm.comments.append(comment_orm)

    return report_orm