read cdn yaml config from api

automate tensorrt model conversion in case of no existing one for user's gpu
This commit is contained in:
Alex Bezdieniezhnykh
2025-04-23 23:20:08 +03:00
parent c68c293448
commit e798af470b
23 changed files with 265 additions and 93 deletions
+19 -3
View File
@@ -36,8 +36,24 @@ class CDNManager:
def download(self, bucket: str, filename: str):
try:
self.download_client.download_file(bucket, filename, filename)
print(f'downloaded {filename} from the {bucket} to current folder')
if filename is not None:
self.download_client.download_file(bucket, filename, os.path.join(bucket, filename))
print(f'downloaded {filename} from the {bucket} to current folder')
else:
response = self.download_client.list_objects_v2(Bucket=bucket)
if 'Contents' in response:
for obj in response['Contents']:
object_key = obj['Key']
local_filepath = os.path.join(bucket, object_key)
local_dir = os.path.dirname(local_filepath)
if local_dir:
os.makedirs(local_dir, exist_ok=True)
if not object_key.endswith('/'):
try:
self.download_client.download_file(bucket, object_key, local_filepath)
except Exception as e_file:
all_successful = False # Mark as failed if any file fails
return True
except Exception as e:
print(e)
@@ -58,7 +74,7 @@ cdn_manager = CDNManager(CDNCredentials(
input_action = sys.argv[1]
input_bucket = sys.argv[2]
input_filename = sys.argv[3]
input_filename = sys.argv[3] if len(sys.argv) > 3 else None
if len(sys.argv) > 4: # 0 is this script's path, hence 5 args is max
input_path = sys.argv[4]