Skip to content

Commit

Permalink
Call echo_logs only when in DEBUG mode (#167)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
danielhollas authored Feb 23, 2023
1 parent e86a331 commit addf493
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Run tests
run: |
pytest -v --slow --default-image=${{ matrix.default-image }}
pytest -sv --slow --default-image=${{ matrix.default-image }}
coverage xml
- name: Upload coverage to Codecov
Expand Down
7 changes: 5 additions & 2 deletions aiidalab_launch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ async def _async_start(
raise click.ClickException(f"Unknown error occurred: {error}")
else:
if wait:
logging_level = logging.getLogger().getEffectiveLevel()
try:
with spinner("Waiting for AiiDAlab instance to get ready..."):
echo_logs = asyncio.create_task(instance.echo_logs())
if logging_level == logging.DEBUG:
echo_logs = asyncio.create_task(instance.echo_logs())
await asyncio.wait_for(instance.wait_for_services(), timeout=wait)
except asyncio.TimeoutError:
raise click.ClickException(
Expand All @@ -435,7 +437,8 @@ async def _async_start(
else:
LOGGER.debug("AiiDAlab instance ready.")
finally:
echo_logs.cancel()
if logging_level == logging.DEBUG:
echo_logs.cancel()

LOGGER.debug("Preparing startup message.")
msg_startup = (
Expand Down

0 comments on commit addf493

Please sign in to comment.