Skip to content

Commit 98bcb3d

Browse files
authored
Parse all lines in app file looking for shebangs to run commands. (#15714)
fixed command parsing so that all lines in the file are parsed
1 parent ee517f3 commit 98bcb3d

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/lightning_app/utilities/app_commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ def _extract_commands_from_file(file_name: str) -> CommandLines:
3838
file_lines = f.readlines()
3939

4040
for line_number, line in enumerate(file_lines):
41-
if line.strip() in APP_COMMAND_LINES_TO_IGNORE:
41+
line = line.strip()
42+
if line in APP_COMMAND_LINES_TO_IGNORE:
4243
continue
4344

4445
# stop parsing at first non-comment line at top of file
4546
if not line.startswith("#"):
46-
break
47+
continue
4748

4849
# remove comment marker and any leading / trailing whitespaces
4950
line = line.lstrip("#").strip()

tests/tests_app/utilities/test_app_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
("multiple_commands.txt", ['echo "foo"', 'echo "bar"'], [1, 2]),
1515
("commands_with_mixed_comments_1.txt", ['echo "foo"', 'echo "bar"'], [1, 3]),
1616
("commands_with_mixed_comments_2.txt", ['echo "foo"', 'echo "bar"'], [2, 4]),
17-
("command_after_first_non_comment_line.txt", ['echo "foo"'], [1]),
17+
("command_after_first_non_comment_line.txt", ['echo "foo"', 'echo "bar"'], [2, 4]),
1818
("bang_not_at_start_of_line.txt", ['echo "foo"'], [2]),
1919
("space_between_bang_and_command.txt", ['echo "foo"'], [1]),
2020
("multiple_spaces_between_band_and_command.txt", ['echo "foo"'], [1]),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# !echo "foo"
23
import lighting
34
# !echo "bar"

0 commit comments

Comments
 (0)