Skip to content

Commit

Permalink
Cap max number of workers in weather-dl. (#170)
Browse files Browse the repository at this point in the history
* Capped max number of workers in weather-dl tool.

* Corrected doc string of class PipelineArgs weather-dl.

* updated weather-dl version to 0.1.10
  • Loading branch information
mahrsee1997 authored Jun 27, 2022
1 parent f860cbd commit a6a9c06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion weather_dl/download_pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from apache_beam.options.pipeline_options import (
PipelineOptions,
StandardOptions,
WorkerOptions,
)

from .clients import CLIENTS
Expand Down Expand Up @@ -69,7 +70,7 @@ class PipelineArgs:
client_name: The type of download client (e.g. Copernicus, Mars, or a fake).
store: A Store, which is responsible for where downloads end up.
manifest: A Manifest, which records download progress.
subsections: A
num_requesters_per_key: Number of requests per subsection (license).
"""
known_args: argparse.Namespace
pipeline_options: PipelineOptions
Expand All @@ -88,6 +89,11 @@ def pipeline(args: PipelineArgs) -> None:

subsections = get_subsections(args.config)

# capping the max number of workers to N i.e. possible simultaneous requests + fudge factor
max_num_workers = len(subsections) * args.num_requesters_per_key + 10
args.pipeline_options.view_as(WorkerOptions).max_num_workers = max_num_workers
logger.info(f"Capped the max number of workers to '{max_num_workers}'.")

request_idxs = {name: itertools.cycle(range(args.num_requesters_per_key)) for name, _ in subsections}

def subsection_and_request(it: Config) -> t.Tuple[str, int]:
Expand Down
2 changes: 1 addition & 1 deletion weather_dl/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
setup(
name='download_pipeline',
packages=find_packages(),
version='0.1.9',
version='0.1.10',
author='Anthromets',
author_email='anthromets-ecmwf@google.com',
url='https://weather-tools.readthedocs.io/en/latest/weather_dl/',
Expand Down

0 comments on commit a6a9c06

Please sign in to comment.