Skip to content

Commit

Permalink
Update docs for user inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardusrendy committed Aug 6, 2024
1 parent dd573a8 commit c5b5688
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
25 changes: 21 additions & 4 deletions alab_management/lab_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,33 @@ def run_subtask(
return result

def request_user_input(self, prompt: str, options: list[str]) -> str:
"""Request user input from the user. This function will block until the user inputs something. Returns the
value returned by the user.
"""
Request user input from the user. This function will block until the user inputs something.
Args:
prompt (str): The prompt to display to the user.
options (list[str]): A list of options to display to the user.
Returns
-------
response (str): The value returned by the user (from the buttons).
"""
return request_user_input(task_id=self.task_id, prompt=prompt, options=options)

def request_user_input_with_note(
self, prompt: str, options: list[str]
) -> tuple[str, str]:
"""Request user input from the user. This function will block until the user inputs something. Returns the
value returned by the user and the note.
"""
Request user input from the user. This function will block until the user inputs something.
Args:
prompt (str): The prompt to display to the user.
options (list[str]): A list of options to display to the user.
Returns
-------
response (str): The value returned by the user (from the buttons).
note (str): The note returned by the user.
"""
return request_user_input_with_note(
task_id=self.task_id, prompt=prompt, options=options
Expand Down
43 changes: 27 additions & 16 deletions alab_management/user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,15 @@ def request_user_input(
"""
Request user input through the dashboard. Blocks until response is given.
task_id (ObjectId): task id requesting user input
prompt (str): prompt to give user
options (List[str]): response options to give user
maintenance (bool): if true, mark this as a request for overall system maintenance
Returns user response as string.
Args:
task_id (ObjectId): task id requesting user input
prompt (str): prompt to give user
options (List[str]): response options to give user
maintenance (bool): if true, mark this as a request for overall system maintenance
Returns
-------
response (str): user response as string
"""
user_input_view = UserInputView()
request_id = user_input_view.insert_request(
Expand All @@ -195,11 +198,15 @@ def request_user_input(

def request_maintenance_input(prompt: str, options: list[str]):
"""
Request user input through the dashboard. Blocks until response is given.
Request user input for maintenance through the dashboard. Blocks until response is given.
Args:
prompt: prompt to give user
options: response options to give user
prompt (str): prompt to give user
options (List[str]): response options to give user
Returns
-------
response (str): user response as string
"""
return request_user_input(
task_id=None,
Expand All @@ -218,14 +225,18 @@ def request_user_input_with_note(
category: str = "Unknown Category",
) -> tuple[str, str]:
"""
Request user input through the dashboard. Blocks until response is given.
task_id (ObjectId): task id requesting user input
prompt (str): prompt to give user
options (List[str]): response options to give user
maintenance (bool): if true, mark this as a request for overall system maintenance
Request user input through the dashboard. Blocks until response. Returns response and note.
Returns user response as string.
Args:
task_id (ObjectId): task id requesting user input
prompt (str): prompt to give user
options (List[str]): response options to give user
maintenance (bool): if true, mark this as a request for overall system maintenance
Returns
-------
response (str): user response as string
note (str): note from the user
"""
user_input_view = UserInputView()
request_id = user_input_view.insert_request(
Expand Down

0 comments on commit c5b5688

Please sign in to comment.