Skip to content

Commit 2717b35

Browse files
authored
UI/UX enhancements (#654)
* remove confusing error about refresh token expiration * package webui logfile in log packaging logic * mark dataset as prepared in webui if operational * show view result when task is running * add command to view the URL and token for webui * improve printed msgs during inference run * fix how ui.interactive works if nested * make result window scrollable * change profiles to settings in UI * change favicon * fix edge case bug in format_errors_dict * fix reading results for finalized executions * update version string * fix linter alert
1 parent 76af6a1 commit 2717b35

File tree

21 files changed

+99
-41
lines changed

21 files changed

+99
-41
lines changed

cli/medperf/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.4"
1+
__version__ = "0.1.5"

cli/medperf/account_management/account_management.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .token_storage import TokenStore
22
from medperf.config_management import read_config, write_config
33
from medperf import config
4-
from medperf.exceptions import MedperfException
4+
from medperf.exceptions import AuthenticationError
55

66

77
def read_user_account():
@@ -49,7 +49,7 @@ def set_credentials(
4949
def read_credentials():
5050
account_info = read_user_account()
5151
if account_info is None:
52-
raise MedperfException("You are not logged in")
52+
raise AuthenticationError("You are not logged in")
5353
email = account_info["email"]
5454
access_token, refresh_token = TokenStore().read_tokens(email)
5555

@@ -63,7 +63,7 @@ def read_credentials():
6363
def delete_credentials():
6464
config_p = read_config()
6565
if config.credentials_keyword not in config_p.active_profile:
66-
raise MedperfException("You are not logged in")
66+
raise AuthenticationError("You are not logged in")
6767

6868
email = config_p.active_profile[config.credentials_keyword]["email"]
6969
TokenStore().delete_tokens(email)
@@ -87,7 +87,7 @@ def get_medperf_user_data():
8787
"""Return cached medperf user data. Get from the server if not found"""
8888
config_p = read_config()
8989
if config.credentials_keyword not in config_p.active_profile:
90-
raise MedperfException("You are not logged in")
90+
raise AuthenticationError("You are not logged in")
9191

9292
medperf_user = config_p.active_profile[config.credentials_keyword].get(
9393
"medperf_user", None

cli/medperf/cli.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import medperf.commands.certificate.certificate as certificate
2323
import medperf.commands.storage as storage
2424
import medperf.web_ui.app as web_ui
25-
from medperf.utils import check_for_updates
25+
from medperf.utils import check_for_updates, get_webui_properties
2626
from medperf.logging.utils import log_machine_details
2727

2828
app = typer.Typer()
@@ -88,6 +88,13 @@ def execute(
8888
config.ui.print("✅ Done!")
8989

9090

91+
@app.command("get_webui_properties")
92+
@clean_except
93+
def get_webui_props():
94+
"""Prints necessary information to access an already-running medperf webui"""
95+
get_webui_properties()
96+
97+
9198
def version_callback(value: bool):
9299
if value:
93100
print(f"MedPerf version {__version__}")

cli/medperf/commands/execution/create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ def load_existing_executions(self):
178178
}
179179

180180
def __get_cube(self, uid: int, name: str) -> Cube:
181-
self.ui.text = f"Retrieving container '{name}'"
182181
cube = Cube.get(uid)
182+
self.ui.text = f"Retrieving {name} container '{cube.name}'"
183183
cube.download_run_files()
184-
self.ui.print(f"> Container '{name}' download complete")
184+
self.ui.print(f"> {name} Container '{cube.name}' download complete")
185185
return cube
186186

187187
def run_experiments(self) -> list[Execution]:

cli/medperf/commands/execution/execution_flow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def set_pending_status(self):
106106
self.__send_evaluator_report("pending")
107107

108108
def run_inference(self):
109-
self.ui.text = "Running model inference on dataset"
109+
self.ui.text = f"Running inference of model '{self.model.name}' on dataset"
110110
infer_timeout = config.infer_timeout
111111
inference_mounts = {
112112
"data_path": self.dataset.data_path,
@@ -138,15 +138,14 @@ def run_inference(self):
138138
self.__send_model_report("finished")
139139

140140
def run_evaluation(self):
141-
self.ui.text = "Running model evaluation on dataset"
141+
self.ui.text = f"Calculating metrics for model '{self.model.name}' predictions"
142142
evaluate_timeout = config.evaluate_timeout
143143
evaluator_mounts = {
144144
"predictions": self.preds_path,
145145
"labels": self.dataset.labels_path,
146146
"output_path": self.results_path,
147147
"local_outputs_path": self.local_outputs_path,
148148
}
149-
self.ui.text = "Evaluating results"
150149
self.__send_evaluator_report("started")
151150
try:
152151
self.evaluator.run(

cli/medperf/comms/auth/auth0.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ def __check_token_email(self, id_token_payload, email):
138138
def logout(self):
139139
"""Logs out the user by revoking their refresh token and deleting the
140140
stored tokens."""
141-
142-
creds = read_credentials()
141+
try:
142+
creds = read_credentials()
143+
except AuthenticationError:
144+
return
143145
refresh_token = creds["refresh_token"]
144146

145147
url = f"https://{self.domain}/oauth/revoke"

cli/medperf/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
creds_folder = str(config_storage / ".tokens")
5555
tokens_db = str(config_storage / ".tokens_db")
5656
pki_assets = str(config_storage / ".pki_assets")
57+
webui_host_props = str(config_storage / ".webui_host_props")
5758

5859
# TODO: should we change this?
5960
safe_root = "" # Base path to accept input paths from user.

cli/medperf/entities/execution.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def save_results(self, results, partial):
8585
pass
8686

8787
def read_results(self):
88+
if self.finalized:
89+
return self.results
8890
with open(self.results_path) as f:
8991
results = yaml.safe_load(f)
9092
return results

cli/medperf/logging/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def package_logs():
208208
logfiles = []
209209
for file in files:
210210
is_logfile = re.match(r"medperf\.log(?:\.\d+)?$", file) is not None
211-
if is_logfile:
211+
is_webui_logfile = re.match(r"medperf_webui\.log(?:\.\d+)?$", file) is not None
212+
if is_logfile or is_webui_logfile:
212213
logfiles.append(file)
213214

214215
package_file = os.path.join(config.logs_storage, config.log_package_file)

cli/medperf/storage/__init__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ def __apply_login_tracking_migrations(config_p: ConfigManager):
5151
if config.credentials_keyword in config_p.active_profile:
5252
# So the user is logged in
5353
if "logged_in_at" not in config_p.active_profile[config.credentials_keyword]:
54-
# Apply migration. We will set it to the current time, since this
55-
# will make sure they will not be logged out before the actual refresh
56-
# token expiration (for a better user experience). However, currently logged
57-
# in users will still face a confusing error when the refresh token expires.
58-
config_p.active_profile[config.credentials_keyword][
59-
"logged_in_at"
60-
] = time.time()
54+
# Apply migration. We will set it to an old time to make sure users no longer
55+
# face a confusing error about refresh token expiration.
56+
config_p.active_profile[config.credentials_keyword]["logged_in_at"] = (
57+
time.time() - 2 * config.token_absolute_expiry
58+
)
6159

6260

6361
def __apply_results_to_executions_migrations(config_p):

0 commit comments

Comments
 (0)