-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inline script parsing issues (#574)
Fixes #572 The fix makes the function parser a bit more robust by round-tripping through ast parse/unparse. This ensures we get consistently formatted code each time and removes any extraneous comments which were previously causing parsing issues. Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
- Loading branch information
Showing
49 changed files
with
1,195 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,8 +84,6 @@ | |
except: message = r''''''{{inputs.parameters.message}}'''''' | ||
|
||
|
||
print(message) | ||
|
||
' | ||
print(message)' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,6 @@ | |
|
||
sys.path.append(os.getcwd()) | ||
|
||
print("hello") | ||
|
||
' | ||
print(''hello'')' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Script Variations | ||
|
||
|
||
|
||
|
||
|
||
|
||
=== "Hera" | ||
|
||
```python linenums="1" | ||
from hera.workflows import Workflow, script | ||
|
||
|
||
@script() | ||
def hello_world(): # pragma: no cover | ||
print("Hello World!") | ||
|
||
|
||
@script() | ||
def multiline_function( | ||
test: str, | ||
another_test: str, | ||
) -> str: # pragma: no cover | ||
print("Hello World!") | ||
|
||
|
||
with Workflow(generate_name="fv-test-", entrypoint="d") as w: | ||
hello_world() | ||
multiline_function() | ||
``` | ||
|
||
=== "YAML" | ||
|
||
```yaml linenums="1" | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: fv-test- | ||
spec: | ||
entrypoint: d | ||
templates: | ||
- name: hello-world | ||
script: | ||
command: | ||
- python | ||
image: python:3.8 | ||
source: 'import os | ||
|
||
import sys | ||
|
||
sys.path.append(os.getcwd()) | ||
|
||
print(''Hello World!'')' | ||
- inputs: | ||
parameters: | ||
- name: test | ||
- name: another_test | ||
name: multiline-function | ||
script: | ||
command: | ||
- python | ||
image: python:3.8 | ||
source: 'import os | ||
|
||
import sys | ||
|
||
sys.path.append(os.getcwd()) | ||
|
||
import json | ||
|
||
try: another_test = json.loads(r''''''{{inputs.parameters.another_test}}'''''') | ||
|
||
except: another_test = r''''''{{inputs.parameters.another_test}}'''''' | ||
|
||
try: test = json.loads(r''''''{{inputs.parameters.test}}'''''') | ||
|
||
except: test = r''''''{{inputs.parameters.test}}'''''' | ||
|
||
|
||
print(''Hello World!'')' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,8 +102,6 @@ | |
except: c = r''''''{{inputs.parameters.c}}'''''' | ||
|
||
|
||
print(a, b, c) | ||
|
||
' | ||
print(a, b, c)' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,6 @@ | |
|
||
sys.path.append(os.getcwd()) | ||
|
||
print("ok") | ||
|
||
' | ||
print(''ok'')' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.