Skip to content

Commit 01adc8b

Browse files
authored
Neural Coder fix bugs (#394)
* Update handle_user_input.py * Update function.py * Update code_line.py
1 parent d1ac7b4 commit 01adc8b

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

neural_coder/graphers/code_line.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@ def register_code_line():
152152
# judge_1: indent is equal to def indent
153153
judge_1 = following_indent_level <= class_def_indent_level
154154
# judge_2: not starting with")"
155-
judge_2 = True if (
156-
following_line != "" and following_line[following_indent_level] != ")") else False
155+
try:
156+
judge_2 = True if (
157+
following_line != "" and following_line[following_indent_level] != ")") else False
158+
except:
159+
judge_2 = False
157160
# judge_3: is not a comment or empty line
158161
judge_3 = True if (
159162
not _is_multi_line_comment and not _is_single_line_comment_or_empty) else False
@@ -216,8 +219,11 @@ def register_code_line():
216219
# judge_1: indent is equal to def indent
217220
judge_1 = following_indent_level <= func_def_indent_level
218221
# judge_2: not starting with")"
219-
judge_2 = True if (
220-
following_line != "" and following_line[following_indent_level] != ")") else False
222+
try:
223+
judge_2 = True if (
224+
following_line != "" and following_line[following_indent_level] != ")") else False
225+
except:
226+
judge_2 = False
221227
# judge_3: is not a comment or empty line
222228
judge_3 = True if (
223229
not _is_multi_line_comment and not _is_single_line_comment_or_empty) else False

neural_coder/graphers/function.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ def c():
7979
# judge_1: indent is equal to def indent
8080
judge_1 = following_indent_level <= def_indent_level
8181
# judge_2: not starting with")"
82-
judge_2 = True if (
83-
following_line != "" and following_line[following_indent_level] != ")") else False
82+
try:
83+
judge_2 = True if (
84+
following_line != "" and following_line[following_indent_level] != ")") else False
85+
except:
86+
judge_2 = False
8487
# judge_3: is not a comment
8588
c1 = False
8689
c2 = False

neural_coder/utils/handle_user_input.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ def get_imports_path(user_code_path: List) -> List:
100100
"classy_vision",
101101
"collections",
102102
"contextlib",
103-
"datasets",
103+
"data",
104104
"dataclasses",
105+
"dataloader",
106+
"dataset",
107+
"datasets",
105108
"einops",
106109
"enum",
107110
"evaluate",
@@ -112,13 +115,17 @@ def get_imports_path(user_code_path: List) -> List:
112115
"importlib",
113116
"inspect",
114117
"intel_extension_for_pytorch",
118+
"itertools",
115119
"jax",
116120
"json",
117121
"keras",
118122
"libcst",
119123
"linecache",
120124
"logging",
125+
"loggings",
121126
"math",
127+
"model",
128+
"models",
122129
"neural_coder",
123130
"neural_compressor",
124131
"numpy",
@@ -131,6 +138,7 @@ def get_imports_path(user_code_path: List) -> List:
131138
"shutil",
132139
"subprocess",
133140
"sys",
141+
"system",
134142
"tempfile",
135143
"typing",
136144
"tensorflow",
@@ -141,11 +149,15 @@ def get_imports_path(user_code_path: List) -> List:
141149
"torchdynamo",
142150
"tqdm",
143151
"traceback",
152+
"trainer_qa",
144153
"unittest",
154+
"utils_qa",
145155
"vissl",
156+
"warning",
146157
"warnings",
147158
"packaging",
148159
"pytorch_lightning",
160+
"__future__",
149161
]
150162

151163
if globals.cache_load_transformers:

0 commit comments

Comments
 (0)