Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Megatron-LM
Commits
b07f1d0a
Commit
b07f1d0a
authored
Apr 01, 2020
by
Neel Kant
Browse files
Add linting script
parent
bf3ce751
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
scripts/linter.py
scripts/linter.py
+36
-0
No files found.
scripts/linter.py
0 → 100644
View file @
b07f1d0a
import
os
import
os.path
as
osp
import
pathlib
import
subprocess
def
recursively_lint_files
():
"""Recursively lint all python files in chosen subdirectories of megatron-lm"""
try
:
import
autopep8
except
ModuleNotFoundError
:
print
(
"Please first install autopep8 via `pip install autopep8`"
)
return
# get all python file paths from top level directory
file_dir
=
str
(
pathlib
.
Path
(
__file__
).
parent
.
absolute
())
working_dir
=
osp
.
join
(
file_dir
,
os
.
pardir
)
all_py_paths
=
set
(
os
.
path
.
join
(
working_dir
,
fname
)
for
fname
in
os
.
listdir
(
working_dir
)
if
".py"
in
fname
)
# get all python file paths from chosen subdirectories
check_dirs
=
[
'docker'
,
'megatron'
,
'openwebtext'
,
'scripts'
,
'tasks'
]
for
sub_dir
in
check_dirs
:
for
path
,
_
,
fnames
in
os
.
walk
(
osp
.
join
(
working_dir
,
sub_dir
)):
all_py_paths
.
update
(
set
(
osp
.
join
(
path
,
fname
)
for
fname
in
fnames
if
".py"
in
fname
))
print
(
"Linting the following: "
)
for
py_path
in
all_py_paths
:
print
(
py_path
)
command
=
'autopep8 --max-line-length 100 --aggressive --in-place {}'
.
format
(
py_path
)
subprocess
.
check_call
(
command
)
if
__name__
==
"__main__"
:
recursively_lint_files
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment