Skip to main content

No project description provided

Project description

This repository contains functions to store knowledge for the bot, to use the knowledge stored by the bot to evaluate some statistics.

Pre-Usage

pipenv install --dev

Usage - Create Bot Knowledge

  1. You can extract knowledge from a repository using the following command:

GITHUB_ACCESS_TOKEN=<github_acess_token> PYTHONPATH=. pipenv run srcopsmetrics/cli.py --repository <repo_name> -c
  1. You can extract knowledge from a organization using the following command:

GITHUB_ACCESS_TOKEN=<github_acess_token> PYTHONPATH=. pipenv run srcopsmetrics/cli.py --organization <org_name> -c

Usage - Storing Knowledge

By default the cli will try to store the bot knowledge on Ceph. In order to store on Ceph you need to provide the following env variables:

  • S3_ENDPOINT_URL Ceph Host name where knowledge is stored.

  • CEPH_BUCKET Ceph Bucket name where knowledge is stored.

  • CEPH_BUCKET_PREFIX Ceph Prefix where knowledge is stored.

  • CEPH_KEY_ID Ceph Key ID

  • CEPH_SECRET_KEY Ceph Secret Key

If you want to test locally you have also the option to store locally without providing any parameter adding -l flag:

GITHUB_ACCESS_TOKEN=<github_acess_token> PYTHONPATH=. pipenv run srcopsmetrics/cli.py --repository <repo_name> -c -l

Usage - Visualize Project Statistics

PYTHONPATH=. pipenv run srcopsmetrics/cli.py --repository <repo_name> -v
PYTHONPATH=. pipenv run srcopsmetrics/cli.py --organization <org_name> -v

Examples

For each repository is possible to obtain the following plots:

MTTFR-in-time.png –> Mean time to First Review (MTTFR) variation after each PR approved in time.

MTTR-in-time.png –> Mean time to Review (MTTR) variation after each PR approved in time.

TTCI-in-time.png –> Time to Close an Issue (TTCI) variation after each PR approved in time.

TTFR-in-time.png –> Time to First Review (TTFR) variation after each PR approved in time.

TTR-in-time.png –> Time to Review (TTR) variation after each PR approved in time.

TTR-per-PR-length.png –> Time to Review (TTR) variation after each PR length.

TTR-per-PR.png –> Time to Review (TTR) variation after each PR.

TTFR-per-PR-length.png –> Time to First Review (TTFR) variation after each PR length.

TTFR-per-PR.png –> Time to First Review (TTFR) variation after each PR.

Entity

Throughout the project, the objects with name “entities” are mentioned. Entity is essentialy a repository metadata that is being inspected during the process of analysis (e.g. Issue or Pull Request). Then, specified features are extracted from this entity and are saved as knowledge afterwards.

Entity Criteria

Any entity satisfies these criteria:

  • schema for entity is available in entity_schema.Schemas class

  • name of the entity is in the enums.EntityTypeEnum class

  • name of the saved entities knowledge file is specified in storage.KnowledgeStorage._FILENAME_ENTITY

  • method named analyse_<entity_name>() and its ‘sub-part’ method named store_<entity_name> is implemented in github_knowledge.GitHubKnowledge class. This concept of an analyse and storage method is used because of the GitHub pagination. These two methods are used in iterator.KnowledgeAnalysis context manager for safe storage saving, meaning that if any exception of type GithubException or KeyboardInterrupt raises during the process of iterating through paginated lists, the context manager tries to save the already analysed (cached) knowledge that should be in valid state (by comparing it to the defined schema in entity_schema.Schemas). This saves time, resources and also the GitHub API rate limit.

  • method analyse_entity is then called in bot_knowledge.analyse_projects with entity enum from enums.EntityTypeEnum passed as a parameter.

Usage - Reviewer Reccomender

PYTHONPATH=. pipenv run srcopsmetrics/cli.py --project <project_name> -r True

If there are bots in the list of contributors of your project you can add them to the list at the beginning of the file. In this way you can receive the percentage of the work done by humans vs bots.

BOTS_NAMES = [
    "sesheta",
    "dependencies[bot]",
    "dependabot[bot]",
    ]

number_reviewer flag is set to 2

Final Score for Reviewers assignment

The final score for the selection of the reviewers, it is based on the following contributions. (Number of reviewers is by default 2, but it can be changed)

  1. Number of PR reviewed respect to total number of PR reviewed by the team.

  2. Mean time to review a PR by reviewer respect to team repostiory MTTR.

  3. Mean length of PR respect to minimum value of PR length for a specific label.

  4. Number of commits respect to the total number of commits in the repository.

5. Time since last review compared to time from the first review of the project respect to the present time. (Time dependent contribution)

Each of the contribution as a weight factor k. If all weight factors are set to 1, all contributions to the final score have the same weight.

Example results

                Repository  PullRequest n.  Commits n.  PullRequestRev n.           MTTFR     MTTR

thoth-station/performance              33          38                 20  0:17:30.500000  0:46:28
INFO:reviewer_recommender:-------------------------------------------------------------------------------

Contrib  PR n.      PR %  PRRev n.  PRRev % MPRLen  Rev n.  MRL    MTTFR     MTTR                     TLR  Comm n.  Comm %    Bot
fridex     17  0.515152        13     0.65      S      21  3.0  0:02:44  0:31:10 40 days 00:08:36.857380       19     0.5  False
pacospace  16  0.484848         7     0.35      M       9  1.0  1:01:46  1:01:46 40 days 05:00:39.857380       19     0.5  False

Contrib        C1        C2       C3   C4  C5     Score
pacospace  0.484848  0.752294  1.00000  0.5   1  0.337028
fridex     0.515152  1.490909  0.22449  0.5   1  0.159314

INFO:reviewer_recommender:Number of reviewers requested: 2
INFO:reviewer_recommender:Reviewers: ['pacospace' 'fridex']

How to contribute

Always feel free to open new Issues or engage in already existing ones!

I want to add new Entity

If you want to contribute by adding new entity that will be analysed from GitHub repositories and stored as a knowledge, your implementation has to meet with Entity criteria described above. Always remember to first create Issue and describe why do you think this new entity should be analysed and stored and what are the benefits of doing so according to the goal of SrcOpsMetrics project. Do not forget to reference the Issue in your Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

srcopsmetrics-2.0.1.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

srcopsmetrics-2.0.1-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file srcopsmetrics-2.0.1.tar.gz.

File metadata

  • Download URL: srcopsmetrics-2.0.1.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for srcopsmetrics-2.0.1.tar.gz
Algorithm Hash digest
SHA256 0ae3c38ba3779603729f9ad5234bfafb6061f06ea6257d9deeaad8de27eb4fc5
MD5 79a7064aedc33bb3f253a2d797a56409
BLAKE2b-256 8e657b71ac92aa5281484864659fc70240e7430c50481485d38ee6da9f44d5e2

See more details on using hashes here.

File details

Details for the file srcopsmetrics-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: srcopsmetrics-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 49.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for srcopsmetrics-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1de1b3bfa7805aba7a5451c4e00ba1f02cf9a9f74294796fcdaac8fb0ab481a7
MD5 543d2536c0b8470f6f58e798774ddff7
BLAKE2b-256 da4308bef518e93b497faea5005df746604a2eb9d2609420ced4135ab655e53a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page