Skip to content

Commit 926aec5

Browse files
chor(test) : Fix kfp-sdk-test for different python versions (kubeflow#11559)
Signed-off-by: chahatsagarmain <[email protected]>
1 parent 51c776c commit 926aec5

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

.github/workflows/kfp-sdk-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Python
2525
uses: actions/setup-python@v4
2626
with:
27-
python-version: ${{ matrix.python }}
27+
python-version: ${{ matrix.python-version }}
2828

2929
- name: Run SDK Tests
3030
run: |

sdk/python/kfp/cli/utils/parsing.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ def get_param_descr(fn: Callable, param_name: str) -> str:
2525
fn (Callable): The function of method with a __doc__ docstring implemented.
2626
param_name (str): The parameter for which to extract the description.
2727
28-
Raises:
29-
ValueError: If docstring is not found or parameter is not found in docstring.
30-
3128
Returns:
3229
str: The description of the parameter.
3330
"""
@@ -38,32 +35,27 @@ def get_param_descr(fn: Callable, param_name: str) -> str:
3835
f'Could not find parameter {param_name} in docstring of {fn}')
3936
lines = docstring.splitlines()
4037

41-
# collect all lines beginning after args, also get indentation space_chars
38+
# Find Args section
4239
for i, line in enumerate(lines):
4340
if line.lstrip().startswith('Args:'):
4441
break
42+
else: # No Args section found
43+
raise ValueError(f'No Args section found in docstring of {fn}')
4544

4645
lines = lines[i + 1:]
47-
48-
first_already_found = False
49-
return_lines = []
50-
51-
# allow but don't require type in docstring
5246
first_line_args_regex = rf'^{param_name}( \(.*\))?: '
53-
for line in lines:
54-
if not first_already_found and re.match(first_line_args_regex,
55-
line.lstrip()):
56-
new_line = re.sub(first_line_args_regex, '', line.strip())
57-
return_lines.append(new_line)
58-
first_already_found = True
59-
first_indentation_level = len(line) - len(line.lstrip())
60-
continue
61-
62-
if first_already_found:
63-
indentation_level = len(line) - len(line.lstrip())
64-
if indentation_level <= first_indentation_level:
65-
return ' '.join(return_lines)
66-
else:
67-
return_lines.append(line.strip())
47+
for i, line in enumerate(lines):
48+
stripped = line.lstrip()
49+
match = re.match(first_line_args_regex, stripped)
50+
if match:
51+
description = [re.sub(first_line_args_regex, '', stripped)]
52+
# Collect any additional lines that are more indented
53+
current_indent = len(line) - len(stripped)
54+
for next_line in lines[i + 1:]:
55+
next_indent = len(next_line) - len(next_line.lstrip())
56+
if next_indent <= current_indent:
57+
break
58+
description.append(next_line.strip())
59+
return ' '.join(description)
6860
raise ValueError(
6961
f'Could not find parameter {param_name} in docstring of {fn}')

0 commit comments

Comments
 (0)