Skip to content

Scenarios

coleman4hcs.scenarios

coleman4hcs.scenarios - Scenario Management for the Coleman4HCS Framework.

This module provides utilities for managing and processing different scenarios in the context of the Coleman4HCS framework. This includes virtual scenarios for commits, scenarios specific to HCS context, and scenarios that consider context information for each commit. The module also provides utilities to process CSV files for experimental evaluations.

Classes:

Name Description
VirtualScenario

Basic virtual scenario to manipulate data for each commit.

VirtualHCSScenario

Extends VirtualScenario to handle HCS context.

VirtualContextScenario

Extends VirtualScenario to handle context information.

IndustrialDatasetScenarioProvider

Provider to process CSV files for experiments.

IndustrialDatasetHCSScenarioProvider

Extends IndustrialDatasetScenarioProvider to handle HCS scenarios.

IndustrialDatasetContextScenarioProvider

Extends IndustrialDatasetScenarioProvider to handle context scenarios.

IndustrialDatasetContextScenarioProvider

Bases: IndustrialDatasetScenarioProvider

Scenario provider for context-aware data.

Parameters:

Name Type Description Default
tcfile str

Path to the test case file.

required
feature_group_name str

Name of the feature group.

required
feature_group_values list of str

List of features.

required
previous_build list of str

List of features from the previous build.

required
sched_time_ratio float

Ratio of the total build time to be used for scheduling. Default is 0.5.

0.5

Attributes:

Name Type Description
feature_group str

The feature group name.

features list of str

List of feature column names.

previous_build list of str

List of features from the previous build.

__init__

__init__(tcfile, feature_group_name, feature_group_values, previous_build, sched_time_ratio=0.5)

Initialize the context-aware scenario provider.

Parameters:

Name Type Description Default
tcfile str

Path to the test case file.

required
feature_group_name str

Name of the feature group.

required
feature_group_values list of str

List of features.

required
previous_build list of str

List of features from the previous build.

required
sched_time_ratio float

Ratio of the total build time to be used for scheduling. Default is 0.5.

0.5

__next__

__next__()

Return the next contextual scenario.

__str__

__str__()

Return the name of the scenario provider.

Returns:

Type Description
str

The scenario provider name.

get

get()

Get the next virtual context scenario.

Called by __next__. Separates data by builds and returns each successive build as a context scenario with feature data.

Returns:

Type Description
VirtualContextScenario or None

The next context scenario, or None if no more builds remain.

IndustrialDatasetHCSScenarioProvider

Bases: IndustrialDatasetScenarioProvider

Scenario provider for HCS-specific data.

Extends the base scenario provider to support variant-specific data.

Parameters:

Name Type Description Default
tcfile str

Path to the test case CSV file.

required
variantsfile str

Path to the variants CSV file.

required
sched_time_ratio float

Ratio of scheduled time to total build time. Default is 0.5.

0.5

Attributes:

Name Type Description
variants DataFrame

DataFrame containing variant data.

__init__

__init__(tcfile, variantsfile, sched_time_ratio=0.5)

Initialize the IndustrialDatasetHCSScenarioProvider.

Parameters:

Name Type Description Default
tcfile str

Path to the test case CSV file.

required
variantsfile str

Path to the variants CSV file.

required
sched_time_ratio float

Ratio of scheduled time to total build time. Default is 0.5.

0.5

__next__

__next__()

Return the next HCS scenario.

get

get()

Get the next virtual HCS scenario.

Called by __next__. Separates data by builds and returns each successive build as an HCS scenario with variant data.

Returns:

Type Description
VirtualHCSScenario or None

The next HCS scenario, or None if no more builds remain.

get_all_variants

get_all_variants()

Return all unique variant names as a list.

Returns:

Type Description
list of str

List of unique variant names.

get_total_variants

get_total_variants()

Return the number of unique variants.

Returns:

Type Description
int

The number of unique variants.

IndustrialDatasetScenarioProvider

Base class for scenario providers that process test case data from CSV files.

Parameters:

Name Type Description Default
tcfile str

Path to the test case CSV file.

required
sched_time_ratio float

Ratio of scheduled time to total build time. Default is 0.5.

0.5

Attributes:

Name Type Description
name str

Name derived from the dataset directory.

avail_time_ratio float

The available time ratio for scheduling.

current_build int

