-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
142 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/bin/bash | ||
|
||
pip install -r /docker/requirements.txt | ||
python3 /docker/map.py | ||
echo "Starting map python code" | ||
python3 /docker/map.py | ||
echo "Closing map python code" |
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,68 @@ | ||
"""Test client for validation""" | ||
|
||
import json | ||
import logging | ||
import os | ||
import pathlib as pl | ||
import time | ||
import uuid | ||
|
||
from osparc_filecomms import handshakers | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="Validation client: [%(filename)s:%(lineno)d] %(message)s", | ||
) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def main(): | ||
logger.info("Started validation client") | ||
|
||
client_uuid = str(uuid.uuid4()) | ||
task_uuid = str(uuid.uuid4()) | ||
client_input_path = pl.Path(os.environ["VALIDATION_CLIENT_INPUT_PATH"]) | ||
client_output_path = pl.Path(os.environ["VALIDATION_CLIENT_OUTPUT_PATH"]) | ||
input_tasks_path = client_output_path / "input_tasks.json" | ||
output_tasks_path = client_input_path / "output_tasks.json" | ||
|
||
this_dir = pl.Path(__file__).parent | ||
|
||
input_tasks_template_path = this_dir / "input_tasks_template.json" | ||
input_tasks = json.loads(input_tasks_template_path.read_text()) | ||
input_tasks["uuid"] = task_uuid | ||
input_tasks["caller_uuid"] = client_uuid | ||
|
||
handshaker = handshakers.FileHandshaker( | ||
client_uuid, | ||
client_input_path, | ||
client_output_path, | ||
is_initiator=False, | ||
verbose_level=logging.DEBUG, | ||
polling_interval=0.1, | ||
print_polling_interval=100, | ||
) | ||
map_uuid = handshaker.shake() | ||
input_tasks["map_uuid"] = map_uuid | ||
|
||
input_tasks_path.write_text(json.dumps(input_tasks)) | ||
|
||
while not os.path.exists(output_tasks_path): | ||
time.sleep(0.1) | ||
|
||
output_tasks = json.loads(output_tasks_path.read_text()) | ||
|
||
assert output_tasks["uuid"] == task_uuid | ||
|
||
logger.info(output_tasks) | ||
|
||
stop_command = { | ||
"caller_uuid": client_uuid, | ||
"map_uuid": map_uuid, | ||
"command": "stop", | ||
} | ||
input_tasks_path.write_text(json.dumps(stop_command)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
3 changes: 2 additions & 1 deletion
3
validation/inputs/input_2/input_tasks.json → validation-client/input_tasks_template.json
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"uuid": "23423432", | ||
"uuid": "dummy", | ||
"caller_uuid": "dummy", | ||
"command": "run", | ||
"tasks": [ | ||
{ | ||
|
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