Skip to content

Commit addf493

Browse files
authored
Call echo_logs only when in DEBUG mode (#167)
The echo_logs function prints out the logs from the container (i.e. the output of aiidalab-launch logs) while the user waits for the container to start. However, logs are printed with logging.DEBUG so there's no point in calling this function unless this level of logging is enabled (via the -vvv cmdline parameter).
1 parent e86a331 commit addf493

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
5656
- name: Run tests
5757
run: |
58-
pytest -v --slow --default-image=${{ matrix.default-image }}
58+
pytest -sv --slow --default-image=${{ matrix.default-image }}
5959
coverage xml
6060
6161
- name: Upload coverage to Codecov

aiidalab_launch/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,11 @@ async def _async_start(
416416
raise click.ClickException(f"Unknown error occurred: {error}")
417417
else:
418418
if wait:
419+
logging_level = logging.getLogger().getEffectiveLevel()
419420
try:
420421
with spinner("Waiting for AiiDAlab instance to get ready..."):
421-
echo_logs = asyncio.create_task(instance.echo_logs())
422+
if logging_level == logging.DEBUG:
423+
echo_logs = asyncio.create_task(instance.echo_logs())
422424
await asyncio.wait_for(instance.wait_for_services(), timeout=wait)
423425
except asyncio.TimeoutError:
424426
raise click.ClickException(
@@ -435,7 +437,8 @@ async def _async_start(
435437
else:
436438
LOGGER.debug("AiiDAlab instance ready.")
437439
finally:
438-
echo_logs.cancel()
440+
if logging_level == logging.DEBUG:
441+
echo_logs.cancel()
439442

440443
LOGGER.debug("Preparing startup message.")
441444
msg_startup = (

0 commit comments

Comments
 (0)