stdlib,tests,configs: Replace Resource override download

The override parameter in the constructor has been renamed to to
'download_md5_mismatch'. This makes the purpose of this parameter
clearer.

The default value has been changed from False to True. We found in most
cases we want to re-download files if the md5 values have changes. Not
wanting to do so is the corner case. This allows us to remove a lot of
parameters from test and example scripts, included in this patch.

Change-Id: I99fc7743f5adf78bf6f4f8efc6222e6df83ac6da
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52086
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2021-10-26 15:39:29 -07:00
parent bde1c46d2d
commit b504398df8
18 changed files with 24 additions and 94 deletions

View File

@@ -198,7 +198,7 @@ def get_resource(
resource_name: str,
to_path: str,
unzip: bool = True,
override: bool = False,
download_md5_mismatch: bool = True,
) -> None:
"""
Obtains a gem5 resource and stored it to a specified location. If the
@@ -212,10 +212,10 @@ def get_resource(
:param unzip: If true, gzipped resources will be unzipped prior to saving
to `to_path`. True by default.
:param override: If a resource is present with an incorrect hash (e.g.,
an outdated version of the resource is present), `get_resource` will delete
this local resource and re-download it if this parameter is True. False by
default.
:param download_md5_mismatch: If a resource is present with an incorrect
hash (e.g., an outdated version of the resource is present), `get_resource`
will delete this local resource and re-download it if this parameter is
True. True by default.
:raises Exception: An exception is thrown if a file is already present at
`to_path` but it does not have the correct md5 sum. An exception will also
@@ -242,7 +242,7 @@ def get_resource(
# In this case, the file has already been download, no need to
# do so again.
return
elif override:
elif download_md5_mismatch:
os.remove(to_path)
else:
raise Exception(

View File

@@ -95,7 +95,7 @@ class Resource(AbstractResource):
self,
resource_name: str,
resource_directory: Optional[str] = None,
override: bool = False,
download_md5_mismatch: bool = True,
):
"""
:param resource_name: The name of the gem5 resource.
@@ -103,10 +103,10 @@ class Resource(AbstractResource):
resource is to be stored. If this parameter is not set, it will set to
the environment variable `GEM5_RESOURCE_DIR`. If the environment is not
set it will default to `~/.cache/gem5` if available, otherwise the CWD.
:param override: If the resource is present, but does not have the
correct md5 value, the resoruce will be deleted and re-downloaded if
this value is True. Otherwise an exception will be thrown. False by
default.
:param download_md5_mismatch: If the resource is present, but does not
have the correct md5 value, the resoruce will be deleted and
re-downloaded if this value is True. Otherwise an exception will be
thrown. True by default.
"""
if resource_directory == None:
@@ -131,7 +131,9 @@ class Resource(AbstractResource):
local_path=to_path,
metadata=get_resources_json_obj(resource_name))
get_resource(
resource_name=resource_name, to_path=to_path, override=override
resource_name=resource_name,
to_path=to_path,
download_md5_mismatch=download_md5_mismatch
)