From 34149fe933d1ba15f9804a6c509153ea97dff203 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 12 Mar 2025 23:11:42 -0400 Subject: [PATCH] Move multipart.encoder import to runtime Another library with a ridiculously long load time. --- client-cli/pvc/lib/provisioner.py | 11 ++++++----- client-cli/pvc/lib/storage.py | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/client-cli/pvc/lib/provisioner.py b/client-cli/pvc/lib/provisioner.py index 41dbb2e9..1f6c537e 100644 --- a/client-cli/pvc/lib/provisioner.py +++ b/client-cli/pvc/lib/provisioner.py @@ -19,11 +19,6 @@ # ############################################################################### -from requests_toolbelt.multipart.encoder import ( - MultipartEncoder, - MultipartEncoderMonitor, -) - import pvc.lib.ansiprint as ansiprint from pvc.lib.common import UploadProgressBar, call_api, get_wait_retdata @@ -549,6 +544,12 @@ def ova_upload(config, name, ova_file, params): bar = UploadProgressBar( ova_file, end_message="Parsing file on remote side...", end_nl=False ) + + from requests_toolbelt.multipart.encoder import ( + MultipartEncoder, + MultipartEncoderMonitor, + ) + upload_data = MultipartEncoder( fields={"file": ("filename", open(ova_file, "rb"), "application/octet-stream")} ) diff --git a/client-cli/pvc/lib/storage.py b/client-cli/pvc/lib/storage.py index 2d3b0be4..42680c7f 100644 --- a/client-cli/pvc/lib/storage.py +++ b/client-cli/pvc/lib/storage.py @@ -23,10 +23,6 @@ import math from os import path from json import loads -from requests_toolbelt.multipart.encoder import ( - MultipartEncoder, - MultipartEncoderMonitor, -) import pvc.lib.ansiprint as ansiprint from pvc.lib.common import UploadProgressBar, call_api, get_wait_retdata @@ -1212,6 +1208,12 @@ def ceph_volume_upload(config, pool, volume, image_format, image_file): bar = UploadProgressBar( image_file, end_message="Parsing file on remote side...", end_nl=False ) + + from requests_toolbelt.multipart.encoder import ( + MultipartEncoder, + MultipartEncoderMonitor, + ) + upload_data = MultipartEncoder( fields={ "file": ("filename", open(image_file, "rb"), "application/octet-stream")