Skip to content

Commit e5ce3d6

Browse files
committed
Cleanup
1 parent 65bec71 commit e5ce3d6

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/cli/workflow.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,6 @@ def _load_workflow_text(workflow_file: str) -> str:
11151115
file_text = file.read()
11161116

11171117
sections = workflow_utils.parse_workflow_spec(file_text)
1118-
if 'workflow' not in sections:
1119-
raise osmo_errors.OSMOUserError('Workflow spec not found.')
11201118
return sections['workflow']
11211119

11221120

src/lib/utils/workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def parse_workflow_spec(workflow_spec: str) -> Dict[str, str]:
4444
Each top-level key (e.g. workflow:, resources:, default-values:) becomes an entry in the
4545
returned dict. The value is the full raw text block for that section, including the key line
4646
itself, with no YAML parsing applied. Raises OSMOUserError if any top-level key appears more
47-
than once.
47+
than once, or if no workflow section is present.
4848
"""
4949
section_pattern = re.compile(
5050
r'^([a-zA-Z][a-zA-Z0-9_-]*):(.*?)(?=^[a-zA-Z][a-zA-Z0-9_-]*:|\Z)',
@@ -58,4 +58,6 @@ def parse_workflow_spec(workflow_spec: str) -> Dict[str, str]:
5858
raise osmo_errors.OSMOUserError(
5959
f'Duplicate top-level key "{key}" found in the workflow spec.')
6060
sections[key] = raw_block
61+
if 'workflow' not in sections:
62+
raise osmo_errors.OSMOUserError('Workflow spec not found.')
6163
return sections

src/utils/job/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,4 @@ def update_status(self, database: connectors.PostgresConnector, status: AppStatu
293293

294294
def validate_app_content(app_content: str):
295295
""" Validate the app content """
296-
sections = workflow_utils.parse_workflow_spec(app_content)
297-
if 'workflow' not in sections:
298-
raise osmo_errors.OSMOUserError('Workflow spec not found.')
296+
workflow_utils.parse_workflow_spec(app_content)

src/utils/job/workflow.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,10 @@ def load_template_with_variables(self) -> str:
791791
if unknown_sections:
792792
raise osmo_errors.OSMOUserError(
793793
f'Unknown top-level keys in workflow spec: {sorted(unknown_sections)}')
794-
if 'workflow' not in sections:
795-
raise osmo_errors.OSMOUserError('Workflow spec not found.')
796794
file_text = sections['workflow']
797795
template_data: Dict[str, Any] = {}
798796
if 'default-values' in sections:
799-
template_data = yaml.safe_load(sections['default-values'])['default-values']
797+
template_data = yaml.safe_load(sections['default-values'])['default-values'] or {}
800798

801799
# Get CLI set values
802800
for data in self.set_variables:

0 commit comments

Comments
 (0)