Showing
3 changed files
with
128 additions
and
3 deletions
1 | -# autocommit | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +# commit-autosuggestions | ||
2 | + | ||
3 | +<p align="center"> | ||
4 | +<a href="https://travis-ci.com/github/graykode/commit-autosuggestions"><img alt="Build Status" src="https://travis-ci.com/graykode/commit-autosuggestions.svg?branch=master"></a> | ||
5 | +<a href="https://github.com/graykode/commit-autosuggestions/blob/master/LICENSE"><img alt="License: Apache 2.0" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> | ||
6 | +<a href="https://pypi.org/project/commit/"><img alt="PyPI" src="https://img.shields.io/pypi/v/commit"></a> | ||
7 | +<a href="https://pepy.tech/project/commit"><img alt="Downloads" src="https://static.pepy.tech/badge/commit"></a> | ||
8 | +</p> | ||
9 | + | ||
10 | +Have you ever hesitated to write a commit message? Now get a commit message from Artificial Intelligence! | ||
11 | +![](images/demo.gif) | ||
12 | + | ||
13 | +### Abstract | ||
14 | +[CodeBERT: A Pre-Trained Model for Programming and Natural Languages](https://arxiv.org/pdf/2002.08155.pdf) introduces a pre-trained model in a combination of Program Language and Natural Language(PL-NL). It also introduces the problem of converting code into natural language (Code Documentation Generation). | ||
15 | +```text | ||
16 | +diff --git a/test.py b/test.py | ||
17 | +new file mode 100644 | ||
18 | +index 0000000..1b1b82a | ||
19 | +--- /dev/null | ||
20 | ++++ b/test.py | ||
21 | +@@ -0,0 +1,3 @@ | ||
22 | ++ | ||
23 | ++def add(a, b): | ||
24 | ++ return a + b | ||
25 | +``` | ||
26 | +```text | ||
27 | +Recommended Commit Message : Add two arguments . | ||
28 | +``` | ||
29 | +We can use CodeBERT to create a model that generates a commit message when code is added. However, most code changes are not made only by add of the code, and some parts of the code are deleted. | ||
30 | +```text | ||
31 | +diff --git a/test.py b/test.py | ||
32 | +index 1b1b82a..32a93f1 100644 | ||
33 | +--- a/test.py | ||
34 | ++++ b/test.py | ||
35 | +@@ -1,3 +1,5 @@ | ||
36 | ++import torch | ||
37 | ++import arguments | ||
38 | + | ||
39 | + def add(a, b): | ||
40 | + return a + b | ||
41 | +``` | ||
42 | +```text | ||
43 | +Recommended Commit Message : Remove unused imports | ||
44 | +``` | ||
45 | +To solve this problem, use a new embedding called [`patch_type_embeddings`](https://github.com/graykode/commit-autosuggestions/blob/master/commit/model/diff_roberta.py#L40) that can distinguish added and deleted, just as the sample et al, 2019 (XLM) used language embeddeding. (1 for added, 2 for deleted.) | ||
46 | + | ||
47 | +### Language support | ||
48 | +| Language | Added | Diff | | ||
49 | +| :------------- | :---: | :---:| | ||
50 | +| Python | ✅ | ✅ | | ||
51 | +| JavaScript | ⬜ | ⬜ | | ||
52 | +| Go | ⬜ | ⬜ | | ||
53 | +| JAVA | ⬜ | ⬜ | | ||
54 | +| Ruby | ⬜ | ⬜ | | ||
55 | +| PHP | ⬜ | ⬜ | | ||
56 | +* ✅ — Supported | ||
57 | +* 🔶 — Partial support | ||
58 | +* 🚧 — Under development | ||
59 | +* ⬜ - N/A ️ | ||
60 | + | ||
61 | +We plan to slowly conquer languages that are not currently supported. However, I also need to use expensive GPU instances of AWS or GCP to train about the above languages. Please do a simple sponsor for this! | ||
62 | + | ||
63 | +### Quick Start | ||
64 | +To run this project, you need a flask-based inference server (GPU) and a client (commit module). If you don't have a GPU, don't worry, you can use it through Google Colab. | ||
65 | + | ||
66 | +#### 1. Run flask pytorch server. | ||
67 | +Prepare Docker and Nvidia-docker before running the server. | ||
68 | + | ||
69 | +##### 1-a. If you have GPU machine. | ||
70 | +Serve flask server with Nvidia Docker | ||
71 | +```shell script | ||
72 | +$ docker run -it --gpus 0 -p 5000:5000 commit-autosuggestions:0.1-gpu | ||
73 | +``` | ||
74 | + | ||
75 | +##### 1-b. If you don't have GPU machine. | ||
76 | +Even if you don't have a GPU, you can still serve the flask server by using the ngrok setting in [commit_autosuggestions.ipynb](commit_autosuggestions.ipynb). | ||
77 | + | ||
78 | +#### 2. Start commit autosuggestion with Python client module named `commit`. | ||
79 | +First, install the package through pip. | ||
80 | +```shell script | ||
81 | +$ pip install commit | ||
82 | +``` | ||
83 | + | ||
84 | +Set the endpoint for the flask server configured in step 1 through the commit configure command. (For example, if the endpoint is http://127.0.0.1:5000, set it as follows: `commit configure --endpoint http://127.0.0.1:5000`) | ||
85 | +```shell script | ||
86 | +$ commit configure --help | ||
87 | +Usage: commit configure [OPTIONS] | ||
88 | + | ||
89 | +Options: | ||
90 | + --profile TEXT unique name for managing each independent settings | ||
91 | + --endpoint TEXT endpoint address accessible to the server (example : | ||
92 | + http://127.0.0.1:5000/) [required] | ||
93 | + | ||
94 | + --help Show this message and exit. | ||
95 | +``` | ||
96 | + | ||
97 | +All setup is done! Now, you can get a commit message from the AI with the command commit. | ||
98 | + | ||
99 | +```shell script | ||
100 | +$ commit --help | ||
101 | +Usage: commit [OPTIONS] COMMAND [ARGS]... | ||
102 | + | ||
103 | +Options: | ||
104 | + --profile TEXT unique name for managing each independent settings | ||
105 | + -f, --file FILENAME patch file containing git diff (e.g. file created by | ||
106 | + `git add` and `git diff --cached > test.diff`) | ||
107 | + | ||
108 | + -v, --verbose print suggested commit message more detail. | ||
109 | + -a, --autocommit automatically commit without asking if you want to | ||
110 | + commit | ||
111 | + | ||
112 | + --help Show this message and exit. | ||
113 | + | ||
114 | +Commands: | ||
115 | + configure | ||
116 | +``` | ||
117 | + | ||
118 | +### Training detail | ||
119 | +Refer [How to train for your lint style](docs/training.md). This allows you to re-fine tuning to your repository's commit lint style. | ||
120 | + | ||
121 | +### Contribution | ||
122 | +You can contribute anything, even a typo or code in the article. Don't hesitate!!. | ||
123 | +Versions are managed only within the branch with the name of each version. After being released on Pypi, it is merged into the master branch and new development proceeds in the upgraded version branch. | ||
124 | + | ||
125 | +### Author | ||
126 | +[Tae Hwan Jung(@graykode)](https://github.com/graykode) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
images/demo.gif
0 → 100644
27.2 KB
... | @@ -16,7 +16,7 @@ import os | ... | @@ -16,7 +16,7 @@ import os |
16 | from setuptools import setup, find_packages | 16 | from setuptools import setup, find_packages |
17 | 17 | ||
18 | project_name = "commit" | 18 | project_name = "commit" |
19 | -version = os.environ.get('COMMIT_VERSION', '0.0.1') | 19 | +version = os.environ.get('COMMIT_VERSION', '0.0.0') |
20 | 20 | ||
21 | if __name__ == "__main__": | 21 | if __name__ == "__main__": |
22 | 22 | ||
... | @@ -33,7 +33,7 @@ if __name__ == "__main__": | ... | @@ -33,7 +33,7 @@ if __name__ == "__main__": |
33 | license="Apache License, Version 2.0", | 33 | license="Apache License, Version 2.0", |
34 | author="TaeHwan-Jung", | 34 | author="TaeHwan-Jung", |
35 | author_email="nlkey2022@gmail.com", | 35 | author_email="nlkey2022@gmail.com", |
36 | - description="", | 36 | + description="A tool that AI automatically recommends commit messages.", |
37 | url="https://github.com/graykode/commit-autosuggestions", | 37 | url="https://github.com/graykode/commit-autosuggestions", |
38 | # Platform, Requires | 38 | # Platform, Requires |
39 | python_requires=">=3.5", | 39 | python_requires=">=3.5", | ... | ... |
-
Please register or login to post a comment