Skip to content

Commit

Permalink
Added schema definition for yaml files in .neuro (#699)
Browse files Browse the repository at this point in the history
* Added schema definition for yaml files in .neuro

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added changelog

* always keep schema comment on template init

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changed changelog from misc to feature

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* removed reference to IntelliSense

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jordyantunes and pre-commit-ci[bot] authored Nov 28, 2024
1 parent adfdd1f commit 7f261bd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.D/699.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This version includes changes to the workflow and project configuration files to enable code completion and validation by adding schema references to Apolo's config yaml files. These changes will improve the development experience by providing better code completion and validation.

Changes:

{{cookiecutter.flow_dir}}/.neuro/live.yml: Added schema reference for code completion support in the live workflow configuration file.
{{cookiecutter.flow_dir}}/.neuro/project.yml: Added schema reference for code completion support in the project configuration file.
4 changes: 2 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ async def get_project_name() -> str:

# >>> Optionally clearing comments
COMMENTS_STRUCTURE = {
"./.neuro/live.yml": r"(\s*#.*)",
"./.neuro/project.yml": r"(\s*#.*)",
"./.neuro/live.yml": r"(\s*#(?! yaml-language-server).*)",
"./.neuro/project.yml": r"(\s*#(?! yaml-language-server).*)",
}
PRESERVE_HINTS_VARIANS = {
"yes": True,
Expand Down
18 changes: 15 additions & 3 deletions tests/unit/test_bake_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re
import sys
from pathlib import Path

Expand Down Expand Up @@ -82,12 +83,23 @@ def test_flow_config_with_comments(cookies: Cookies, preserve_comments: str) ->
}
)
assert result.exit_code == 0
comment_sign = "#"
comment_regex = re.compile(r"(\s*#(?! yaml-language-server).*)")
with inside_dir(str(result.project_path)):
live_file_content = Path(".neuro/live.yml").read_text()
project_file_content = Path(".neuro/project.yml").read_text()
l_com_exists = comment_sign in live_file_content
p_com_exists = comment_sign in project_file_content

l_com_exists = any(
[
comment_regex.match(line) is not None
for line in live_file_content.splitlines()
]
)
p_com_exists = any(
[
comment_regex.match(line) is not None
for line in project_file_content.splitlines()
]
)
if preserve_comments == "yes":
assert l_com_exists, ".neuro/live.yml file does not contain comments"
assert p_com_exists, ".neuro/project.yml file does not contain comments"
Expand Down
2 changes: 2 additions & 0 deletions {{cookiecutter.flow_dir}}/.neuro/live.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/neuro-inc/neuro-flow/refs/heads/master/src/apolo_flow/flow-schema.json
## Keep the preceding line to enable code completion for the workflow configuration file.
kind: live
## Required. Type of workflow, might be one of the following:
## - 'live' -- full reference at https://docs.apolo.us/apolo-flow-reference/workflow-syntax/live-workflow-syntax
Expand Down
2 changes: 2 additions & 0 deletions {{cookiecutter.flow_dir}}/.neuro/project.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/neuro-inc/neuro-flow/refs/heads/master/src/apolo_flow/project-schema.json
## Keep the preceding line to enable code completion for the project configuration file.
## Check our full reference documentation at https://docs.apolo.us/apolo-flow-reference/workflow-syntax/project-configuration-syntax
id: {{ cookiecutter.flow_id }}
## Could be referenced as $[[ project.id ]] or $[[ flow.project_id ]] contexts.
Expand Down

0 comments on commit 7f261bd

Please sign in to comment.