CS-539 Term Project
Creators: name: Akyol, Giray
name: Çavdar, Sinan
Publisher: name: figshare
Year: 2024
Subjects: classificationCode: 461204
subject: Programming languages

description: ### IntroductionThis document provides comprehensive instructions for setting up and using the Flacoco fault localization tool along with the Codet5 and InCoder models for code automation tasks. Follow these steps to ensure correct installation and execution of the tools.<br>### Setting Up Flacoco1. **Installation**: Begin by visiting [Flacoco's GitHub repository](https://github.com/ASSERT-KTH/flacoco). Follow the installation instructions provided there to download and install Flacoco on your local machine.<br>### Environment SetupRun the `requirements.txt` file dependencies.<br>- For models, download from:  - [Model 1](https://zenodo.org/records/7559244)  - [Model 2](https://zenodo.org/records/7559277)  Move the model checkpoints to the `models` folder.<br>- For the dataset, visit: [Autocode-java Dataset](https://github.com/APR-Comp/autocode-java/tree/0067c93660ccf7fc41bea6a913de2124e92bb924).<br>### Configuring Your Workspace2. **Preparation of Files**: Once Flacoco is installed, prepare your workspace by copying all buggy files, which you intend to analyze, into the `autocode` directory. Ensure that these files are in the correct format as expected by the Flacoco tool.<br>### Running Fault Localization3. **Executing the Flacbak Script**: Navigate to the directory where the `flacbak` script is located. Run this script to automatically generate the locations of faults within your buggy files. This step is crucial for pinpointing the areas that need further inspection or correction. Running the script will generate a file with the faulty locations used by the generation script.<br>### Generation4. **Codet5 and InCoder**:   - **Codet5 Tool**: Execute the Python script `autocode_codet5_finetune.py` found in the `incoder/clm/clm-apr/codet5_finetune` directory. This script uses the fault locations computed in the previous step to generate the prompts used in the generator models. This step requires a GPU and you may need to fix the paths for your system.    - **InCoder Tool**: Similarly, the InCoder tool can be run using the same script.This step generates two json files, one for the inputs to the model and one for the outputted candidate patches. <br>### Validation Process5. **Model Validation**: After generation, it is essential to validate the models outputs. Run the validation script `validate_autocode_finetune.py` located in the `humaneval` directory. This script will run the included unit tests for each buggy code to check for compilation and plausible patches. The outputted code is saved to the directory “acres” with a name format describing the bug, status and path number.  <br>### Reviewing Results6. **Accessing Output**: The output from the fine-tuning and validation processes can be found in the `acres` folder. Review these results to assess the improvements and effectiveness of the models on your code. This folder contains detailed logs and output files that provide insights into the performance of the tools.<br>### Important Notices- **Path Configuration**: Please be aware that some paths in the code are hardcoded to the home directory. It is essential to review and modify these paths according to your specific environment to ensure proper functionality.- **Hardware Requirement**: This code is designed to operate exclusively on systems with specific GPU capabilities which supports cuda. Ensure that your environment meets this requirement for optimal performance.- **Modifying Generated Patches**:  - **InCoder**: To change the number of generated patches from the beam search for InCoder (default is 25), navigate to the `incoder/clm/clm-apr/codet5_finetune/autocode_incoder_finetune.py` file. Modify the `num_output` parameter in the statement `humaneval_incoder_finetune_output(input_file, output_file, model_name=model_name, num_output=25)` to your desired value.  - **Codet5**: Similarly, to change the number of generated patches for Codet5, navigate to the `codet5/clm/clm-apr/codet5_finetune/autocode_codet5_finetune.py` file. Modify the `num_output` parameter in the statement `humaneval_codet5_finetune_output(input_file, output_file, model_name=model_name, num_output=25)` to your desired value.<br>### ConclusionBy following these detailed instructions, you can effectively set up Flacoco and the Codet5 or InCoder tools for your coding projects. This setup will aid in identifying faults and improving code quality through advanced machine learning models.