Skip to content

Commit

Permalink
Merge pull request #478 from PyPSA/tqdm-display
Browse files Browse the repository at this point in the history
replace progressbar by tqdm
  • Loading branch information
fneum authored Feb 22, 2023
2 parents ec4191f + 3642d5c commit e28e106
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion envs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies:
- networkx
- scipy
- shapely>=2.0
- progressbar2
- pyomo
- matplotlib<3.6
- proj
Expand Down
16 changes: 8 additions & 8 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions scripts/build_renewable_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
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
Expand All @@ -203,7 +202,6 @@

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)
Expand Down

0 comments on commit e28e106

Please sign in to comment.