From 6a2ac465896ce6f980f0f3d374d6d401b8acb900 Mon Sep 17 00:00:00 2001 From: Kshitij Sisodia Date: Tue, 1 Mar 2022 17:36:06 +0000 Subject: MLECO-2881: Using MD5 sum for downloaded resources check. Removing git as a requirement for the checks performed for downloaded resources. Another minor change is renaming of RTE_components.h to RTE_Components.h as per the convention. Change-Id: If93f80f2f5dfa6a3f143259904c33b3b6d3a6e7c Signed-off-by: Kshitij Sisodia --- set_up_default_resources.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'set_up_default_resources.py') diff --git a/set_up_default_resources.py b/set_up_default_resources.py index 48e6a67..899fbe6 100755 --- a/set_up_default_resources.py +++ b/set_up_default_resources.py @@ -27,6 +27,7 @@ from argparse import ArgumentParser from argparse import ArgumentTypeError from collections import namedtuple from urllib.error import URLError +from scripts.py.check_update_resources_downloaded import get_md5sum_for_file json_uc_res = [ @@ -356,6 +357,8 @@ def set_up_resources( greater than 0 is provided, this will be taken as the cache size. If 0, the default values, as per the NPU config requirements, are used. + check_clean_folder (bool): Indicates whether the resources folder needs to + be checked for updates and cleaned. """ # Paths current_file_dir = os.path.dirname(os.path.abspath(__file__)) @@ -369,14 +372,8 @@ def set_up_resources( metadata_dict = dict() vela_version = "3.2.0" - # Check if the current directory is a git repository - is_git_repo = os.path.exists(os.path.join(current_file_dir, ".git")) - git_commit_hash = "" - setup_script_hash_changed = False - if is_git_repo: - # If the current directory is a git script then extract the set_up_default_resorces.py hash - command = f"git log -1 --pretty=tformat:%H {os.path.abspath(__file__)}" - git_commit_hash = call_command(command, False) + setup_script_hash_verified = False + setup_script_hash = get_md5sum_for_file(os.path.abspath(__file__)) try: # 1.1 Does the download dir exist? @@ -398,11 +395,9 @@ def set_up_resources( remove_tree_dir(download_dir) metadata_dict = dict() else: - # Check if the set_up_default_resorces.py has changed from last setup, only if this is a git repo - if is_git_repo: - setup_script_hash_changed = not ( - metadata_dict["set_up_script_hash"] == git_commit_hash - ) + # Check if the set_up_default_resorces.py has changed from last setup + setup_script_hash_verified = ( + metadata_dict.get('set_up_script_md5sum') == setup_script_hash) else: raise @@ -444,7 +439,7 @@ def set_up_resources( except OSError as e: if e.errno == errno.EEXIST: # The usecase_name download dir exist - if setup_script_hash_changed: + if check_clean_folder and not setup_script_hash_verified: for idx, metadata_uc_url_prefix in enumerate( [ f @@ -588,7 +583,7 @@ def set_up_resources( # 4. Collect and write metadata logging.info("Collecting and write metadata.") metadata_dict["ethosu_vela_version"] = vela_version - metadata_dict["set_up_script_hash"] = git_commit_hash.strip("\n") + metadata_dict["set_up_script_md5sum"] = setup_script_hash.strip("\n") metadata_dict["resources_info"] = json_uc_res with open(metadata_file_path, "w") as metadata_file: -- cgit v1.2.1