graykode

(refactor) rename autocommit to commit-autosuggestions

# autocommit
\ No newline at end of file
......@@ -20,9 +20,9 @@ import torch.nn as nn
from torch.utils.data import TensorDataset, DataLoader, SequentialSampler
from transformers import (RobertaConfig, RobertaTokenizer)
from autocommit.model import Seq2Seq
from autocommit.utils import (Example, convert_examples_to_features)
from autocommit.model.diff_roberta import RobertaModel
from commit.model import Seq2Seq
from commit.utils import (Example, convert_examples_to_features)
from commit.model.diff_roberta import RobertaModel
from flask import Flask, jsonify, request
......
......@@ -27,7 +27,7 @@ def tokenizing(code):
)
return json.loads(res.text)["tokens"]
def autocommit(diffs):
def autosuggestions(diffs):
commit_message = []
for idx, example in enumerate(whatthepatch.parse_patch(diffs)):
if not example.changes:
......@@ -50,7 +50,9 @@ def autocommit(diffs):
data=json.dumps(data),
headers=args.headers
)
commit_message.append(json.loads(res.text))
commit = json.loads(res.text)
commit.update({'path' : example.header.new_path})
commit_message.append(commit)
else:
data = {"idx": idx, "added": added, "deleted": deleted}
res = requests.post(
......@@ -58,7 +60,9 @@ def autocommit(diffs):
data=json.dumps(data),
headers=args.headers
)
commit_message.append(json.loads(res.text))
commit = json.loads(res.text)
commit.update({'path': example.header.new_path})
commit_message.append(commit)
return commit_message
def main():
......@@ -69,7 +73,7 @@ def main():
staged_files = [f.strip() for f in staged_files]
diffs = "\n".join(staged_files)
message = autocommit(diffs=diffs)
message = autosuggestions(diffs=diffs)
print(message)
if __name__ == '__main__':
......
......@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from autocommit.model.diff_roberta import RobertaModel
from autocommit.model.model import Seq2Seq
from commit.model.diff_roberta import RobertaModel
from commit.model.model import Seq2Seq
__all__ = [
'RobertaModel',
......
# Copyright 2020-present Tae Hwan Jung
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from setuptools import setup
project_name = "commit"
version = os.environ.get('COMMIT_VERSION', '0.0.0')
if __name__ == "__main__":
with open('README.md', 'r') as t:
README = t.read()
setup(
# Project Name, Version
name=project_name,
version=version,
long_description=README,
long_description_content_type='text/markdown',
# Author
license="Apache License, Version 2.0",
author="TaeHwan-Jung",
author_email="nlkey2022@gmail.com",
description="",
url="https://github.com/graykode/commit-autosuggestions",
# Platform, Requires
python_requires=">=3.5",
platforms=["any"],
project_urls={
"Source Code": "https://github.com/graykode/commit-autosuggestions",
},
entry_points={
'console_scripts': [
'commit=commit.__main__:main',
],
}
)
\ No newline at end of file
......@@ -37,8 +37,8 @@ from torch.utils.data.distributed import DistributedSampler
from transformers import (AdamW, get_linear_schedule_with_warmup, RobertaConfig, RobertaTokenizer)
import bleu
from autocommit.model import Seq2Seq, RobertaModel
from autocommit.utils import (convert_examples_to_features, Example)
from commit.model import Seq2Seq, RobertaModel
from commit.utils import (convert_examples_to_features, Example)
MODEL_CLASSES = {'roberta': (RobertaConfig, RobertaModel, RobertaTokenizer)}
......