VLC fix (#224)
* Enhance SetupController with improved logging and error handling during setup and file upload processes. Update instance type to t3.xlarge and AMI ID for AWS configuration. Add download progress logging and exception handling for better debugging. * Enhance VLC status evaluation by adding multiple paths for file and URL information extraction, improving robustness against varying VLC XML structures. Implement detailed logging for better debugging and error handling in case of mismatches or missing data. Update example JSON for VLC evaluation to use a valid HLS stream URL. * Improve audio comparison robustness in VLC evaluator by adding error handling for audio file loading and extraction. Implement detailed logging for empty or corrupt files, and normalize DTW distance calculation for more accurate similarity scoring. Remove deprecated audio fingerprint comparison function. --------- Co-authored-by: yuanmengqi <yuanmengqi@mail.ustc.edu.cn>
This commit is contained in:
@@ -79,7 +79,7 @@ class SetupController:
|
||||
return False
|
||||
|
||||
|
||||
for cfg in config:
|
||||
for i, cfg in enumerate(config):
|
||||
config_type: str = cfg["type"]
|
||||
parameters: Dict[str, Any] = cfg["parameters"]
|
||||
|
||||
@@ -87,10 +87,17 @@ class SetupController:
|
||||
# protocol
|
||||
setup_function: str = "_{:}_setup".format(config_type)
|
||||
assert hasattr(self, setup_function), f'Setup controller cannot find init function {setup_function}'
|
||||
logger.info(f"call function {setup_function}")
|
||||
getattr(self, setup_function)(**parameters)
|
||||
|
||||
logger.info("SETUP: %s(%s)", setup_function, str(parameters))
|
||||
|
||||
try:
|
||||
logger.info(f"Executing setup step {i+1}/{len(config)}: {setup_function}")
|
||||
logger.debug(f"Setup parameters: {parameters}")
|
||||
getattr(self, setup_function)(**parameters)
|
||||
logger.info(f"SETUP COMPLETED: {setup_function}({str(parameters)})")
|
||||
except Exception as e:
|
||||
logger.error(f"SETUP FAILED at step {i+1}/{len(config)}: {setup_function}({str(parameters)})")
|
||||
logger.error(f"Error details: {e}")
|
||||
logger.error(f"Traceback: {traceback.format_exc()}")
|
||||
raise Exception(f"Setup step {i+1} failed: {setup_function} - {e}") from e
|
||||
|
||||
return True
|
||||
|
||||
@@ -113,25 +120,41 @@ class SetupController:
|
||||
raise Exception(f"Setup Download - Invalid URL ({url}) or path ({path}).")
|
||||
|
||||
if not os.path.exists(cache_path):
|
||||
logger.info(f"Cache file not found, downloading from {url} to {cache_path}")
|
||||
max_retries = 3
|
||||
downloaded = False
|
||||
e = None
|
||||
for i in range(max_retries):
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
logger.info(f"Download attempt {i+1}/{max_retries} for {url}")
|
||||
response = requests.get(url, stream=True, timeout=300) # Add 5 minute timeout
|
||||
response.raise_for_status()
|
||||
|
||||
# Get file size if available
|
||||
total_size = int(response.headers.get('content-length', 0))
|
||||
if total_size > 0:
|
||||
logger.info(f"File size: {total_size / (1024*1024):.2f} MB")
|
||||
|
||||
downloaded_size = 0
|
||||
with open(cache_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if chunk:
|
||||
f.write(chunk)
|
||||
logger.info("File downloaded successfully")
|
||||
downloaded_size += len(chunk)
|
||||
if total_size > 0 and downloaded_size % (1024*1024) == 0: # Log every MB
|
||||
progress = (downloaded_size / total_size) * 100
|
||||
logger.info(f"Download progress: {progress:.1f}%")
|
||||
|
||||
logger.info(f"File downloaded successfully to {cache_path} ({downloaded_size / (1024*1024):.2f} MB)")
|
||||
downloaded = True
|
||||
break
|
||||
|
||||
except requests.RequestException as e:
|
||||
logger.error(
|
||||
f"Failed to download {url} caused by {e}. Retrying... ({max_retries - i - 1} attempts left)")
|
||||
# Clean up partial download
|
||||
if os.path.exists(cache_path):
|
||||
os.remove(cache_path)
|
||||
if not downloaded:
|
||||
raise requests.RequestException(f"Failed to download {url}. No retries left.")
|
||||
|
||||
@@ -144,14 +167,18 @@ class SetupController:
|
||||
|
||||
# send request to server to upload file
|
||||
try:
|
||||
logger.info(f"Uploading {os.path.basename(path)} to VM at {path}")
|
||||
logger.debug("REQUEST ADDRESS: %s", self.http_server + "/setup" + "/upload")
|
||||
response = requests.post(self.http_server + "/setup" + "/upload", headers=headers, data=form)
|
||||
response = requests.post(self.http_server + "/setup" + "/upload", headers=headers, data=form, timeout=600) # 10 minute timeout for upload
|
||||
if response.status_code == 200:
|
||||
logger.info("Command executed successfully: %s", response.text)
|
||||
logger.info(f"File uploaded successfully: {path}")
|
||||
logger.debug("Upload response: %s", response.text)
|
||||
else:
|
||||
logger.error("Failed to upload file. Status code: %s", response.text)
|
||||
logger.error(f"Failed to upload file {path}. Status code: {response.status_code}, Response: {response.text}")
|
||||
raise requests.RequestException(f"Upload failed with status {response.status_code}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error("An error occurred while trying to send the request: %s", e)
|
||||
logger.error(f"An error occurred while trying to upload {path}: {e}")
|
||||
raise
|
||||
|
||||
def _upload_file_setup(self, files: List[Dict[str, str]]):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user