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

replace progressbar by tqdm #478

Merged
merged 7 commits into from
Feb 22, 2023
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
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