in src/prepare_dlc_dev_environment.py [0:0]
def create_new_file_with_updated_version(currency_path, updated_content, previous_version_path):
"""
Create a new buildspec file with the updated content and update the pointer file.
"""
new_file_path = os.path.join(get_cloned_folder_path(), currency_path)
if os.path.exists(new_file_path):
LOGGER.error(f"ERROR: File {new_file_path} already exists, please enter a new file")
exit(1)
os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
with open(new_file_path, "w") as new_file:
new_file.writelines(updated_content)
LOGGER.info(f"Created {new_file_path} using {previous_version_path}")
# Update the graviton pointer file
graviton_pointer_file_path = os.path.join(
os.path.dirname(os.path.dirname(new_file_path)), "inference", "buildspec-graviton.yml"
)
# Update the arm64 pointer file
arm64_pointer_file_path = os.path.join(
os.path.dirname(os.path.dirname(new_file_path)), "inference", "buildspec-arm64.yml"
)
if "graviton" in new_file_path and os.path.exists(graviton_pointer_file_path):
update_pointer_file(graviton_pointer_file_path, currency_path)
elif "graviton" in new_file_path:
LOGGER.warning(f"Graviton pointer file not found at {graviton_pointer_file_path}")
elif "arm64" in new_file_path and os.path.exists(arm64_pointer_file_path):
update_pointer_file(arm64_pointer_file_path, currency_path)
elif "arm64" in new_file_path:
LOGGER.warning(f"ARM64 pointer file not found at {arm64_pointer_file_path}")
else:
pointer_file_path = os.path.join(os.path.dirname(new_file_path), "buildspec.yml")
if os.path.exists(pointer_file_path):
update_pointer_file(pointer_file_path, currency_path)
else:
LOGGER.warning(f"Pointer file not found at {pointer_file_path}")