Skip to content

qas

QAS model and functions to handle Quality Attribute Scenarios.

QASDescriptor

Bases: BaseModel

Describes the system-level requirements for the model component. Represents a Quality Attribute Scenario.

Source code in mlte/negotiation/qas.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class QASDescriptor(BaseModel):
    """Describes the system-level requirements for the model component. Represents a Quality Attribute Scenario."""

    identifier: Optional[str] = None
    """The unique identifier for the QAS."""

    quality: str = ""
    """System property that is being evaluated. Selected from quality attributes custom list."""

    stimulus: Optional[str] = None
    """The condition that triggers this scenario."""

    source: Optional[str] = None
    """Where the stimulus comes from."""

    environment: Optional[str] = None
    """Set of circumnstances in which the scenario takes place."""

    response: Optional[str] = None
    """Activity that ocurrs as the result of the stimulus."""

    measure: Optional[str] = None
    """Used to determine if the goals of the responses of the scenario have been achieved."""

    def __str__(self) -> str:
        """Converts to a string representation of the QA scenario."""
        prefix = f"{self.identifier} ({self.quality}):"
        desc1 = f"{self.stimulus} from {self.source} during {self.environment}."
        desc2 = f"{self.response} {self.measure}."
        return f"{prefix} {desc1[0].upper()}{desc1[1:]} {desc2[0].upper()}{desc2[1:]}"

environment = None class-attribute instance-attribute

Set of circumnstances in which the scenario takes place.

identifier = None class-attribute instance-attribute

The unique identifier for the QAS.

measure = None class-attribute instance-attribute

Used to determine if the goals of the responses of the scenario have been achieved.

quality = '' class-attribute instance-attribute

System property that is being evaluated. Selected from quality attributes custom list.

response = None class-attribute instance-attribute

Activity that ocurrs as the result of the stimulus.

source = None class-attribute instance-attribute

Where the stimulus comes from.

stimulus = None class-attribute instance-attribute

The condition that triggers this scenario.

__str__()

Converts to a string representation of the QA scenario.

Source code in mlte/negotiation/qas.py
39
40
41
42
43
44
def __str__(self) -> str:
    """Converts to a string representation of the QA scenario."""
    prefix = f"{self.identifier} ({self.quality}):"
    desc1 = f"{self.stimulus} from {self.source} during {self.environment}."
    desc2 = f"{self.response} {self.measure}."
    return f"{prefix} {desc1[0].upper()}{desc1[1:]} {desc2[0].upper()}{desc2[1:]}"

add_qas_ids(base_id, quality_scenarios)

Ensures that all QAS in the NegotiationCard have an id, and assigns one to those who don't have it.

Source code in mlte/negotiation/qas.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def add_qas_ids(
    base_id: str, quality_scenarios: list[QASDescriptor]
) -> list[QASDescriptor]:
    """Ensures that all QAS in the NegotiationCard have an id, and assigns one to those who don't have it."""
    # Find the highest position that has been assigned a QAS id.
    highest_id_pos = 0
    sorted_qas: list[QASDescriptor] = sorted(
        [qas for qas in quality_scenarios if qas.identifier is not None],
        key=lambda x: x.identifier,  # type: ignore
        reverse=True,
    )
    if len(sorted_qas) > 0:
        highest_id_pos = _get_pos_from_qas_id(sorted_qas[0].identifier)  # type: ignore[arg-type]

    # Go over all QAS and assign ids to those that don't have them, based on the highest position found.
    for qas in quality_scenarios:
        if qas.identifier is None:
            highest_id_pos += 1
            qas.identifier = _build_qas_id(base_id, highest_id_pos)

    return quality_scenarios