Metrics¶
Base Metrics Extractor¶
-
class
repominer.metrics.base.
BaseMetricsExtractor
(path_to_repo: str, at: str = 'release')¶ This is the base class to extract metrics from IaC scripts. It is extended by concrete classes to extract metrics for specific languages (e.g., Ansible and Tosca).
-
__init__
(path_to_repo: str, at: str = 'release')¶ The clss constructor.
- Parameters
path_to_repo (str) – The path to the repository.
at (str) – When to extract metrics: at each release or each commit.
-
dataset
¶ The metrics dataset, populated after
extract()
.- Type
pandas.DataFrame
- Raises
ValueError – If at is not one of the following: release, commit.
NotImplementedError – The commit option is not implemented yet.
-
extract
(labeled_files: List[repominer.files.FailureProneFile], product: bool = True, process: bool = True, delta: bool = False)¶ Extract metrics from labeled files.
- Parameters
labeled_files (List[FailureProneFile]) – The list of FailureProneFile objects that are used to label a script as failure-prone (1) or clean (0).
product (bool) – Whether to extract product metrics.
process (bool) – Whether to extract process metrics.
delta (bool) – Whether to extract delta metrics between two successive releases (or commits).
-
get_files
() → Set[str]¶ Return all the files in the repository
- Returns
The set of filepath relative to the root of repository
- Return type
Set[str]
-
get_process_metrics
(from_commit: str, to_commit: str) → dict¶ Extract process metrics for an evolution period.
- Parameters
from_commit (str) – Hash of release start
to_commit (str) – Hash of release end
-
get_product_metrics
(script: str) → Dict[str, Any]¶ Extract source code metrics from a script.
- Parameters
script (str) – The content of the script to extract metrics from.
- Returns
A dictionary of <metric, value>.
- Return type
Dict[str, Any]
-
to_csv
(filepath)¶ Save the metrics as csv The file is saved asa
- Parameters
filepath (str) – The path to the csv.
-
Ansible Metrics Extractor¶
-
class
repominer.metrics.ansible.
AnsibleMetricsExtractor
(path_to_repo: str, at: str)¶ Bases:
repominer.metrics.base.BaseMetricsExtractor
-
__init__
(path_to_repo: str, at: str)¶ The clss constructor.
- Parameters
path_to_repo (str) – The path to the repository.
at (str) – When to extract metrics: at each release or each commit.
-
dataset
¶ The metrics dataset, populated after
extract()
.- Type
pandas.DataFrame
- Raises
ValueError – If at is not one of the following: release, commit.
NotImplementedError – The commit option is not implemented yet.
-
get_product_metrics
(script: str) → dict¶ Extract product metrics from a script. :param script: the script from which to run AnsibleMetrics on :return: a dictionary {string: float} with metrics. If an error occurs, return an empty dictionary
-
Tosca Metrics Extractor¶
-
class
repominer.metrics.tosca.
ToscaMetricsExtractor
(path_to_repo: str, at: str)¶ Bases:
repominer.metrics.base.BaseMetricsExtractor
-
__init__
(path_to_repo: str, at: str)¶ The clss constructor.
- Parameters
path_to_repo (str) – The path to the repository.
at (str) – When to extract metrics: at each release or each commit.
-
dataset
¶ The metrics dataset, populated after
extract()
.- Type
pandas.DataFrame
- Raises
ValueError – If at is not one of the following: release, commit.
NotImplementedError – The commit option is not implemented yet.
-
get_product_metrics
(script: str) → dict¶ Extract product metrics from a script
-