You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to think of Mephisto's output from a user-first perspective. Here's a mockup of what a more friendly output stream could look like. In this case, I move away from just using logging as output as mentioned in #386 and focus on a more first-class support for CLI output.
GIF:
Still image:
Mockup source:
Requires the rich package, pip install rich:
fromtimeimportsleepfromrich.consoleimportConsolefromrich.promptimportConfirmconsole=Console()
DELAY_OFF=0defprint_summary(task):
fromrich.tableimportTable, Columnfromrichimportboximportlocalelocale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
table=Table("property", Column("value", style="magenta bold"), "description", title="Task Launch Preview", box=box.ROUNDED, expand=True, show_lines=True)
# table = Table("task_name", "blueprint", "architect", "crowd provider", "requester", title="Task Launch Preview")# table.add_row("my_custom_task", "simple_static_task", "local", "mturk_sanbox", "demo")table.add_row("task_name", "my_custom_task", "ID used to later query all HITs launched in this run.\nConfigure via: task.task_name.")
table.add_row("blueprint", "simple_static_task", "The base template for your task. Can be found in the folder: mephisto/abstractions/blueprints.")
table.add_row("architect", "local", "Where this task will be hosted/launched from. Configure via: mephisto/architect=...")
table.add_row("crowd provider", "mturk_sandbox", "The underlying platform that supplies the crowdworkers (e.g. mturk, mturk_sandbox).")
table.add_row("requester", "demo", "The account/budget to run the task through. Configure via: mephisto.provider.requester_name=... Or use the mephisto CLI for more info: 'mephisto requesters'")
console.print(table)
billing_table=Table("num HITs", "price", "estimated total", title="Estimated Costs")
billing_table.add_row(str(task['hits']), locale.currency(0.02), f"[bold green]{locale.currency(task['hits'] *0.02)}[/bold green]")
console.print(billing_table)
deflog(category, message):
returnf"[dim]{category}[/dim] - {message}"defprepare_router():
console.log(log("router/install", "npm install (hidden, show with 'build.show_npm_output: true')"))
sleep(1*DELAY_OFF)
console.log(log("router/install", "npm build (hidden, show with 'build.show_npm_output: true')"))
sleep(2*DELAY_OFF)
console.log(log("router/install", "completed npm build"))
console.log(log("operator/launch", "created a task run under name: 'react-static-task-example'"))
defprepare_architect():
console.log(log("architect/deploy", "building payload"))
sleep(1*DELAY_OFF)
console.log(log("architect/deploy", "sending payload to final destination"))
sleep(2*DELAY_OFF)
console.log(log("architect/deploy", "deployed successfully"))
deflaunch_tasks(console):
fromrich.emojiimportEmojipreview_url="http://localhost:3000"assignment_url="http://localhost:3000/?worker_id=x&assignment_id="forjobinrange(3):
# console.log(f":rocket: Launched Assignment {job+1}. Preview: '{preview_url}' | Assignment: '{assignment_url}{job+1}'")console.log(log(f":rocket: assignment/launch", f"assignment ID: {job+1}\nPreview: '{preview_url}'\nAssignment: '{assignment_url}{job+1}'"))
sleep(0.1)
sleep(2*DELAY_OFF)
defstart():
task= { "hits": 500}
print_summary(task)
confirm=Confirm.ask(f"[bold]Are you sure you would like to proceed launching {task['hits']} HITs?[/bold]")
ifnotconfirm:
returnwithconsole.status("[bold green]Setting up router...") asstatus:
prepare_router()
withconsole.status("[bold green]Invoking architect...") asstatus:
prepare_architect()
fromrich.progressimportProgresswithProgress(transient=True) asprogress:
task=progress.add_task("[bold green]Launching tasks...", total=3)
sleep(1)
launch_tasks(progress.console)
# simulate completion:forjobinrange(3):
sleep(1.5)
ifjob==1:
progress.console.log(log(f"[yellow]:hourglass: assignment/update", f"Assignment {job+1} timed-out."))
else:
progress.console.log(log(f"[green]:inbox_tray: assignment/update", f"Assignment {job+1} received."))
progress.advance(task)
sleep(1)
console.log("Finished launching 3 tasks.")
# with console.status("[bold green]Launching tasks...", spinner="earth") as status:# launch_tasks()start()
The text was updated successfully, but these errors were encountered:
Adding this to a milestone, as considering we already have rich as part of elsewhere in our CLI it shouldn't be a large stretch to get it running for task launches as well.
@JackUrb@pringshia I don't think #869 really covers everything suggested in this issue (as that PR only covers logging and this is more about the output when running the task itself).
Logging was a pretty serious concern for this experience, but I do see that there's more to it. I'd suggest having a different issue for the Mephisto OperatorTUI instead.
It would be great to think of Mephisto's output from a user-first perspective. Here's a mockup of what a more friendly output stream could look like. In this case, I move away from just using logging as output as mentioned in #386 and focus on a more first-class support for CLI output.
GIF:
Still image:
Mockup source:
Requires the
rich
package,pip install rich
:The text was updated successfully, but these errors were encountered: