{"id":13935169,"url":"https://github.com/kuk/log-progress","last_synced_at":"2025-07-19T20:31:07.231Z","repository":{"id":56759877,"uuid":"51253495","full_name":"kuk/log-progress","owner":"kuk","description":"https://habr.com/ru/post/276725/","archived":true,"fork":false,"pushed_at":"2020-06-14T13:53:02.000Z","size":9,"stargazers_count":564,"open_issues_count":11,"forks_count":60,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-08-07T23:15:12.698Z","etag":null,"topics":["jupyter","logging","widget"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-07T15:56:41.000Z","updated_at":"2024-02-09T21:07:07.000Z","dependencies_parsed_at":"2022-08-16T02:00:31.370Z","dependency_job_id":null,"html_url":"https://github.com/kuk/log-progress","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuk%2Flog-progress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuk%2Flog-progress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuk%2Flog-progress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuk%2Flog-progress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuk","download_url":"https://codeload.github.com/kuk/log-progress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226666541,"owners_count":17665043,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jupyter","logging","widget"],"created_at":"2024-08-07T23:01:26.330Z","updated_at":"2025-07-19T20:31:07.223Z","avatar_url":"https://github.com/kuk.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"\u003e # `log-progress` functionality was integrated into \u003ca href=\"https://github.com/tqdm/tqdm\"\u003e`tqdm`\u003c/a\u003e. Please, use `from tqdm.notebook import tqdm as log_progress`.\n\n## Widget based progress bar for Jupyter (IPython Notebook)\n\n### Code\nJust copy and paste it into your project:\n```python\ndef log_progress(sequence, every=None, size=None, name='Items'):\n    from ipywidgets import IntProgress, HTML, VBox\n    from IPython.display import display\n\n    is_iterator = False\n    if size is None:\n        try:\n            size = len(sequence)\n        except TypeError:\n            is_iterator = True\n    if size is not None:\n        if every is None:\n            if size \u003c= 200:\n                every = 1\n            else:\n                every = int(size / 200)     # every 0.5%\n    else:\n        assert every is not None, 'sequence is iterator, set every'\n\n    if is_iterator:\n        progress = IntProgress(min=0, max=1, value=1)\n        progress.bar_style = 'info'\n    else:\n        progress = IntProgress(min=0, max=size, value=0)\n    label = HTML()\n    box = VBox(children=[label, progress])\n    display(box)\n\n    index = 0\n    try:\n        for index, record in enumerate(sequence, 1):\n            if index == 1 or index % every == 0:\n                if is_iterator:\n                    label.value = '{name}: {index} / ?'.format(\n                        name=name,\n                        index=index\n                    )\n                else:\n                    progress.value = index\n                    label.value = u'{name}: {index} / {size}'.format(\n                        name=name,\n                        index=index,\n                        size=size\n                    )\n            yield record\n    except:\n        progress.bar_style = 'danger'\n        raise\n    else:\n        progress.bar_style = 'success'\n        progress.value = index\n        label.value = \"{name}: {index}\".format(\n            name=name,\n            index=str(index or '?')\n        )\n```\n\n### Examples\nProgress bar changes its color based on outcome:\n\n![](https://habrastorage.org/files/d7a/1f5/9f6/d7a1f59f61634d63a42b274ba186d1ba.gif)\n\n![](https://habrastorage.org/files/1bc/544/e8a/1bc544e8a50b419382d0fc090e087cce.gif)\n\nIterators are supported:\n\n![](https://habrastorage.org/files/712/255/d77/712255d77fd5473b8113e7bfc1bd852f.gif)\n\nMore then one progress bar can be in a sigle cell:\n\n![](https://habrastorage.org/files/1b4/48f/9a5/1b448f9a5b74456091eb5b16799c7c3e.gif)\n\n![](https://habrastorage.org/files/95d/c00/1df/95dc001dffb24852999a73ae8129a209.gif)\n\nThey can even be from different threads:\n\n![](https://habrastorage.org/files/e64/69a/fe5/e6469afe59ed485c84565a672d24cd50.gif)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuk%2Flog-progress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuk%2Flog-progress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuk%2Flog-progress/lists"}