From 88cb86b2050ec7557c7c164f6d8be534b05fc6c4 Mon Sep 17 00:00:00 2001 From: ninjinkun Date: Fri, 22 Jan 2021 12:52:43 +0900 Subject: [PATCH 1/2] fix: surpress print session ID in the subset command --- launchable/commands/record/session.py | 11 +++++++---- launchable/commands/record/tests.py | 2 +- launchable/commands/subset.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index 7bfee2fb4..93c546aa7 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -26,7 +26,12 @@ default=True, metavar='SESSION_FILE' ) -def session(build_name: str, save_session_file: bool): +def session(build_name: str, save_session_file: bool, print_session = True: bool): + """ + print_session is for barckward compatibility. + If you run this `record session` standalone, the command should print the session ID because v1.1 users expect the beheivior. That is why the flag is default True. + If you run this command from the other command such as `subset` and `record tests`, you should set print_session = False because users don't expect to print session ID to the subset output. + """ token, org, workspace = parse_token() headers = { @@ -44,9 +49,7 @@ def session(build_name: str, save_session_file: bool): if save_session_file: write_session(build_name, "{}/{}".format(session_path, session_id)) - # For backward compatibility prior v1.1 - click.echo("{}/{}".format(session_path, session_id)) - else: + if print_session: # what we print here gets captured and passed to `--session` in later commands click.echo("{}/{}".format(session_path, session_id)) diff --git a/launchable/commands/record/tests.py b/launchable/commands/record/tests.py index 092ea6db7..700670ecd 100644 --- a/launchable/commands/record/tests.py +++ b/launchable/commands/record/tests.py @@ -49,7 +49,7 @@ def tests(context, base_path: str, session_id: str, build_name: str): if build_name: session_id = read_session(build_name) if not session_id: - res = context.invoke(session, build_name=build_name, save_session_file=True) + res = context.invoke(session, build_name=build_name, save_session_file=True, print_session=False) session_id = read_session(build_name) else: raise click.UsageError( diff --git a/launchable/commands/subset.py b/launchable/commands/subset.py index 14e6fd863..666b76647 100644 --- a/launchable/commands/subset.py +++ b/launchable/commands/subset.py @@ -56,7 +56,7 @@ def subset(context, target, session_id, base_path: str, build_name: str): if build_name: session_id = read_session(build_name) if not session_id: - context.invoke(session, build_name=build_name, save_session_file=True) + context.invoke(session, build_name=build_name, save_session_file=True, print_session=False) session_id = read_session(build_name) else: raise click.UsageError( From 6e02bec3369e1641581ad801631107d5ea70dffc Mon Sep 17 00:00:00 2001 From: ninjinkun Date: Fri, 22 Jan 2021 13:00:15 +0900 Subject: [PATCH 2/2] fix: syntax --- launchable/commands/record/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index 93c546aa7..9f8696845 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -26,7 +26,7 @@ default=True, metavar='SESSION_FILE' ) -def session(build_name: str, save_session_file: bool, print_session = True: bool): +def session(build_name: str, save_session_file: bool, print_session: bool = True): """ print_session is for barckward compatibility. If you run this `record session` standalone, the command should print the session ID because v1.1 users expect the beheivior. That is why the flag is default True.