The current build number being processed.

total_build_duration float

The total duration of the current build.

scenario VirtualScenario or None

The current virtual scenario.

tcdf DataFrame

DataFrame containing test case data.

max_builds int

The maximum number of builds in the dataset.

__init__

__init__(tcfile, sched_time_ratio=0.5)

Initialize the IndustrialDatasetScenarioProvider.

Parameters:

Name Type Description Default
tcfile str

Path to the test case CSV file.

required
sched_time_ratio float

Ratio of scheduled time to total build time. Default is 0.5.

0.5

__iter__

__iter__()

Return the iterator for the scenario provider.

Returns:

Type Description
IndustrialDatasetScenarioProvider

The iterator instance.

__next__

__next__()

Return the next scenario.

Returns:

Type Description
VirtualScenario

The next virtual scenario.

Raises:

Type Description
StopIteration

If no more scenarios are available.

__str__

__str__()

Return the name of the scenario provider.

Returns:

Type Description
str

The scenario provider name.

get

get()

Get the next virtual scenario.

Called by __next__. Separates data by builds and returns each successive build as a scenario.

Returns:

Type Description
VirtualScenario or None

The next scenario, or None if no more builds remain.

get_avail_time_ratio

get_avail_time_ratio()

Return the available time ratio.

Returns:

Type Description
float

The available time ratio.

last_build

last_build(build)

Set the last build number.

Parameters:

Name Type Description Default
build int

The build number to set.

required

VirtualContextScenario

Bases: VirtualScenario

Extends VirtualScenario to include context-specific features for each commit.

Parameters:

Name Type Description Default
*args

Positional arguments passed to VirtualScenario.

()
feature_group str

The name of the feature group.

required
features list of str

The feature names.

required
context_features DataFrame

DataFrame containing context features.

required
**kwargs

Keyword arguments passed to VirtualScenario.

{}

Attributes:

Name Type Description
feature_group str

The name of the feature group.

features list of str

The feature names.

context_features DataFrame

DataFrame containing context features.

get_context_features

get_context_features()

Return the context features associated with the scenario.

Returns:

Type Description
DataFrame

DataFrame containing context features.

get_feature_group

get_feature_group()

Return the feature group.

Returns:

Type Description
str

The feature group name.

get_features

get_features()

Return the features associated with the scenario.

Returns:

Type Description
list of str

The feature names.

VirtualHCSScenario

Bases: VirtualScenario

Extends VirtualScenario to handle data in an HCS-specific context.

Parameters:

Name Type Description Default
*args

Positional arguments passed to VirtualScenario.

()
variants DataFrame

DataFrame containing variant information.

required
**kwargs

Keyword arguments passed to VirtualScenario.

{}

Attributes:

Name Type Description
variants DataFrame

DataFrame containing variant information.

__init__

__init__(*args, variants, **kwargs)

Initialize the VirtualHCSScenario.

Parameters:

Name Type Description Default
*args

Positional arguments passed to VirtualScenario.

()
variants DataFrame

DataFrame containing variant information.

required
**kwargs

Keyword arguments passed to VirtualScenario.

{}

get_variants

get_variants()

Return the variants associated with the system.

Returns:

Type Description
DataFrame

DataFrame containing variant information.

VirtualScenario

Virtual scenario used to manipulate data for each commit.

Parameters:

Name Type Description Default
available_time float

The time available to execute tests.

required
testcases list of dict

The test cases for the scenario.

required
build_id int

The build identifier.

required
total_build_duration float

The total duration of the build.

required

Attributes:

Name Type Description
available_time float

The time available to execute tests.

testcases list of dict

The test cases for the scenario.

build_id int

The build identifier.

total_build_duration float

The total duration of the build.

__init__

__init__(available_time, testcases, build_id, total_build_duration)

Initialize the VirtualScenario.

Parameters:

Name Type Description Default
available_time float

The time available to execute tests.

required
testcases list of dict

The test cases for the scenario.

required
build_id int

The build identifier.

required
total_build_duration float

The total duration of the build.

required

get_available_time

get_available_time()

Return the available time to execute the tests.

Returns:

Type Description
float

The available time.

get_testcases

get_testcases()

Return the test cases for the scenario.

Returns:

Type Description
list of dict

The test cases.

reset

reset()

Reset the priorities for all test cases in the scenario.