Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Develop] Updated QUICK_START_GUIDE.md #1397

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion QUICK_START_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ optional arguments:
-i INPUT, --input INPUT
Source of input data: images folder, image, webcam and video.
--load-weights LOAD_WEIGHTS
Load weights to run the evaluation. It could be a trained/optimized model or exported model.
Load weights to run the evaluation. It could be a trained/optimized model (POT only) or exported model.
--fit-to-size FIT_TO_SIZE FIT_TO_SIZE
Width and Height space-separated values. Fits displayed images to window with specified Width and Height. This options applies to result visualisation only.
--loop Enable reading the input in a loop.
Expand Down
50 changes: 35 additions & 15 deletions tests/ote_cli/misc/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,48 @@
class TestDocs:
@e2e_pytest_component
def test_help_stdoutputs_of_tools(self):
# read and gathering help command example and corresponding output from the doc
with open("QUICK_START_GUIDE.md", encoding="UTF-8") as read_file:
commands = []
msg_in_doc = []
msg_temp = ""
full_text = ''
found_help_cmd = False
cmd_idx = 0
for line in read_file:
full_text += line
if "ote" in line and "--help" in line:
commands.append(line.strip().split(' '))
if "$" in line and "ote" in line and "--help" in line:
commands.append(line.split("$")[-1].strip().split(' '))
found_help_cmd = True
elif found_help_cmd:
# grep all messages quoted with "```"
if "```" not in line:
if line == "...\n":
# some msg output is too long to put them all onto the doc.
# those will be marked as "..." to represent its shrinking
continue
msg_temp += msg_temp
else:
# tokenize msg in the doc by replacing whitespace to a single space
# for ease comparison with actual output messages
msg_in_doc.append(" ".join(msg_temp.split()))
msg_temp = ""
cmd_idx += 1
found_help_cmd = False

MAX_INDENT = 10
assert len(commands) == len(msg_in_doc), \
f"length of cmds & msg in doc is mismatched. len(cmds) = {len(commands)}, " \
f"len(msg_in_doc) = {len(msg_in_doc)}"

for command in commands:
output = run(command, capture_output=True)
help_message = output.stdout.decode()
found = True
if help_message not in full_text:
found = False
for _ in range(MAX_INDENT):
help_message = "\n".join([" " + line for line in help_message.split("\n")])
if help_message in full_text:
found = True
break
assert found, f"\nHelp message:\n{output.stdout.decode()}\n was not found in \n{full_text}"
# compare actual help message output & one that came from doc
for idx in range(len(commands)):
output = run(commands[idx], capture_output=True)
help_msg = output.stdout.decode()
# tokenize by replace all whitespace to a single space
help_msg = " ".join(help_msg.split())
# asserting with "in" op to deal with shrinked message as well
assert msg_in_doc[idx] in help_msg, \
f"help message in doc:\n{msg_in_doc[idx]}\nis not equal with stdout:\n{help_msg}"

@e2e_pytest_component
def test_algorithms_table(self):
Expand Down