Skip to content

Python: Improve progress status in console #4186

Closed as not planned
Closed as not planned

Description

@helderco

Overview

As a follow-up to #3806, I’d like to show some progress on the screen while waiting for the engine to provision and also while running the pipeline.

Demo

Watch the November 17th community call (0:40:45) where I show some of this.

Related

Multiple people will be working around improving logging. For the SDK, we’re particularly interested in improvements from the engine side. More specifically, if we have structured logging, we’ll be able to present more granular progress with each “pipeline step”.

There may be more consensus and design decisions coming from the other SDKs as well. Remember to track them here.

Considerations

  • In order to default to a rich based logger, implemented as a logger handler, it must but opt-in (e.g., dagger.setup() before doing anything else)
  • See how Sentry and Django setup logging

Activity

  1. robertu94 commented on Jan 4, 2023

    @robertu94

    Not sure where to best report this, but I have this issue too. I ported a portion of our CI/CD code to use Dagger's Python SDK, and it so far it works great, but before I throw the switch I want to make sure that the quality of our logs from CI do not degrade. For context, we have a C++ code with a number of dependencies. One aspect that we want to ensure is that each release builds on one of a number of common Linux distributions using system provided (and when supported MacOS) we can reasonably expect our users will have on their laptops using system provided dependencies.

    However, in the process of debugging things using Dagger, it was really hard to determine which of a series of image layers led to a failure. This is because the outputs are not identifiable (i.e. is #18 relating to the series of tasks based on the almalinux:8 or almalinux:9 image). Improving the logs to make these distinguishable would be great.

    (I intentionally inserted a typo in cmake in the centos_base function to illustrate my point)

    Here is the error message that I get now:

    > dnf install -y cmak gcc gcc-c++ ninja-build boost-devel ccache git pkg-config:
    #18 0.782 Last metadata expiration check: 0:31:29 ago on Wed Jan  4 22:08:40 2023.
    #18 1.149 No match for argument: cmak
    #18 1.182 Error: Unable to find a match: cmak
    ------
    Traceback (most recent call last):
      File "/home/runderwood/git/libpressio/./ci/test.py", line 200, in <module>
        anyio.run(test, args)
      File "/home/runderwood/.local/lib/python3.11/site-packages/anyio/_core/_eventloop.py", line 70, in run
        return asynclib.run(func, *args, **backend_options)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runderwood/.local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 292, in run
        return native_run(wrapper(), debug=debug)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/asyncio/runners.py", line 190, in run
        return runner.run(main)
               ^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/asyncio/runners.py", line 118, in run
        return self._loop.run_until_complete(task)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/asyncio/base_events.py", line 653, in run_until_complete
        return future.result()
               ^^^^^^^^^^^^^^^
      File "/home/runderwood/.local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
        return await func(*args)
               ^^^^^^^^^^^^^^^^^
      File "/home/runderwood/git/libpressio/./ci/test.py", line 187, in test
        async with anyio.create_task_group() as tg:
      File "/home/runderwood/.local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 662, in __aexit__
        raise exceptions[0]
      File "/home/runderwood/git/libpressio/./ci/test.py", line 185, in test_centos
        return await common_steps(centos_base(client, version)).exit_code()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runderwood/.local/lib/python3.11/site-packages/dagger/api/gen.py", line 172, in exit_code
        return await _ctx.execute(int | None)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runderwood/.local/lib/python3.11/site-packages/dagger/api/base.py", line 90, in execute
        result = await self.session.execute(query, get_execution_result=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runderwood/.local/lib/python3.11/site-packages/gql/client.py", line 1231, in execute
        raise TransportQueryError(
    gql.transport.exceptions.TransportQueryError: {'message': 'process "dnf install -y cmak gcc gcc-c++ ninja-build boost-devel ccache git pkg-config" did not complete successfully: exit code: 1', 'locations': [{'line': 43, 'column': 49}], 'path': ['container', 'from', 'withMountedCache', 'withMountedCache', 'withEnvVariable', 'withExec', 'withExec', 'withExec', 'withExec', 'withDirectory', 'withWorkdir', 'withExec', 'withExec', 'withExec', 'withExec', 'withDirectory', 'withWorkdir', 'withExec', 'withExec', 'withExec', 'withWorkdir', 'withExec', 'withExec', 'exitCode']}

    Additionally, It would be great to get a more useful "backtrace" here. Something like

    When building the following:
    from("almalinux:8")
    with_mounted_cache("/var/cache/dnf")
    with_mounted_cache("/var/ccache/ccache")
    with_exec("dnf install -y dnf-plugins-core")
    with_exec("dnf install -y  epel-release")
    with_exec("dnf config-manager --set-enabled powertools")
    with_exec("dnf install -y cmak gcc gcc-c++ ninja-build boost-devel ccache git pkg-config")
    
    The build steps were: #1-5,18
    
    The following error occurred:
    #18 0.782 Last metadata expiration check: 0:31:29 ago on Wed Jan  4 22:08:40 2023.
    #18 1.149 No match for argument: cmak
    #18 1.182 Error: Unable to find a match: cmak

    I've attached the (fixed) version of the pipeline for reference:
    test.zip

  2. helderco commented on Jan 4, 2023

    @helderco
    ContributorAuthor

    This issue doesn't include the logs from the engine as it works now, only when structured logging is available:

    You might be interested in this though:

    Watch this Community Call Demo - Upcoming Logging Improvements!

  3. robertu94 commented on Jan 5, 2023

    @robertu94

    @helderco thanks for the link to the demo. It looks awesome 🚀 and I think it would address my use cases.

  4. self-assigned this
    on Jan 5, 2023
  5. removed their assignment
    on Feb 9, 2023
  6. helderco commented on Apr 17, 2023

    @helderco
    ContributorAuthor

    There's an experimental TUI with dagger run for better interactive progress during pipeline execution.

    Instructions here:

  7. helderco commented on Jul 18, 2023

    @helderco
    ContributorAuthor

    Closing in favor of:

    1. Engine logs: the TUI gives a much better and centralized way to see progress from the engine.
    2. Auto provisioning1: Every SDK needs this, included in When using Dagger interactively, feedback about what is happening could reduce confusion. #4820.

    Footnotes

    1. SDK checks and downloads CLI and starts session. ↩

  8. gerhard commented on Aug 1, 2023

    @gerhard
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions