Skip to content

Commit

Permalink
Adding configs for retries, retrywait, timeout, and chunksize
Browse files Browse the repository at this point in the history
  • Loading branch information
mtauraso committed Aug 22, 2024
1 parent 161b806 commit b76b66c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/fibad/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ def run(config):
logger.info("Requesting cutouts")
# pass the rects to the cutout downloader
download_cutout_group(
rects=rects, cutout_dir=config.get("cutout_dir"), user=config["username"], password=config["password"]
rects=rects,
cutout_dir=config.get("cutout_dir"),
user=config["username"],
password=config["password"],
retrywait=config.get("retry_wait", 30),
retries=config.get("retries", 3),
timeout=config.get("timeout", 3600),
chunksize=config.get("chunk_size", 990),
)

logger.info("Done")
Expand Down Expand Up @@ -368,7 +375,7 @@ def save(self):
missed.write(self.filepath, overwrite=True, **self.format_kwargs)


def download_cutout_group(rects: list[dC.Rect], cutout_dir: Union[str, Path], user, password):
def download_cutout_group(rects: list[dC.Rect], cutout_dir: Union[str, Path], user, password, **kwargs):

Check warning on line 378 in src/fibad/download.py

View check run for this annotation

Codecov / codecov/patch

src/fibad/download.py#L378

Added line #L378 was not covered by tests
"""Download cutouts to the given directory
Calls downloadCutout.download, so supports long lists of rects beyond the limits of the HSC web API
Expand All @@ -383,6 +390,8 @@ def download_cutout_group(rects: list[dC.Rect], cutout_dir: Union[str, Path], us
Username for HSC's download service to use
password : string
Password for HSC's download service to use
**kwargs: dict
Additonal arguments for downloadCutout.download. See downloadCutout.download for details
"""

with working_directory(Path(cutout_dir)):
Expand All @@ -398,5 +407,5 @@ def download_cutout_group(rects: list[dC.Rect], cutout_dir: Union[str, Path], us
request_hook=stats_hook,
failed_chunk_hook=failed_chunk_hook,
resume=True,
chunksize=10,
**kwargs,
)
10 changes: 10 additions & 0 deletions src/fibad/fibad_default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ cutout_dir = "../hscplay/cutouts/"
offset = 0
num_sources = 10

# These control the downloader's HTTP requests and retries
# `retry_wait` How long to wait before retrying a failed HTTP request in seconds. Default 30s
retry_wait = 30
# `retries` How many times to retry a failed HTTP request before moving on to the next one. Default 3 times
retries = 3
# `timepout` How long should we wait to get a full HTTP response from the server. Default 3600s (1hr)
timeout = 3600
# `chunksize` How many sky location rectangles should we request in a single request. Default is 990
chunksize = 990

[model]
name = "ExampleCNN"

Expand Down

0 comments on commit b76b66c

Please sign in to comment.