Merge pull request #478 from PyPSA/tqdm-display

replace progressbar by tqdm
This commit is contained in:
Fabian Neumann 2023-02-22 15:25:48 +01:00 committed by GitHub
commit e28e106c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View File

@ -33,7 +33,6 @@ dependencies:
- networkx
- scipy
- shapely>=2.0
- progressbar2
- pyomo
- matplotlib<3.6
- proj

View File

@ -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):

View File

@ -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)