def download_model()

in decisionai_plugin/common/util/model.py [0:0]


def download_model(config, subscription, model_id, model_dir): 
    try:
        zip_dir = os.path.join(config.model_temp_dir, subscription + '_' + model_id + '_' + str(time.time()))
        os.makedirs(zip_dir, exist_ok=True)

        # download from blob
        container_name = config.tsana_app_name
        azure_blob = AzureBlob(AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_ACCOUNT_KEY, AZURE_STORAGE_ACCOUNT_DOMAIN)
        azure_blob.create_container(container_name)
        model_name = subscription + '_' + model_id
        
        zip_file = os.path.join(zip_dir, "model.zip")
        azure_blob.download_blob(container_name, model_name, zip_file)
        with zipfile.ZipFile(zip_file) as zf:
            shutil.rmtree(model_dir, ignore_errors=True)
            os.makedirs(model_dir, exist_ok=True)
            zf.extractall(path=model_dir)
        return STATUS_SUCCESS, ''
    except Exception as e:
        return STATUS_FAIL, str(e)
    finally:
        shutil.rmtree(zip_dir, ignore_errors=True)