diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98c8e569..71b9ba03 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: # Make docstrings PEP 257 compliant - repo: https://github.com/PyCQA/docformatter - rev: v1.6.0.rc1 + rev: v1.5.1 hooks: - id: docformatter args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"] @@ -67,7 +67,7 @@ repos: # Do YAML formatting (before the linter checks it for misses) - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.6.0 + rev: v2.7.0 hooks: - id: pretty-format-yaml args: [--autofix, --indent, "2", --preserve-quotes] diff --git a/envs/environment.yaml b/envs/environment.yaml index 9325ac09..5ffe0d71 100644 --- a/envs/environment.yaml +++ b/envs/environment.yaml @@ -33,7 +33,6 @@ dependencies: - networkx - scipy - shapely>=2.0 -- progressbar2 - pyomo - matplotlib<3.6 - proj diff --git a/scripts/_helpers.py b/scripts/_helpers.py index 5032cdf9..c32baf11 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -3,9 +3,11 @@ # # SPDX-License-Identifier: MIT +import urllib from pathlib import Path import pandas as pd +from tqdm import tqdm REGION_COLS = ["geometry", "name", "x", "y", "country"] @@ -251,16 +253,14 @@ def aggregate_costs(n, flatten=False, opts=None, existing_only=False): def progress_retrieve(url, file): - import urllib + with tqdm(unit="B", unit_scale=True, unit_divisor=1024, miniters=1) as t: - from progressbar import ProgressBar + def update_to(b=1, bsize=1, tsize=None): + if tsize is not None: + t.total = tsize + t.update(b * bsize - t.n) - pbar = ProgressBar(0, 100) - - def dlProgress(count, blockSize, totalSize): - pbar.update(int(count * blockSize * 100 / totalSize)) - - urllib.request.urlretrieve(url, file, reporthook=dlProgress) + urllib.request.urlretrieve(url, file, reporthook=update_to) def get_aggregation_strategies(aggregation_strategies): diff --git a/scripts/build_renewable_profiles.py b/scripts/build_renewable_profiles.py index c8a0fc42..a132115b 100644 --- a/scripts/build_renewable_profiles.py +++ b/scripts/build_renewable_profiles.py @@ -187,7 +187,6 @@ import time import atlite import geopandas as gpd import numpy as np -import progressbar as pgb import xarray as xr from _helpers import configure_logging from dask.distributed import Client, LocalCluster @@ -203,7 +202,6 @@ if __name__ == "__main__": snakemake = mock_snakemake("build_renewable_profiles", technology="solar") configure_logging(snakemake) - pgb.streams.wrap_stderr() nprocesses = int(snakemake.threads) noprogress = not snakemake.config["atlite"].get("show_progress", False)