Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Commit-Analysis-ML
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ahmad, Rawel
Commit-Analysis-ML
Commits
e14d4a0f
Commit
e14d4a0f
authored
1 year ago
by
Rawel
Browse files
Options
Downloads
Patches
Plain Diff
main contains some errors regarding storing the data into the right folder, wrote a fixing class
parent
92b0d47d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classifier/fixing.py
+66
-0
66 additions, 0 deletions
Classifier/fixing.py
with
66 additions
and
0 deletions
Classifier/fixing.py
0 → 100644
+
66
−
0
View file @
e14d4a0f
import
glob
import
os
from
tqdm
import
tqdm
from
Data.Database.db_repository
import
DBRepository
abspath
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
os
.
chdir
(
abspath
)
def
get_relevant_entry
(
com_sha
,
config_code
,
is_fixing
):
col
=
"
fixing_sha
"
if
is_fixing
else
"
vcc_sha
"
entries
=
list
(
filter
(
lambda
entry
:
entry
[
col
]
==
com_sha
and
entry
[
"
fixing_config_code
"
]
==
config_code
,
mappings
))
if
len
(
entries
)
==
1
:
return
entries
[
0
]
ground_truth
=
list
(
filter
(
lambda
entry
:
entry
[
"
determined_by_heuristic
"
]
==
0
,
entries
))
if
len
(
ground_truth
)
>=
1
:
return
ground_truth
[
0
]
confident
=
list
(
filter
(
lambda
entry
:
entry
[
"
confidence_value
"
]
==
1
,
entries
))
if
len
(
confident
)
>=
1
:
return
confident
[
0
]
not_confident
=
list
(
filter
(
lambda
entry
:
entry
[
"
confidence_value
"
]
==
0
,
entries
))
if
len
(
not_confident
)
>=
1
:
return
not_confident
[
0
]
def
get_path
(
mapping
,
is_fixing
):
directory
=
"
Training/unclassified
"
if
is_fixing
else
"
Training/vccs
"
config_code
=
mapping
[
"
fixing_config_code
"
]
if
mapping
[
"
determined_by_heuristic
"
]
==
0
:
directory
=
f
"
{
directory
}
/
{
config_code
.
lower
()
}
/ground_truth
"
else
:
if
mapping
[
"
confidence_value
"
]
==
1
:
directory
=
f
"
{
directory
}
/
{
config_code
.
lower
()
}
/confident
"
else
:
directory
=
f
"
{
directory
}
/
{
config_code
.
lower
()
}
/not_confident
"
os
.
makedirs
(
directory
,
exist_ok
=
True
)
return
directory
def
main
():
global
mappings
db_repo
=
DBRepository
()
mappings
=
db_repo
.
get_all_mappings
()
vcc_paths
=
glob
.
glob
(
"
Training/vccs/**/*.json
"
,
recursive
=
True
)
for
path
in
tqdm
(
vcc_paths
):
[
_
,
_
,
config_code
,
_
,
file_name
]
=
path
.
split
(
"
/
"
)
com_sha
=
file_name
.
rstrip
(
"
.json
"
)
mapping
=
get_relevant_entry
(
com_sha
,
config_code
,
False
)
end_directory
=
f
"
{
get_path
(
mapping
,
False
)
}
/
{
file_name
}
"
os
.
rename
(
path
,
end_directory
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment