Skip to content

Commit

Permalink
Merge pull request #104 from launchableinc/fix/print-session-bug
Browse files Browse the repository at this point in the history
Surpress print session ID in the subset command
  • Loading branch information
ninjinkun authored Jan 22, 2021
2 parents fbae204 + 6e02bec commit ea1307a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions launchable/commands/record/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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.
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 = {
Expand All @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion launchable/commands/record/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion launchable/commands/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ea1307a

Please sign in to comment.