Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bad0cd2
tests and general code cleanup for python api
mspruc Sep 4, 2025
817e939
Merge pull request #1 from mspruc/python-api-tests
mspruc Sep 4, 2025
8c4592f
rm unused configurations
mspruc Sep 4, 2025
2039859
add wayang.properties file for python api tests
mspruc Sep 8, 2025
9063e54
add python api configurations to test .properties file
mspruc Sep 8, 2025
796c3bf
expand exception msg
mspruc Sep 8, 2025
748270e
add common python3 config for resource .properties file
mspruc Nov 4, 2025
4e26257
add config to correct .properties file
mspruc Nov 4, 2025
881563a
try referring to two folders up
mspruc Nov 4, 2025
70c9918
update workflow
mspruc Nov 4, 2025
ed29104
rollback action version of cache & add license
mspruc Nov 4, 2025
7e45e99
refer to pywy src
mspruc Nov 4, 2025
6d72093
hardcode env path
mspruc Nov 4, 2025
9c82d38
add .properties for local testing & bump cloudpickle to 3.1.2
mspruc Nov 4, 2025
ae89953
roll back to python3.8
mspruc Nov 4, 2025
94987b6
remove tests as they only work for specific python versions
mspruc Nov 5, 2025
c4635a5
clean up imports
mspruc Nov 5, 2025
435f1b6
bump python version
mspruc Nov 5, 2025
2a56927
make tests compatible with pytest & and pytest to workflow
mspruc Nov 6, 2025
be3de2b
remove references to self
mspruc Nov 6, 2025
9b5a6e5
add pytest to requirements
mspruc Nov 6, 2025
d3fe274
move pytest unit testing to its own run block
mspruc Nov 6, 2025
bce3d74
add run tag to pytest
mspruc Nov 6, 2025
211f2f1
more info in exception msgs
mspruc Nov 10, 2025
5b762f2
fix up test_filter should now runnable from same directory as maven
mspruc Nov 10, 2025
09571da
add requests to requirements
mspruc Nov 10, 2025
31991c0
add resources folder & contents
mspruc Nov 10, 2025
fd8382a
licenses
mspruc Nov 10, 2025
5786d9f
license in __init__
mspruc Nov 10, 2025
9f1c811
change file type of sample_data
mspruc Nov 10, 2025
5760984
fix sample_data in test_filter
mspruc Nov 10, 2025
6bc722f
fix test
mspruc Nov 10, 2025
ccf9c7d
test data for test_json.py
mspruc Nov 10, 2025
35efdbd
move python tests after maven
mspruc Nov 10, 2025
e760a94
move python dependencies before maven tests so tests can use them
mspruc Nov 10, 2025
9218f3a
add missing arg to pytest
mspruc Nov 10, 2025
5e30917
add resources for json test
mspruc Nov 11, 2025
37b87fa
move over to mvn runner instead of bin
mspruc Nov 11, 2025
f81d012
enable custom properties file
mspruc Nov 11, 2025
860816f
add config to python test runner
mspruc Nov 11, 2025
365374f
add meta func for config files with pytest
mspruc Nov 11, 2025
d12149b
add test directory to pytest
mspruc Nov 11, 2025
27b036f
remove unused quotations
mspruc Nov 12, 2025
2487a46
add omitted comma
mspruc Nov 12, 2025
76ba1b6
disable test requiring missing implementations
mspruc Nov 12, 2025
e1ea95c
explicitly write pom to exec from, pytest should now be executable fr…
mspruc Nov 13, 2025
9b9c797
add better process waiting
mspruc Nov 13, 2025
670215d
maven process for test_json
mspruc Nov 13, 2025
4471bb0
make json api respect custom configs
mspruc Nov 17, 2025
c34ed59
rm test_join as joins are already tested in filter and it was not set…
mspruc Nov 17, 2025
85503b6
skip test missing impl
mspruc Nov 17, 2025
26f939c
update readme with pytest specifics
mspruc Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,30 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
- name: Install Protoc
run: sudo apt install -y protobuf-compiler
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r python/src/pywy/requirements.txt
- name: Build And Install
run: ./mvnw clean install -B -Dmaven.test.skip=true
- name: Run Unit tests
- name: Run Maven Unit tests
run: ./mvnw clean verify -B -Dmaven.test.skip=false -Dwayang.configuration=file:$(pwd)/tools/test/config/wayang.properties
- name: Run Python Unit tests
run: pytest -ra --config tools/test/config/wayang.properties python/src/pywy/tests/
3 changes: 3 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ def word_count():
if __name__ == "__main__":
word_count
```

### Testing python code
You can run the python tests by using pytest, the requirements for the tests are listed in `python/src/pywy/requirements.txt`. To run the tests navigate to the base wayang folder, e.g. `/var/www/html` and run `pytest -s python/src/pywy` if you need to pass a specific configuration for your use case you can also add a config flag `pytest -s --config=pathToYourConfig python/src/pywy/`
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import subprocess
import json
import requests

# Specify the API URL we want to send our JSON to
url = 'http://localhost:8080/wayang-api-json/submit-plan'
# Specify the appropriate header for the POST request
headers = {'Content-type': 'application/json'}

with open("/var/www/html/wayang-api/wayang-api-json/src/main/resources/plan-a.json") as f:
plan = json.load(f)
print(plan)

#with subprocess.Popen(["/var/www/html/wayang-assembly/target/wayang-0.7.1/bin/wayang-submit org.apache.wayang.api.json.springboot.SpringBootApplication"], stdout=subprocess.PIPE, shell=True) as proc:
#print("Started wayang-api-json")
#print(proc.stdout.read())
response = requests.post(url, headers=headers, json=plan)
print(response)
#print(proc.terminate())
# we support python 3.11
numpy==1.24.0
cloudpickle==3.1.2
pytest==8.3.5
requests==2.31.0
19 changes: 19 additions & 0 deletions python/src/pywy/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

def pytest_addoption(parser):
parser.addoption("--config", action="store", help="uses configuration path")
40 changes: 0 additions & 40 deletions python/src/pywy/tests/filter_test.py

This file was deleted.

45 changes: 0 additions & 45 deletions python/src/pywy/tests/join_test.py

This file was deleted.

16 changes: 16 additions & 0 deletions python/src/pywy/tests/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
61 changes: 61 additions & 0 deletions python/src/pywy/tests/resources/plan-a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"context": {
"platforms": [
"java",
"spark"
],
"origin": "python"
},
"operators": [
{
"id": 1,
"cat": "input",
"input": [],
"output": [2],
"operatorName": "textFileInput",
"data": {
"filename": "file:///var/www/html/data/wordcount-out-python.txt"
}
},
{
"id": 2,
"cat": "unary",
"input": [1],
"output": [3],
"operatorName": "map",
"data": {
"udf": "(s: String) => s.toInt"
}
},
{
"id": 3,
"cat": "unary",
"input": [2],
"output": [4],
"operatorName": "map",
"data": {
"udf": "(x: Int) => x + 1"
}
},
{
"id": 4,
"cat": "unary",
"input": [3],
"output": [5],
"operatorName": "filter",
"data": {
"udf": "(x: Int) => x >= 5"
}
},
{
"id": 5,
"cat": "output",
"input": [4],
"output": [],
"operatorName": "textFileOutput",
"data": {
"filename": "file:///var/www/html/data/wordcount-out-python.txt"
}
}
]
}
Loading
Loading