in src/braket_container.py [0:0]
def unpack_code_and_add_to_path(local_s3_file : str, compression_type : str):
"""
Unpack the customer code, if necessary. Add the customer code to the system path.
Args:
local_s3_file (str): the file representing the customer code.
compression_type (str): if the customer code is stored in an archive, this value will
represent the compression type of the archive.
"""
if compression_type and compression_type.strip().lower() in ["gzip", "zip"]:
try:
shutil.unpack_archive(local_s3_file, EXTRACTED_CUSTOMER_CODE_PATH)
except Exception as e:
log_failure_and_exit(
f"Got an exception while trying to unpack archive: {local_s3_file} of type: "
f"{compression_type}.\nException: {e}"
)
else:
shutil.move(local_s3_file, EXTRACTED_CUSTOMER_CODE_PATH)
sys.path.append(EXTRACTED_CUSTOMER_CODE_PATH)