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

MCS-1982 - [Webenabled] Attempting Unavailable Action Waits until Timeout #709

Merged
merged 1 commit into from
Dec 11, 2023
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
19 changes: 17 additions & 2 deletions webenabled/mcs_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def _post_step_and_get_output(self, action: str, params=None):

return action_to_return, images, step_output

def check_for_error(self, elapsed):
# Shouldn't need to wait very long for errors like "invalid action"
secs_to_check = 1.0
if (elapsed > secs_to_check):
error_file_list = glob.glob(
self.step_output_dir + "/error_*.json")

return len(error_file_list) > 0

def get_images_and_step_output(self, startup=False, init_scene=False):
"""Watch the output directory and return the latest images and step
output that appears. If it does not appear in <timeout> seconds, then
Expand All @@ -214,8 +223,14 @@ def get_images_and_step_output(self, startup=False, init_scene=False):
self.img_name = self.blank_path
return [self.img_name], self.step_output

if elapsed > IMAGE_WAIT_TIMEOUT:
self.logger.info("Timeout waiting for image")
quick_error_check = self.check_for_error(elapsed)

if elapsed > IMAGE_WAIT_TIMEOUT or quick_error_check:
log_message = "Timeout waiting for image"
if (quick_error_check):
log_message = "Error returned from MCS controller."

self.logger.info(log_message)

list_of_error_files = glob.glob(
self.step_output_dir + "/error_*.json")
Expand Down
7 changes: 6 additions & 1 deletion webenabled/templates/mcs_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ <h1>Machine Common Sense</h1>
}

function runMultipleActions(action, totalCount) {
if (document.getElementById('scene-filename').innerHTML == "None - Please select a scene.") {
alert("Please select a scene before attempting an action.");
return;
}

console.log('run multiple actions: ' + action + ' x ' + totalCount);
processingKeypress = true;
loadingSpinner(true);
Expand Down Expand Up @@ -835,7 +840,7 @@ <h1>Machine Common Sense</h1>
return;
}

if (document.getElementById('scene-filename').innerHTML == "None") {
if (document.getElementById('scene-filename').innerHTML == "None - Please select a scene.") {
alert("Please select a scene before attempting an action.");
return;
}
Expand Down
Loading