All Projects → coinse → pyggi

coinse / pyggi

Licence: MIT license
Python General Framework for Genetic Improvement [Version 2]

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pyggi

Chaos Ssm Documents
Collection of AWS SSM Documents to perform Chaos Engineering experiments
Stars: ✭ 225 (+837.5%)
Mutual labels:  software-engineering
freesources
Repository of free resources for learning Software Development
Stars: ✭ 38 (+58.33%)
Mutual labels:  software-engineering
PATCH
The PATCH repository for issues tracking, wiki and shared material.
Stars: ✭ 34 (+41.67%)
Mutual labels:  repair
How To Prepare For Google Interview Swe Sre
This repository includes resources which are more than sufficient to prepare for google interview if you are applying for a software engineer position or a site reliability engineer position
Stars: ✭ 251 (+945.83%)
Mutual labels:  software-engineering
refined.blog
curated list of personal blogs
Stars: ✭ 144 (+500%)
Mutual labels:  software-engineering
SEntiMoji
data, code, pre-trained models and experiment results for "SEntiMoji: An Emoji-Powered Learning Approach for Sentiment Analysis in Software Engineering"
Stars: ✭ 27 (+12.5%)
Mutual labels:  software-engineering
Technicalnote
Repository to store what we have studied. 📖 We want everyone to get a job through TechnicalNote.
Stars: ✭ 206 (+758.33%)
Mutual labels:  software-engineering
wps-se
Software Engineering Basic for Web Developer
Stars: ✭ 59 (+145.83%)
Mutual labels:  software-engineering
ArchitectureWeekly
Architecture Weekly - links and resources to boost your knowledge and developer skills
Stars: ✭ 1,060 (+4316.67%)
Mutual labels:  software-engineering
ITMO
Все лабы и отчеты кафедры ВТ (СППО) Университета ИТМО
Stars: ✭ 63 (+162.5%)
Mutual labels:  software-engineering
Coding Interview University
A complete computer science study plan to become a software engineer.
Stars: ✭ 204,859 (+853479.17%)
Mutual labels:  software-engineering
ceil
Helmut Hoffer von Ankershoffen experimenting with auto-provisioned RPi cluster running K8S on bare-metal
Stars: ✭ 42 (+75%)
Mutual labels:  software-engineering
awesome-backend
🚀 A curated and opinionated list of resources (English & Russian) for Backend developers | Структурированный список ресурсов для изучения Backend разработки
Stars: ✭ 826 (+3341.67%)
Mutual labels:  software-engineering
Design Patterns Python
💻 Padrões de Projeto em Python
Stars: ✭ 246 (+925%)
Mutual labels:  software-engineering
software-architecture-books
A comprehensive list of books on Software Architecture.
Stars: ✭ 7,397 (+30720.83%)
Mutual labels:  software-engineering
Nycsde
公众号【码农田小齐】的分类合集
Stars: ✭ 208 (+766.67%)
Mutual labels:  software-engineering
ecchronos
Ericsson distributed repair scheduler for Apache Cassandra
Stars: ✭ 22 (-8.33%)
Mutual labels:  repair
software-engineering
Remote Jobs for Software Engineering
Stars: ✭ 48 (+100%)
Mutual labels:  software-engineering
NeuralCodeTranslator
Neural Code Translator provides instructions, datasets, and a deep learning infrastructure (based on seq2seq) that aims at learning code transformations
Stars: ✭ 32 (+33.33%)
Mutual labels:  software-engineering
webspicy
A technology agnostic specification and test framework that yields better coverage for less testing effort.
Stars: ✭ 42 (+75%)
Mutual labels:  software-engineering

PYGGI(Python General Framework for Genetic Improvement) Build Status Coverage Status

PYGGI logo

PYGGI is the lightweight and simple framework for Genetic Improvement. It helps one practice or experience GI with only few code lines by reducing the costs of implementing typical GI process such as source code manipulation and patch management.

Prerequisites

Documentation

You can find the PYGGI's documentation here. (Currently outdated, will be updated soon!)

Citation

