Showing
12 changed files
with
65 additions
and
11 deletions
File moved
... | @@ -20,9 +20,9 @@ import torch.nn as nn | ... | @@ -20,9 +20,9 @@ import torch.nn as nn |
20 | from torch.utils.data import TensorDataset, DataLoader, SequentialSampler | 20 | from torch.utils.data import TensorDataset, DataLoader, SequentialSampler |
21 | from transformers import (RobertaConfig, RobertaTokenizer) | 21 | from transformers import (RobertaConfig, RobertaTokenizer) |
22 | 22 | ||
23 | -from autocommit.model import Seq2Seq | 23 | +from commit.model import Seq2Seq |
24 | -from autocommit.utils import (Example, convert_examples_to_features) | 24 | +from commit.utils import (Example, convert_examples_to_features) |
25 | -from autocommit.model.diff_roberta import RobertaModel | 25 | +from commit.model.diff_roberta import RobertaModel |
26 | 26 | ||
27 | from flask import Flask, jsonify, request | 27 | from flask import Flask, jsonify, request |
28 | 28 | ... | ... |
... | @@ -27,7 +27,7 @@ def tokenizing(code): | ... | @@ -27,7 +27,7 @@ def tokenizing(code): |
27 | ) | 27 | ) |
28 | return json.loads(res.text)["tokens"] | 28 | return json.loads(res.text)["tokens"] |
29 | 29 | ||
30 | -def autocommit(diffs): | 30 | +def autosuggestions(diffs): |
31 | commit_message = [] | 31 | commit_message = [] |
32 | for idx, example in enumerate(whatthepatch.parse_patch(diffs)): | 32 | for idx, example in enumerate(whatthepatch.parse_patch(diffs)): |
33 | if not example.changes: | 33 | if not example.changes: |
... | @@ -50,7 +50,9 @@ def autocommit(diffs): | ... | @@ -50,7 +50,9 @@ def autocommit(diffs): |
50 | data=json.dumps(data), | 50 | data=json.dumps(data), |
51 | headers=args.headers | 51 | headers=args.headers |
52 | ) | 52 | ) |
53 | - commit_message.append(json.loads(res.text)) | 53 | + commit = json.loads(res.text) |
54 | + commit.update({'path' : example.header.new_path}) | ||
55 | + commit_message.append(commit) | ||
54 | else: | 56 | else: |
55 | data = {"idx": idx, "added": added, "deleted": deleted} | 57 | data = {"idx": idx, "added": added, "deleted": deleted} |
56 | res = requests.post( | 58 | res = requests.post( |
... | @@ -58,7 +60,9 @@ def autocommit(diffs): | ... | @@ -58,7 +60,9 @@ def autocommit(diffs): |
58 | data=json.dumps(data), | 60 | data=json.dumps(data), |
59 | headers=args.headers | 61 | headers=args.headers |
60 | ) | 62 | ) |
61 | - commit_message.append(json.loads(res.text)) | 63 | + commit = json.loads(res.text) |
64 | + commit.update({'path': example.header.new_path}) | ||
65 | + commit_message.append(commit) | ||
62 | return commit_message | 66 | return commit_message |
63 | 67 | ||
64 | def main(): | 68 | def main(): |
... | @@ -69,7 +73,7 @@ def main(): | ... | @@ -69,7 +73,7 @@ def main(): |
69 | staged_files = [f.strip() for f in staged_files] | 73 | staged_files = [f.strip() for f in staged_files] |
70 | diffs = "\n".join(staged_files) | 74 | diffs = "\n".join(staged_files) |
71 | 75 | ||
72 | - message = autocommit(diffs=diffs) | 76 | + message = autosuggestions(diffs=diffs) |
73 | print(message) | 77 | print(message) |
74 | 78 | ||
75 | if __name__ == '__main__': | 79 | if __name__ == '__main__': | ... | ... |
... | @@ -12,8 +12,8 @@ | ... | @@ -12,8 +12,8 @@ |
12 | # See the License for the specific language governing permissions and | 12 | # See the License for the specific language governing permissions and |
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | -from autocommit.model.diff_roberta import RobertaModel | 15 | +from commit.model.diff_roberta import RobertaModel |
16 | -from autocommit.model.model import Seq2Seq | 16 | +from commit.model.model import Seq2Seq |
17 | 17 | ||
18 | __all__ = [ | 18 | __all__ = [ |
19 | 'RobertaModel', | 19 | 'RobertaModel', | ... | ... |
File moved
setup.py
0 → 100644
1 | +# Copyright 2020-present Tae Hwan Jung | ||
2 | +# | ||
3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +# you may not use this file except in compliance with the License. | ||
5 | +# You may obtain a copy of the License at | ||
6 | +# | ||
7 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +# | ||
9 | +# Unless required by applicable law or agreed to in writing, software | ||
10 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +# See the License for the specific language governing permissions and | ||
13 | +# limitations under the License. | ||
14 | + | ||
15 | +import os | ||
16 | +from setuptools import setup | ||
17 | + | ||
18 | +project_name = "commit" | ||
19 | +version = os.environ.get('COMMIT_VERSION', '0.0.0') | ||
20 | + | ||
21 | +if __name__ == "__main__": | ||
22 | + | ||
23 | + with open('README.md', 'r') as t: | ||
24 | + README = t.read() | ||
25 | + | ||
26 | + setup( | ||
27 | + # Project Name, Version | ||
28 | + name=project_name, | ||
29 | + version=version, | ||
30 | + long_description=README, | ||
31 | + long_description_content_type='text/markdown', | ||
32 | + # Author | ||
33 | + license="Apache License, Version 2.0", | ||
34 | + author="TaeHwan-Jung", | ||
35 | + author_email="nlkey2022@gmail.com", | ||
36 | + description="", | ||
37 | + url="https://github.com/graykode/commit-autosuggestions", | ||
38 | + # Platform, Requires | ||
39 | + python_requires=">=3.5", | ||
40 | + platforms=["any"], | ||
41 | + project_urls={ | ||
42 | + "Source Code": "https://github.com/graykode/commit-autosuggestions", | ||
43 | + }, | ||
44 | + entry_points={ | ||
45 | + 'console_scripts': [ | ||
46 | + 'commit=commit.__main__:main', | ||
47 | + ], | ||
48 | + } | ||
49 | + ) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -37,8 +37,8 @@ from torch.utils.data.distributed import DistributedSampler | ... | @@ -37,8 +37,8 @@ from torch.utils.data.distributed import DistributedSampler |
37 | from transformers import (AdamW, get_linear_schedule_with_warmup, RobertaConfig, RobertaTokenizer) | 37 | from transformers import (AdamW, get_linear_schedule_with_warmup, RobertaConfig, RobertaTokenizer) |
38 | 38 | ||
39 | import bleu | 39 | import bleu |
40 | -from autocommit.model import Seq2Seq, RobertaModel | 40 | +from commit.model import Seq2Seq, RobertaModel |
41 | -from autocommit.utils import (convert_examples_to_features, Example) | 41 | +from commit.utils import (convert_examples_to_features, Example) |
42 | 42 | ||
43 | MODEL_CLASSES = {'roberta': (RobertaConfig, RobertaModel, RobertaTokenizer)} | 43 | MODEL_CLASSES = {'roberta': (RobertaConfig, RobertaModel, RobertaTokenizer)} |
44 | 44 | ... | ... |
-
Please register or login to post a comment