Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show progress bars #251

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ requests
resolvelib
stevedore
toml
virtualenv
tqdm
virtualenv

4 changes: 2 additions & 2 deletions src/fromager/commands/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import click
from packaging.requirements import Requirement

from .. import clickext, context, requirements_file, sdist, server
from .. import clickext, context, progress, requirements_file, sdist, server

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -59,7 +59,7 @@ def bootstrap(

server.start_wheel_server(wkctx)

for origin, toplevel in to_build:
for origin, toplevel in progress.progress(to_build):
sdist.handle_requirement(wkctx, Requirement(toplevel), req_type=origin)

# If we put pre-built wheels in the downloads directory, we should
Expand Down
11 changes: 6 additions & 5 deletions src/fromager/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from packaging.requirements import Requirement
from packaging.version import Version

from fromager import clickext, context, hooks, sdist, server, sources, wheels
from fromager import clickext, context, hooks, progress, sdist, server, sources, wheels

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -67,10 +67,11 @@ def build_sequence(

"""
with open(build_order_file, "r") as f:
for entry in json.load(f):
wheel_filename = _build(
wkctx, entry["dist"], Version(entry["version"]), sdist_server_url
)
for entry in progress.progress(json.load(f)):
dist_name = entry["dist"]
dist_version = Version(entry["version"])
logger.info("%s: Building %s==%s", dist_name, dist_name, dist_version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I've been trying to standardize log messages as all lower case

wheel_filename = _build(wkctx, dist_name, dist_version, sdist_server_url)
server.update_wheel_mirror(wkctx)
# After we update the wheel mirror, the built file has
# moved to a new directory.
Expand Down
4 changes: 2 additions & 2 deletions src/fromager/commands/download_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click
from packaging.requirements import Requirement

from .. import context, sdist, sources
from .. import context, progress, sdist, sources

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -41,7 +41,7 @@ def download_sequence(
wheel_servers = [sdist_server_url]

with open(build_order_file, "r") as f:
for entry in json.load(f):
for entry in progress.progress(json.load(f)):
if entry["prebuilt"]:
logger.info(f"{entry['dist']} uses a pre-built wheel, skipping")
continue
Expand Down
14 changes: 14 additions & 0 deletions src/fromager/progress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys
import typing

import tqdm as _tqdm

__all__ = ("progress",)


def progress(it: typing.Iterable, *, unit="pkg", **kwargs: typing.Any) -> typing.Any:
"""tqdm progress bar"""
if not sys.stdout.isatty():
# wider progress bar in CI
kwargs.setdefault("ncols", 78)
yield from _tqdm.tqdm(it, unit=unit, **kwargs)
Loading