tfds.download.Resource

Class Resource

Defined in core/download/resource.py.

Represents a resource to download, extract, or both.

__init__

__init__(
    url=None,
    extract_method=None,
    path=None
)

Resource constructor.

Args:

  • url: str, the URL at which to download the resource.
  • extract_method: ExtractMethod to be used to extract resource. If not set, will be guessed from downloaded file name original_fname.
  • path: str, path of resource on local disk. Can be None if resource has not be downloaded yet. In such case, url must be set.

Properties

extract_fname

Name of extracted archive (file or directory).

extract_method

Returns ExtractMethod to use on resource. Cannot be None.

extract_method_name

Returns the name (str) of the extraction method.

fname

Name of downloaded file (not as downloaded, but as stored).

info_path

Returns path (str) of INFO file associated with resource.

sha256

Methods

exists_locally

exists_locally()

Returns whether the resource exists locally, at resource.path.

write_info_file

write_info_file(
    *args,
    **kwargs
)

Write the INFO file next to local file.

Although the method is synchronized, there is still a risk two processes running at the same time overlap here. Risk accepted, since potentially lost data (dataset_name) is only for human consumption.

Args:

  • dataset_name: data used to dl the file.
  • original_fname: name of file as downloaded.