Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 2.82 KB

contribution_workflow.md

File metadata and controls

63 lines (44 loc) · 2.82 KB

Adding a new project for code annotation

Ideally a user needs to run through these steps to create a new project contribution -

  1. Create a new project under the projects folder
  2. Create a original_source folder to contain the uncommented original source code
  3. Create a human_annotated folder to contain the annotated code with human comments
  4. Create an intermediate_files folder to contain intermediate files that are generated by the annotator
  5. From project root folder, run annotator.py with output folder as human_annotated folder e.g
python3 src/annotator.py -o <project-folder>/intermediate_files/<project-name> \
                         -s <project-folder>/original_source \
                         -c <project-folder>/human_annotated/ \
                         -t <project-folder>/intermediate/<project-name>.function_file_list.json \
                         -u <project-folder>/intermediate/<project-name>.struct_file_list.json \
                         -p <project-name>

After generating user comments they should,

  1. From project root folder, run comment_extraction.py to extract comments from the human_annotated folder to generate the annotated db
python3 src/utils/comment_extractor.py -s <project-folder>/human_annotated/ \
                                       -d  <project-folder>/human_annotated/<project-name>.db_comments.db

Using workflow script to automate everything

This all can be done via the scripts/execute_workflow.sh script which can be run like this,

Let's say for a project ingress-node-firewall-master who's url is https://github.com/openshift/ingress-node-firewall.git

  • To create necessary directories user can run the below command

./scripts/execute_workflow.sh create_dirs ingress-node-firewall-master https://github.com/openshift/ingress-node-firewall.git

When run in a shell the output will look like below,

Run the below command and keep the bpf directory only, deleting others - 

git clone --depth=1 https://github.com/openshift/ingress-node-firewall.git projects/ingress-node-firewall-master/original_source &&\
rm -rf projects/ingress-node-firewall-master/original_source/.git &&\
cd projects/ingress-node-firewall-master/original_source
  • After that user can follow the comments on the commandline and fetch the repo

Note:- We need to keep only the bpf source files and delete everything else.

  • To annotate the project and create a human comments stub we run -
$ ./scripts/execute_workflow.sh annotate ingress-node-firewall-master https://github.com/openshift/ingress-node-firewall.git
  • Finally after the human comments have been added we can run the comment extractor as -
./scripts/execute_workflow.sh extract_comment ingress-node-firewall-master https://github.com/openshift/ingress-node-firewall.git