Toggle navigation
Toggle navigation
This project
Loading...
Sign in
graykode
/
commit-autosuggestions
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
graykode
2020-11-06 19:55:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
06b5a74a3ab1ab2effb670c1491e167acced87df
06b5a74a
1 parent
16c23c2e
(refactor) rename autocommit to commit-autosuggestions
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
65 additions
and
11 deletions
README.md
autocommit/__init__.py → commit/__init__.py
autocommit/app.py → commit/app.py
autocommit/commit.py → commit/commit.py
autocommit/model/__init__.py → commit/model/__init__.py
autocommit/model/diff_roberta.py → commit/model/diff_roberta.py
autocommit/model/model.py → commit/model/model.py
autocommit/utils.py → commit/utils.py
autocommit/weight/added/.keep → commit/weight/added/.keep
autocommit/weight/diff/.keep → commit/weight/diff/.keep
setup.py
train.py
README.md
0 → 100644
View file @
06b5a74
# autocommit
\ No newline at end of file
auto
commit/__init__.py
→
commit/__init__.py
View file @
06b5a74
File moved
auto
commit/app.py
→
commit/app.py
View file @
06b5a74
...
...
@@ -20,9 +20,9 @@ import torch.nn as nn
from
torch.utils.data
import
TensorDataset
,
DataLoader
,
SequentialSampler
from
transformers
import
(
RobertaConfig
,
RobertaTokenizer
)
from
auto
commit.model
import
Seq2Seq
from
auto
commit.utils
import
(
Example
,
convert_examples_to_features
)
from
auto
commit.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
...
...
auto
commit/commit.py
→
commit/commit.py
View file @
06b5a74
...
...
@@ -27,7 +27,7 @@ def tokenizing(code):
)
return
json
.
loads
(
res
.
text
)[
"tokens"
]
def
auto
commit
(
diffs
):
def
auto
suggestions
(
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
=
auto
commit
(
diffs
=
diffs
)
message
=
auto
suggestions
(
diffs
=
diffs
)
print
(
message
)
if
__name__
==
'__main__'
:
...
...
auto
commit/model/__init__.py
→
commit/model/__init__.py
View file @
06b5a74
...
...
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
auto
commit.model.diff_roberta
import
RobertaModel
from
auto
commit.model.model
import
Seq2Seq
from
commit.model.diff_roberta
import
RobertaModel
from
commit.model.model
import
Seq2Seq
__all__
=
[
'RobertaModel'
,
...
...
auto
commit/model/diff_roberta.py
→
commit/model/diff_roberta.py
View file @
06b5a74
File moved
auto
commit/model/model.py
→
commit/model/model.py
View file @
06b5a74
File moved
auto
commit/utils.py
→
commit/utils.py
View file @
06b5a74
File moved
auto
commit/weight/added/.keep
→
commit/weight/added/.keep
View file @
06b5a74
File moved
auto
commit/weight/diff/.keep
→
commit/weight/diff/.keep
View file @
06b5a74
File moved
setup.py
0 → 100644
View file @
06b5a74
# 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
train.py
View file @
06b5a74
...
...
@@ -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
auto
commit.model
import
Seq2Seq
,
RobertaModel
from
auto
commit.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
)}
...
...
Please
register
or
login
to post a comment