Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,11 +130,11 @@ with gr.Blocks(title="Prepperoni - Premiere Pro to XML Converter", css=css) as a
|
|
| 130 |
# Try predicting with the backend
|
| 131 |
try:
|
| 132 |
logger.info(f"Sending file to backend for processing with sequence name: {seq_name}")
|
| 133 |
-
# Use the
|
| 134 |
result = client.predict(
|
| 135 |
handle_file(temp_file_path),
|
| 136 |
seq_name,
|
| 137 |
-
|
| 138 |
)
|
| 139 |
logger.info(f"Got result from backend: {result}")
|
| 140 |
except Exception as e:
|
|
@@ -145,12 +145,13 @@ with gr.Blocks(title="Prepperoni - Premiere Pro to XML Converter", css=css) as a
|
|
| 145 |
shutil.rmtree(temp_dir, ignore_errors=True)
|
| 146 |
|
| 147 |
# Handle the result
|
| 148 |
-
# The backend returns [file_path, message]
|
| 149 |
try:
|
| 150 |
# Extract file path and message from the result
|
| 151 |
-
if isinstance(result, (list, tuple)) and len(result) >=
|
| 152 |
xml_path = result[0]
|
| 153 |
-
message = result[1]
|
|
|
|
| 154 |
else:
|
| 155 |
logger.error(f"Unexpected result format: {result}")
|
| 156 |
return None, "Error: Unexpected response format from backend", "Error"
|
|
@@ -172,14 +173,14 @@ with gr.Blocks(title="Prepperoni - Premiere Pro to XML Converter", css=css) as a
|
|
| 172 |
with open(xml_local_path, "wb") as f:
|
| 173 |
f.write(response.content)
|
| 174 |
logger.info(f"XML file saved to {xml_local_path}")
|
| 175 |
-
return xml_local_path, message, "Success!"
|
| 176 |
else:
|
| 177 |
logger.error(f"Failed to download XML: {response.status_code}")
|
| 178 |
return None, f"Error downloading XML: {response.status_code}", "Error"
|
| 179 |
elif isinstance(xml_path, str) and os.path.exists(xml_path):
|
| 180 |
# It's a local file path that exists
|
| 181 |
logger.info(f"XML file is at local path: {xml_path}")
|
| 182 |
-
return xml_path, message, "Success!"
|
| 183 |
else:
|
| 184 |
logger.error(f"Invalid XML path: {xml_path}")
|
| 185 |
return None, "Error: Invalid XML file path returned from backend", "Error"
|
|
|
|
| 130 |
# Try predicting with the backend
|
| 131 |
try:
|
| 132 |
logger.info(f"Sending file to backend for processing with sequence name: {seq_name}")
|
| 133 |
+
# Use the process_file function from the backend
|
| 134 |
result = client.predict(
|
| 135 |
handle_file(temp_file_path),
|
| 136 |
seq_name,
|
| 137 |
+
api_name="/process_file" # Use the actual function name from the backend
|
| 138 |
)
|
| 139 |
logger.info(f"Got result from backend: {result}")
|
| 140 |
except Exception as e:
|
|
|
|
| 145 |
shutil.rmtree(temp_dir, ignore_errors=True)
|
| 146 |
|
| 147 |
# Handle the result
|
| 148 |
+
# The backend returns [file_path, message, analytics_text]
|
| 149 |
try:
|
| 150 |
# Extract file path and message from the result
|
| 151 |
+
if isinstance(result, (list, tuple)) and len(result) >= 2:
|
| 152 |
xml_path = result[0]
|
| 153 |
+
message = result[1]
|
| 154 |
+
analytics = result[2] if len(result) >= 3 else ""
|
| 155 |
else:
|
| 156 |
logger.error(f"Unexpected result format: {result}")
|
| 157 |
return None, "Error: Unexpected response format from backend", "Error"
|
|
|
|
| 173 |
with open(xml_local_path, "wb") as f:
|
| 174 |
f.write(response.content)
|
| 175 |
logger.info(f"XML file saved to {xml_local_path}")
|
| 176 |
+
return xml_local_path, f"{message}\n\n{analytics}", "Success!"
|
| 177 |
else:
|
| 178 |
logger.error(f"Failed to download XML: {response.status_code}")
|
| 179 |
return None, f"Error downloading XML: {response.status_code}", "Error"
|
| 180 |
elif isinstance(xml_path, str) and os.path.exists(xml_path):
|
| 181 |
# It's a local file path that exists
|
| 182 |
logger.info(f"XML file is at local path: {xml_path}")
|
| 183 |
+
return xml_path, f"{message}\n\n{analytics}", "Success!"
|
| 184 |
else:
|
| 185 |
logger.error(f"Invalid XML path: {xml_path}")
|
| 186 |
return None, "Error: Invalid XML file path returned from backend", "Error"
|