question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to report progress while building context

See original GitHub issue

When building an exceptionally large context, there is no way to report progress. I’d opt to add an option to the util’s make context method of progress=False, so that people can manually call the function and set progress=True if they desire it.

To see the problem in action, use this repo (note the docker branch) and run toolset/run-tests.py --install server --docker --test '' (you will need python 2.7 and the requirements listed here. Building teh context can sometimes take up to 15 minutes (note: this is on an NFS filesystem which is notoriously slow when tarring a lot of small files) and normally takes about 5 minutes (on my local SSD)

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:15
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
speedplanecommented, Feb 9, 2016

I monkey patched docker/api/build.py and progress info via the class below. This class wraps a file object and will report how much of has been read. Once this class is defined, you can see progress by adding context = StreamPrinter(context) before we make the _post call.

class StreamPrinter(object):
    '''
    Wrap a file object and print out read progress. Used in conjunction with
    the 
    '''
    def __init__(self, file):
        self.read_so_far = 0
        self.starttime = datetime.datetime.utcnow()
        self.file = file

    def __iter__(self, *args, **kwargs):
        self.starttime = datetime.datetime.utcnow()
        return self

    def chk_print(self, fn):
        old_megs = self.read_so_far / 1024 / 1024
        out = fn()
        self.read_so_far += len(out)
        new_megs = self.read_so_far / 1024 / 1024
        if old_megs != new_megs:
            log.debug('Sent %s megabytes. Time elapsed: %s'%(new_megs,
                datetime.datetime.utcnow() - self.starttime))
        return out

    def next(self):
        return self.chk_print(fn = lambda: next(self.file))

    def read(self, *args, **kwargs):
        return self.chk_print(fn = lambda: self.file.read(*args, **kwargs))

This is still a bit messy and I’m not sure that this is the best approach, which is why I didn’t make a pull request. But thought others may find it useful.

0reactions
gabrieldemarmiessecommented, Nov 8, 2020

https://gabrieldemarmiesse.github.io/python-on-whales/ The only downside is that it’ll be open source next year.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a progress report and how can you effectively manage ...
A progress report allows you to get important information on project completion. ScrumGenius is a simple, yet powerful, tool that can improve your...
Read more >
8 steps to write an effective project status report - Asana
Effective project status reports are the best way to keep your stakeholders aligned and in the loop during your project progress.
Read more >
Enhancement: builder: support progress report when no TTY ...
Currently, Docker build suppresses progress output when running in a script, ... I get a progress report for the "Sending build context.
Read more >
Show progress only if a background operation is long
Here's what I'd do: 1) Use a BackgroundWorker. 2) In before you call the method RunWorkerAsync, store the current time in a variable....
Read more >
Building Progress Bars for the Web with Django and Celery
When preparing a file for download; When the user is in a queue waiting for their request to get processed. The Components of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found