@inproceedings{An:2019:PLI:3338906.3341184,
 author = {An, Gabin and Blot, Aymeric and Petke, Justyna and Yoo, Shin},
 title = {PyGGI 2.0: Language Independent Genetic Improvement Framework},
 booktitle = {Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering},
 series = {ESEC/FSE 2019},
 year = {2019},
 isbn = {978-1-4503-5572-8},
 location = {Tallinn, Estonia},
 pages = {1100--1104},
 numpages = {5},
 url = {http://doi.acm.org/10.1145/3338906.3341184},
 doi = {10.1145/3338906.3341184},
 acmid = {3341184},
 publisher = {ACM},
 address = {New York, NY, USA},
 keywords = {Genetic Improvement, Search-based Software Engineering},
}

The pdf file is available at link.

Getting Started

1. Clone the repository

$ git clone ~
$ cd PYGGI

2. Install

$ python setup.py install

3. Run the example

1. Improving runtime of Triangle by deleting delay() function call
  • java
$ cd example
$ python improve_java.py --project_path ../sample/Triangle_fast_java --mode [line|tree] --epoch [EPOCH] --iter [MAX_ITER]
  • python
$ cd example
$ python improve_python.py --project_path ../sample/Triangle_fast_python/ --mode [line|tree] --epoch [EPOCH] --iter [MAX_ITER]
2. Repairing the bug of Triangle
  • java
$ cd example
$ python repair_java.py --project_path ../sample/Triangle_bug_java --mode [line|tree] --epoch [EPOCH] --iter [MAX_ITER]
  • python
$ cd example
$ python repair_python.py --project_path ../sample/Triangle_bug_python/ --mode [line|tree] --epoch [EPOCH] --iter [MAX_ITER]
Important notice about using tree mode for Java, C++, or C programs

For the Java samples (Triangle_fast_java, Triangle_bug_java), we provide the XML version of Triangle.java files translated by srcML (download). However, in the general case, you should translate the target Java, C++, or C files into XML files before initialising Program instances and provide the translated those XML files as target files.

Or, you can simply override the setup method of AbstractProgram, which is initially empty, to execute the translation command.

ex) Translating Triangle.java to Triangle.java.xml using srcML (See the context at example/improve_java.py)

class MyTreeProgram(TreeProgram):
    def setup(self):
        if not os.path.exists(os.path.join(self.tmp_path, "Triangle.java.xml")):
            self.exec_cmd("srcml Triangle.java -o Triangle.java.xml")

Then, PyGGI will manipulate the XML files using XmlEngine(in pyggi/tree/xml_engine.py) and convert it back to the original language by stripping all the XML tags before running the test command.

Program setup convention

Two files should be provided: a configuration file and a test script. You can refer the sample programs in the sample directory.

1. Config file (JSON format)

{target_dir_path}/.pyggi.config

ex) sample/Triangle_fast_java/.pyggi.config

{
  "target_files": [
    "Triangle.java"
  ],
  "test_command": "./run.sh"
}

However, you can also specify the config file name (default: .pyggi.config),

ex)

program = LineProgram("sample/Triangle_fast_java", config='.custom.pyggi.config')

or directly provide the dict type configuration when initialising Program. ex)

config = {
    "target_files": ["Triangle.java"],
    "test_command": "./run.sh"
}
program = LineProgram("sample/Triangle_fast_java", config=config)

2. Test script file

{target_dir_path}/run.sh

ex) sample/Triangle_fast/run.sh

#!/bin/sh
set -e

# cd $1

rm -f *.class
javac -cp "./junit-4.10.jar" Triangle.java TriangleTest.java TestRunner.java
java -cp "./junit-4.10.jar:./" TestRunner TriangleTest

The output of the test command should be the fitness of the program (only number),

7.0

or, you can use own result parser by overriding the compute_fitness method of Program classes.

This is the example of a custom result parser from example/improve_python.py,

class MyProgram(AbstractProgram):
    def compute_fitness(self, elapsed_time, stdout, stderr):
        import re
        m = re.findall("runtime: ([0-9.]+)", stdout)
        if len(m) > 0:
            runtime = m[0]
            failed = re.findall("([0-9]+) failed", stdout)
            pass_all = len(failed) == 0
            if pass_all:
                return round(float(runtime), 3)
            else:
                raise ParseError
        else:
            raise ParseError

class MyLineProgram(LineProgram, MyProgram):
    pass

class MyTreeProgram(TreeProgram, MyProgram):
    pass

, when the standard output is in the pytest format, such as:

======================================== test session starts ========================================
platform linux -- Python 3.6.2, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /media/ssd/Workspace/PYGGI, inifile:
collected 4 items                                                                                    

test_triangle.py ....runtime: 0.22184443473815918


===================================== 4 passed in 0.23 seconds ======================================
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].