sc2_datasets.utils.download_utils

Functions

download_replaypack(→ pathlib.Path | None)

Exposes logic for downloading a single StarCraft II replaypack from an url.

Module Contents

download_replaypack(destination_dir: pathlib.Path, replaypack_name: str, replaypack_url: str) pathlib.Path | None

Exposes logic for downloading a single StarCraft II replaypack from an url.

Parameters:
  • destination_dir (Path) – Specifies the destination directory where the replaypack will be saved.

  • replaypack_name (str) – Specifies the name of a replaypack that will be used for the downloaded .zip archive.

  • replaypack_url (str) – Specifies the url that is a direct link to the .zip which will be downloaded.

Returns:

Returns the filepath to the downloaded .zip archive. If the download failed, None is returned.

Return type:

Path | None

Examples

The use of this method is intended to download a .zip replaypack containing StarCraft II games.

Replaypack download directory should be empty before running this function.

Replaypack name will be used as the name for the downloaded .zip archive.

Replaypack url should be valid and poiting directly to a .zip archive hosted on some server.

The parameters should be set as in the example below.

>>> from pathlib import Path
>>> replaypack_download_dir = Path("datasets/download_directory").resolve()
>>> replaypack_name = "TournamentName"
>>> replaypack_url = "some_url"
>>> download_replaypack_object = download_replaypack(
...    destination_dir=replaypack_download_dir,
...    replaypack_name=replaypack_name,
...    replaypack_url=replaypack_url)
>>> assert isinstance(replaypack_download_dir, Path)
>>> assert isinstance(replaypack_name, str)
>>> assert isinstance(replaypack_url, str)
>>> assert len(os.listdir(replaypack_download_dir)) == 0
>>> assert existing_files[0].endswith(".zip")