Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for local csv file as input #106

Merged
merged 4 commits into from
Apr 13, 2022
Merged

Conversation

CannedFish
Copy link
Contributor

@CannedFish CannedFish commented Apr 2, 2022

In some scenarios, such as parameter tuning, it is not necessary to obtain relevant statistics through the network every time. This PR help to support batch reading statistics from local csv files.

Usage as follows:

usage: criticality_score [-h] (--repo REPO | --local-file L_FILE) [--format {default,csv,json}]
                         [--params PARAMS [PARAMS ...]]

Gives criticality score for an open source project

optional arguments:
  -h, --help            show this help message and exit
  --repo REPO           repository url
  --local-file L_FILE   path of a local csv file with repo stats
  --format {default,csv,json}
                        output format. allowed values are [default, csv, json]
  --params PARAMS [PARAMS ...]
                        Additional parameters in form (<value>|<key>):<weight>:<max_threshold>, <value> for repo, and
                        <key> for loacl file

Here is an example:

# cat python_top_2.csv
name,artifacts,url,language,created_since,updated_since,contributor_count,org_count,commit_frequency,recent_releases_count,updated_issues_count,closed_issues_count,comment_frequency,dependents_count,criticality_score,idc,bc,cc
salt,salt@3004,https://github.com/saltstack/salt,Python,120,0,3636,7,62.6,21,1641,679,1.1,20974,0.87814,6.436596945448553e-05,3.4932693324662978e-06,1.0844059851056442e-19
core,[email protected],https://github.com/home-assistant/core,Python,89,0,2520,9,162.7,205,5330,3786,3.5,380,0.87147,1.2873193890897107e-05,6.431467681977665e-06,0.12111046542342438

# criticality_score --local-file python_top_2.csv --format csv --params idc:1.5:0.1 bc:1.5:0.01 cc:0.5:1
name,artifacts,url,language,created_since,updated_since,contributor_count,org_count,commit_frequency,recent_releases_count,updated_issues_count,closed_issues_count,comment_frequency,dependents_count,criticality_score,idc,bc,cc
salt,salt@3004,https://github.com/saltstack/salt,Python,120,0,3636,7,62.6,21,1641,679,1.1,20974,0.62214,6.436596945448553e-05,3.4932693324662978e-06,1.0844059851056442e-19
core,[email protected],https://github.com/home-assistant/core,Python,89,0,2520,9,162.7,205,5330,3786,3.5,380,0.62426,1.2873193890897107e-05,6.431467681977665e-06,0.12111046542342438

Copy link
Contributor

@calebbrown calebbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change. I ripped the score logic out into a separate file and did the csv processing in there, but this helps keep it all together.

FYI: See #108 on the future direction I have in mind for this project.

criticality_score/run.py Outdated Show resolved Hide resolved
Copy link
Contributor

@calebbrown calebbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

I have one minor comment, but otherwise this is ready to go.

criticality_score/run.py Show resolved Hide resolved
@CannedFish
Copy link
Contributor Author

CannedFish commented Apr 13, 2022

Hi @calebbrown , I have resolved conflicts, please review again. Thanks.

@calebbrown calebbrown merged commit f1f0a5b into ossf:main Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants