Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 3, 2022
1 parent c8eb0e0 commit 772bfae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/lightning_app/cli/cmd_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,3 @@ def echo_cluster_status_long(
message += f" [{duration_seconds(seconds_in_current_state)}]"

click.echo(message)

3 changes: 1 addition & 2 deletions src/lightning_app/utilities/string_formatting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

def duration_seconds(seconds: int) -> str:
"""Generates a duration string in 00h00m00s format."""
mins, seconds = divmod(seconds, 60)
Expand All @@ -9,4 +8,4 @@ def duration_seconds(seconds: int) -> str:
duration = f"{mins:02}m" + duration
if hours:
duration = f"{hours:02}h" + duration
return duration
return duration
23 changes: 13 additions & 10 deletions tests/tests_app/utilities/test_string_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
from lightning_app.utilities.string_formatting import duration_seconds


@pytest.mark.parametrize("seconds,want_string", [
(0, "00s"),
(0.1, "0.1s"),
(5, "05s"),
(50, "50s"),
(60, "01m00s"),
(60*60, "01h00s"),
(60*60+60, "01h01m00s"),
(60*60*25, "25h00s"),
])
@pytest.mark.parametrize(
"seconds,want_string",
[
(0, "00s"),
(0.1, "0.1s"),
(5, "05s"),
(50, "50s"),
(60, "01m00s"),
(60 * 60, "01h00s"),
(60 * 60 + 60, "01h01m00s"),
(60 * 60 * 25, "25h00s"),
],
)
def test_duration_seconds(seconds, want_string):
assert want_string == duration_seconds(seconds)

0 comments on commit 772bfae

Please sign in to comment.