Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,15 +29,15 @@ class SandboxManager:
|
|
| 29 |
try:
|
| 30 |
self.client = Client(engine)
|
| 31 |
self.is_connected = True
|
| 32 |
-
return f"
|
| 33 |
except Exception as e:
|
| 34 |
self.is_connected = False
|
| 35 |
self.current_engine = None
|
| 36 |
-
return f"
|
| 37 |
|
| 38 |
def launch_sandbox(self, main_py_code, requirements_txt):
|
| 39 |
if not self.is_connected:
|
| 40 |
-
return "
|
| 41 |
|
| 42 |
try:
|
| 43 |
result = self.client.predict(
|
|
@@ -45,359 +45,458 @@ class SandboxManager:
|
|
| 45 |
requirements=requirements_txt,
|
| 46 |
api_name="/launch_sandbox"
|
| 47 |
)
|
| 48 |
-
return f"
|
| 49 |
except Exception as e:
|
| 50 |
-
return f"
|
| 51 |
|
| 52 |
def fetch_logs(self):
|
| 53 |
if not self.is_connected:
|
| 54 |
-
return "
|
| 55 |
|
| 56 |
try:
|
| 57 |
result = self.client.predict(api_name="/fetch_logs")
|
| 58 |
timestamp = datetime.now().strftime("%H:%M:%S")
|
| 59 |
-
return f"
|
| 60 |
except Exception as e:
|
| 61 |
-
return f"Failed to fetch logs: {str(e)}"
|
| 62 |
|
| 63 |
def kill_sandbox(self):
|
| 64 |
if not self.is_connected:
|
| 65 |
-
return "
|
| 66 |
|
| 67 |
try:
|
| 68 |
result = self.client.predict(api_name="/kill_sandbox")
|
| 69 |
-
return f"
|
| 70 |
except Exception as e:
|
| 71 |
-
return f"
|
| 72 |
|
| 73 |
def get_status(self):
|
| 74 |
if not self.is_connected:
|
| 75 |
-
return "
|
| 76 |
|
| 77 |
try:
|
| 78 |
result = self.client.predict(api_name="/status_sandbox")
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
except Exception as e:
|
| 82 |
-
return f"
|
| 83 |
|
| 84 |
# Initialize sandbox manager
|
| 85 |
sandbox = SandboxManager()
|
| 86 |
|
| 87 |
-
#
|
| 88 |
SAMPLE_MAIN_PY = """#!/usr/bin/env python3
|
| 89 |
\"\"\"
|
| 90 |
-
|
| 91 |
-
Python Application Template
|
| 92 |
\"\"\"
|
| 93 |
|
| 94 |
import os
|
| 95 |
import sys
|
| 96 |
import json
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
"
|
| 110 |
-
"
|
| 111 |
-
"
|
| 112 |
-
"
|
| 113 |
}
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
if __name__ == "__main__":
|
| 124 |
main()
|
| 125 |
"""
|
| 126 |
|
| 127 |
-
SAMPLE_REQUIREMENTS_TXT = """#
|
| 128 |
-
# Production-
|
| 129 |
-
|
| 130 |
-
# Core utilities
|
| 131 |
-
requests
|
| 132 |
-
python-dateutil
|
| 133 |
-
pytz
|
| 134 |
-
|
| 135 |
-
# Data processing
|
| 136 |
-
numpy
|
| 137 |
-
pandas
|
| 138 |
-
|
| 139 |
-
#
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
#
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
#
|
| 149 |
-
# psycopg2-binary
|
| 150 |
-
#
|
| 151 |
-
|
| 152 |
-
#
|
| 153 |
-
#
|
| 154 |
-
#
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
#
|
| 158 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
"""
|
| 160 |
|
| 161 |
-
#
|
| 162 |
-
|
| 163 |
-
@import url('https://fonts.googleapis.com/css2?family=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
.gradio-container {
|
| 166 |
-
font-family: '
|
| 167 |
-
background-color:
|
| 168 |
-
color:
|
| 169 |
min-height: 100vh;
|
| 170 |
-
|
| 171 |
-
padding: 0;
|
| 172 |
}
|
| 173 |
|
| 174 |
-
/*
|
| 175 |
-
.
|
| 176 |
-
background
|
| 177 |
color: white !important;
|
| 178 |
-
padding:
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
font-size: 14px !important;
|
| 182 |
-
font-weight: 500 !important;
|
| 183 |
}
|
| 184 |
|
| 185 |
-
.
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
font-size: 13px !important;
|
| 190 |
-
border-bottom: 1px solid #485563 !important;
|
| 191 |
}
|
| 192 |
|
| 193 |
-
.
|
| 194 |
-
font-size:
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
margin: 20px 0 10px 0 !important;
|
| 198 |
}
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
}
|
| 208 |
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
font-size: 16px !important;
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
| 217 |
}
|
| 218 |
|
| 219 |
-
.
|
| 220 |
-
padding:
|
| 221 |
}
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
|
|
|
| 225 |
color: white !important;
|
| 226 |
-
border:
|
| 227 |
-
border-radius:
|
| 228 |
-
padding:
|
| 229 |
font-size: 14px !important;
|
| 230 |
font-weight: 500 !important;
|
| 231 |
-
cursor: pointer !important;
|
| 232 |
transition: all 0.2s ease !important;
|
|
|
|
| 233 |
}
|
| 234 |
|
| 235 |
-
.
|
| 236 |
-
|
| 237 |
-
|
| 238 |
}
|
| 239 |
|
| 240 |
-
.
|
| 241 |
-
background-color:
|
| 242 |
-
color:
|
| 243 |
-
border: 1px solid
|
| 244 |
-
border-radius:
|
| 245 |
-
padding:
|
| 246 |
font-size: 14px !important;
|
| 247 |
font-weight: 500 !important;
|
| 248 |
-
cursor: pointer !important;
|
| 249 |
transition: all 0.2s ease !important;
|
| 250 |
}
|
| 251 |
|
| 252 |
-
.
|
| 253 |
-
background-color: #
|
| 254 |
-
border-color:
|
| 255 |
}
|
| 256 |
|
| 257 |
-
.
|
| 258 |
-
background-color
|
| 259 |
color: white !important;
|
| 260 |
-
border:
|
| 261 |
-
border-radius:
|
| 262 |
-
padding:
|
| 263 |
font-size: 14px !important;
|
| 264 |
font-weight: 500 !important;
|
| 265 |
-
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
-
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
}
|
| 271 |
|
| 272 |
-
.
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
border: 1px solid #
|
| 276 |
-
border-radius:
|
| 277 |
-
padding:
|
| 278 |
-
font-
|
| 279 |
-
|
| 280 |
}
|
| 281 |
|
| 282 |
-
.
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
border: 1px solid #
|
| 286 |
-
border-radius:
|
| 287 |
-
padding:
|
| 288 |
-
font-
|
| 289 |
-
|
| 290 |
}
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
border
|
| 297 |
-
|
| 298 |
font-size: 14px !important;
|
| 299 |
-
|
|
|
|
| 300 |
}
|
| 301 |
|
| 302 |
-
.
|
| 303 |
-
font-family: '
|
| 304 |
-
background
|
| 305 |
-
border:
|
| 306 |
-
border-radius:
|
| 307 |
font-size: 13px !important;
|
| 308 |
-
}
|
| 309 |
-
|
| 310 |
-
.aws-logs {
|
| 311 |
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace !important;
|
| 312 |
-
background-color: #232f3e !important;
|
| 313 |
-
color: #ffffff !important;
|
| 314 |
-
border: 1px solid #d5dbdb !important;
|
| 315 |
-
border-radius: 4px !important;
|
| 316 |
-
font-size: 12px !important;
|
| 317 |
line-height: 1.4 !important;
|
| 318 |
}
|
| 319 |
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
}
|
| 331 |
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
border
|
| 336 |
-
|
|
|
|
|
|
|
| 337 |
height: fit-content !important;
|
| 338 |
}
|
| 339 |
|
| 340 |
-
.
|
| 341 |
-
background
|
| 342 |
-
border-bottom: 1px solid #d5dbdb !important;
|
| 343 |
padding: 12px 16px !important;
|
| 344 |
-
font-weight:
|
| 345 |
-
color: #232f3e !important;
|
| 346 |
font-size: 14px !important;
|
| 347 |
-
|
|
|
|
| 348 |
}
|
| 349 |
|
| 350 |
-
.
|
| 351 |
padding: 16px !important;
|
| 352 |
}
|
| 353 |
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
border-radius: 4px !important;
|
| 358 |
-
padding: 12px !important;
|
| 359 |
-
margin: 8px 0 !important;
|
| 360 |
-
font-size: 13px !important;
|
| 361 |
-
color: #232f3e !important;
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
.aws-breadcrumb {
|
| 365 |
-
font-size: 12px !important;
|
| 366 |
-
color: #687078 !important;
|
| 367 |
-
margin: 8px 20px !important;
|
| 368 |
}
|
| 369 |
|
| 370 |
-
.
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
|
|
|
| 375 |
}
|
| 376 |
|
| 377 |
-
.
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
|
| 381 |
-
|
|
|
|
| 382 |
text-align: center !important;
|
| 383 |
-
padding:
|
| 384 |
-
border-right: 1px solid
|
| 385 |
}
|
| 386 |
|
| 387 |
-
.
|
| 388 |
border-right: none !important;
|
| 389 |
}
|
| 390 |
|
| 391 |
-
.
|
| 392 |
-
font-size:
|
| 393 |
-
font-weight:
|
| 394 |
-
color:
|
|
|
|
| 395 |
}
|
| 396 |
|
| 397 |
-
.
|
| 398 |
font-size: 12px !important;
|
| 399 |
-
color:
|
| 400 |
margin-top: 4px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
}
|
| 402 |
"""
|
| 403 |
|
|
@@ -408,157 +507,151 @@ def auto_refresh_logs():
|
|
| 408 |
return sandbox.fetch_logs()
|
| 409 |
|
| 410 |
def load_sample_files():
|
| 411 |
-
"""Load sample files
|
| 412 |
return SAMPLE_MAIN_PY, SAMPLE_REQUIREMENTS_TXT
|
| 413 |
|
| 414 |
-
# Build the
|
| 415 |
-
with gr.Blocks(css=
|
| 416 |
|
| 417 |
-
#
|
| 418 |
gr.HTML("""
|
| 419 |
-
<div class="
|
| 420 |
-
<
|
| 421 |
-
<
|
| 422 |
-
</div>
|
| 423 |
-
<div class="aws-nav">
|
| 424 |
-
Services > Compute > Sandbox > Management Console
|
| 425 |
</div>
|
| 426 |
-
<div class="
|
| 427 |
-
|
| 428 |
</div>
|
| 429 |
""")
|
| 430 |
|
| 431 |
-
# Service Title
|
| 432 |
-
gr.HTML('<div class="aws-service-title">Sandbox Compute Service</div>')
|
| 433 |
-
|
| 434 |
with gr.Row():
|
| 435 |
# Main Content Area
|
| 436 |
with gr.Column(scale=3):
|
| 437 |
-
#
|
| 438 |
-
with gr.Group(elem_classes=["
|
| 439 |
-
gr.HTML('<div class="
|
| 440 |
-
with gr.Group(elem_classes=["
|
| 441 |
with gr.Row():
|
| 442 |
-
connect_btn = gr.Button("
|
| 443 |
-
load_samples_btn = gr.Button("Load
|
| 444 |
|
|
|
|
| 445 |
current_engine_display = gr.Textbox(
|
| 446 |
value="No engine selected",
|
| 447 |
-
label="Active Compute Engine",
|
| 448 |
interactive=False,
|
| 449 |
-
elem_classes=["
|
|
|
|
| 450 |
)
|
| 451 |
|
|
|
|
| 452 |
connection_status = gr.Textbox(
|
| 453 |
-
value="
|
| 454 |
-
label="Connection Status",
|
| 455 |
interactive=False,
|
| 456 |
-
elem_classes=["
|
|
|
|
| 457 |
)
|
| 458 |
|
| 459 |
-
#
|
| 460 |
-
with gr.Group(elem_classes=["
|
| 461 |
-
gr.HTML('<div class="
|
| 462 |
-
with gr.Group(elem_classes=["
|
| 463 |
-
with gr.Tab("main.py"
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
)
|
| 473 |
|
| 474 |
-
with gr.Tab("requirements.txt"
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
)
|
| 484 |
|
| 485 |
-
# Deployment
|
| 486 |
-
gr.HTML('<div
|
| 487 |
with gr.Row():
|
| 488 |
-
launch_btn = gr.Button("Deploy Application", elem_classes=["
|
| 489 |
-
kill_btn = gr.Button("Terminate Instance", elem_classes=["
|
| 490 |
|
| 491 |
-
|
| 492 |
-
gr.HTML('<div class="aws-form-label" style="margin-top: 16px;">Deployment Status</div>')
|
| 493 |
launch_output = gr.Textbox(
|
| 494 |
lines=6,
|
| 495 |
interactive=False,
|
| 496 |
-
placeholder="Deployment
|
| 497 |
-
elem_classes=["
|
| 498 |
show_label=False
|
| 499 |
)
|
| 500 |
|
| 501 |
-
#
|
| 502 |
with gr.Column(scale=1):
|
| 503 |
-
#
|
| 504 |
-
with gr.Group(elem_classes=["
|
| 505 |
-
gr.HTML('<div class="
|
| 506 |
-
with gr.Group(elem_classes=["
|
|
|
|
| 507 |
status_display = gr.Textbox(
|
| 508 |
-
value="
|
| 509 |
-
label="Current Status",
|
| 510 |
interactive=False,
|
| 511 |
-
elem_classes=["
|
|
|
|
| 512 |
)
|
| 513 |
|
| 514 |
-
status_refresh_btn = gr.Button("Refresh Status", elem_classes=["
|
| 515 |
|
| 516 |
-
gr.HTML('<div
|
| 517 |
|
| 518 |
-
|
| 519 |
-
gr.HTML('<div class="aws-form-label">Auto-Refresh Settings</div>')
|
| 520 |
auto_refresh_status_cb = gr.Checkbox(
|
| 521 |
-
label="
|
| 522 |
value=False
|
| 523 |
)
|
| 524 |
auto_refresh_logs_cb = gr.Checkbox(
|
| 525 |
-
label="
|
| 526 |
value=False
|
| 527 |
)
|
| 528 |
|
| 529 |
-
#
|
| 530 |
-
with gr.Group(elem_classes=["
|
| 531 |
-
gr.HTML('<div class="
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
<div class="
|
| 535 |
-
<div class="
|
| 536 |
-
<div class="
|
| 537 |
</div>
|
| 538 |
-
<div class="
|
| 539 |
-
<div class="
|
| 540 |
-
<div class="
|
| 541 |
</div>
|
| 542 |
-
<div class="
|
| 543 |
-
<div class="
|
| 544 |
-
<div class="
|
| 545 |
</div>
|
| 546 |
-
|
|
|
|
| 547 |
|
| 548 |
-
# Logs
|
| 549 |
-
with gr.Group(elem_classes=["
|
| 550 |
-
gr.HTML('<div class="
|
| 551 |
-
with gr.Group(elem_classes=["
|
| 552 |
with gr.Row():
|
| 553 |
-
fetch_logs_btn = gr.Button("Fetch Logs", elem_classes=["
|
| 554 |
gr.HTML('<div style="flex-grow: 1;"></div>')
|
| 555 |
|
| 556 |
-
gr.HTML('<div class="
|
| 557 |
logs_display = gr.Textbox(
|
| 558 |
-
lines=
|
| 559 |
interactive=False,
|
| 560 |
-
elem_classes=["
|
| 561 |
-
placeholder="Application logs will
|
| 562 |
show_label=False
|
| 563 |
)
|
| 564 |
|
|
@@ -623,11 +716,13 @@ with gr.Blocks(css=aws_css, title="AWS Sandbox Service", theme=gr.themes.Default
|
|
| 623 |
outputs=[logs_timer]
|
| 624 |
)
|
| 625 |
|
| 626 |
-
# Footer
|
| 627 |
gr.HTML("""
|
| 628 |
-
<div style="text-align: center; margin-top: 40px; padding:
|
| 629 |
-
<p
|
| 630 |
-
<p
|
|
|
|
|
|
|
| 631 |
</div>
|
| 632 |
""")
|
| 633 |
|
|
|
|
| 29 |
try:
|
| 30 |
self.client = Client(engine)
|
| 31 |
self.is_connected = True
|
| 32 |
+
return f"β Connected to: {engine}", engine
|
| 33 |
except Exception as e:
|
| 34 |
self.is_connected = False
|
| 35 |
self.current_engine = None
|
| 36 |
+
return f"β Connection failed to {engine}: {str(e)}", "Not connected"
|
| 37 |
|
| 38 |
def launch_sandbox(self, main_py_code, requirements_txt):
|
| 39 |
if not self.is_connected:
|
| 40 |
+
return "β Not connected to backend. Please connect first.", ""
|
| 41 |
|
| 42 |
try:
|
| 43 |
result = self.client.predict(
|
|
|
|
| 45 |
requirements=requirements_txt,
|
| 46 |
api_name="/launch_sandbox"
|
| 47 |
)
|
| 48 |
+
return f"β Sandbox deployed successfully on {self.current_engine}\n\nResponse: {result}", self.get_status()
|
| 49 |
except Exception as e:
|
| 50 |
+
return f"β Deployment failed: {str(e)}", ""
|
| 51 |
|
| 52 |
def fetch_logs(self):
|
| 53 |
if not self.is_connected:
|
| 54 |
+
return "β Not connected to backend"
|
| 55 |
|
| 56 |
try:
|
| 57 |
result = self.client.predict(api_name="/fetch_logs")
|
| 58 |
timestamp = datetime.now().strftime("%H:%M:%S")
|
| 59 |
+
return f"[{timestamp}] Logs from {self.current_engine}:\n\n{result}"
|
| 60 |
except Exception as e:
|
| 61 |
+
return f"[ERROR] Failed to fetch logs: {str(e)}"
|
| 62 |
|
| 63 |
def kill_sandbox(self):
|
| 64 |
if not self.is_connected:
|
| 65 |
+
return "β Not connected to backend", ""
|
| 66 |
|
| 67 |
try:
|
| 68 |
result = self.client.predict(api_name="/kill_sandbox")
|
| 69 |
+
return f"β Sandbox terminated on {self.current_engine}\n\nResponse: {result}", self.get_status()
|
| 70 |
except Exception as e:
|
| 71 |
+
return f"β Termination failed: {str(e)}", ""
|
| 72 |
|
| 73 |
def get_status(self):
|
| 74 |
if not self.is_connected:
|
| 75 |
+
return "OFFLINE"
|
| 76 |
|
| 77 |
try:
|
| 78 |
result = self.client.predict(api_name="/status_sandbox")
|
| 79 |
+
if "running" in str(result).lower():
|
| 80 |
+
return f"RUNNING - {result}"
|
| 81 |
+
else:
|
| 82 |
+
return f"IDLE - {result}"
|
| 83 |
except Exception as e:
|
| 84 |
+
return f"ERROR - {str(e)}"
|
| 85 |
|
| 86 |
# Initialize sandbox manager
|
| 87 |
sandbox = SandboxManager()
|
| 88 |
|
| 89 |
+
# Professional code templates
|
| 90 |
SAMPLE_MAIN_PY = """#!/usr/bin/env python3
|
| 91 |
\"\"\"
|
| 92 |
+
Sandbox Compute Environment
|
| 93 |
+
Enterprise Python Application Template
|
| 94 |
\"\"\"
|
| 95 |
|
| 96 |
import os
|
| 97 |
import sys
|
| 98 |
import json
|
| 99 |
+
import logging
|
| 100 |
+
from datetime import datetime, timezone
|
| 101 |
+
|
| 102 |
+
# Configure logging
|
| 103 |
+
logging.basicConfig(
|
| 104 |
+
level=logging.INFO,
|
| 105 |
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
| 106 |
+
)
|
| 107 |
+
logger = logging.getLogger(__name__)
|
| 108 |
+
|
| 109 |
+
def initialize_environment():
|
| 110 |
+
\"\"\"Initialize the compute environment\"\"\"
|
| 111 |
+
logger.info("Initializing sandbox environment...")
|
| 112 |
|
| 113 |
+
env_info = {
|
| 114 |
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
| 115 |
+
"python_version": sys.version,
|
| 116 |
+
"platform": os.name,
|
| 117 |
+
"working_directory": os.getcwd(),
|
| 118 |
+
"environment_variables": dict(os.environ)
|
| 119 |
}
|
| 120 |
|
| 121 |
+
logger.info(f"Environment initialized: {env_info['timestamp']}")
|
| 122 |
+
return env_info
|
| 123 |
+
|
| 124 |
+
def execute_business_logic():
|
| 125 |
+
\"\"\"Main application business logic\"\"\"
|
| 126 |
+
logger.info("Executing main application logic...")
|
| 127 |
+
|
| 128 |
+
# Example: Data processing pipeline
|
| 129 |
+
data_points = list(range(1, 101))
|
| 130 |
+
processed_data = [x ** 2 for x in data_points if x % 2 == 0]
|
| 131 |
+
|
| 132 |
+
result = {
|
| 133 |
+
"status": "success",
|
| 134 |
+
"data_points_processed": len(processed_data),
|
| 135 |
+
"sum_of_squares": sum(processed_data),
|
| 136 |
+
"processing_time": datetime.now(timezone.utc).isoformat()
|
| 137 |
+
}
|
| 138 |
|
| 139 |
+
logger.info(f"Processing complete: {result}")
|
| 140 |
+
return result
|
| 141 |
+
|
| 142 |
+
def main():
|
| 143 |
+
\"\"\"Main application entry point\"\"\"
|
| 144 |
+
try:
|
| 145 |
+
print("=" * 60)
|
| 146 |
+
print("SANDBOX COMPUTE ENVIRONMENT - PRODUCTION RUNTIME")
|
| 147 |
+
print("=" * 60)
|
| 148 |
+
|
| 149 |
+
# Initialize
|
| 150 |
+
env_info = initialize_environment()
|
| 151 |
+
print(f"Environment: {env_info['platform']}")
|
| 152 |
+
print(f"Python: {env_info['python_version'].split()[0]}")
|
| 153 |
+
print(f"Started: {env_info['timestamp']}")
|
| 154 |
+
|
| 155 |
+
print("\\n" + "-" * 40)
|
| 156 |
+
print("EXECUTING APPLICATION LOGIC")
|
| 157 |
+
print("-" * 40)
|
| 158 |
+
|
| 159 |
+
# Execute business logic
|
| 160 |
+
result = execute_business_logic()
|
| 161 |
+
|
| 162 |
+
# Output results
|
| 163 |
+
print(f"\\nStatus: {result['status'].upper()}")
|
| 164 |
+
print(f"Data Points: {result['data_points_processed']}")
|
| 165 |
+
print(f"Computation Result: {result['sum_of_squares']}")
|
| 166 |
+
print(f"Completed: {result['processing_time']}")
|
| 167 |
+
|
| 168 |
+
print("\\n" + "=" * 60)
|
| 169 |
+
print("APPLICATION EXECUTION COMPLETED SUCCESSFULLY")
|
| 170 |
+
print("=" * 60)
|
| 171 |
+
|
| 172 |
+
except Exception as e:
|
| 173 |
+
logger.error(f"Application failed: {str(e)}")
|
| 174 |
+
raise
|
| 175 |
|
| 176 |
if __name__ == "__main__":
|
| 177 |
main()
|
| 178 |
"""
|
| 179 |
|
| 180 |
+
SAMPLE_REQUIREMENTS_TXT = """# Enterprise Python Dependencies
|
| 181 |
+
# Production-grade package specifications
|
| 182 |
+
|
| 183 |
+
# Core utilities and date handling
|
| 184 |
+
requests>=2.31.0,<3.0.0
|
| 185 |
+
python-dateutil>=2.8.2,<3.0.0
|
| 186 |
+
pytz>=2023.3
|
| 187 |
+
|
| 188 |
+
# Data processing and analysis
|
| 189 |
+
numpy>=1.24.0,<2.0.0
|
| 190 |
+
pandas>=2.0.0,<3.0.0
|
| 191 |
+
|
| 192 |
+
# Logging and monitoring
|
| 193 |
+
structlog>=23.1.0
|
| 194 |
+
prometheus-client>=0.17.0
|
| 195 |
+
|
| 196 |
+
# Configuration management
|
| 197 |
+
pydantic>=2.0.0,<3.0.0
|
| 198 |
+
python-dotenv>=1.0.0
|
| 199 |
+
|
| 200 |
+
# Database connectivity (uncomment as needed)
|
| 201 |
+
# sqlalchemy>=2.0.0,<3.0.0
|
| 202 |
+
# psycopg2-binary>=2.9.0
|
| 203 |
+
# redis>=4.5.0
|
| 204 |
+
|
| 205 |
+
# Web frameworks (uncomment as needed)
|
| 206 |
+
# fastapi>=0.100.0,<1.0.0
|
| 207 |
+
# uvicorn[standard]>=0.23.0
|
| 208 |
+
# gunicorn>=21.0.0
|
| 209 |
+
|
| 210 |
+
# Scientific computing (uncomment as needed)
|
| 211 |
+
# scipy>=1.11.0,<2.0.0
|
| 212 |
+
# scikit-learn>=1.3.0,<2.0.0
|
| 213 |
+
# matplotlib>=3.7.0,<4.0.0
|
| 214 |
+
|
| 215 |
+
# Development and testing (uncomment as needed)
|
| 216 |
+
# pytest>=7.4.0,<8.0.0
|
| 217 |
+
# black>=23.0.0,<24.0.0
|
| 218 |
+
# mypy>=1.5.0,<2.0.0
|
| 219 |
+
# flake8>=6.0.0,<7.0.0
|
| 220 |
"""
|
| 221 |
|
| 222 |
+
# Professional industrial CSS
|
| 223 |
+
professional_css = """
|
| 224 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
|
| 225 |
+
|
| 226 |
+
:root {
|
| 227 |
+
--primary-color: #2563eb;
|
| 228 |
+
--primary-hover: #1d4ed8;
|
| 229 |
+
--secondary-color: #64748b;
|
| 230 |
+
--success-color: #059669;
|
| 231 |
+
--warning-color: #d97706;
|
| 232 |
+
--danger-color: #dc2626;
|
| 233 |
+
--background: #f8fafc;
|
| 234 |
+
--surface: #ffffff;
|
| 235 |
+
--border: #e2e8f0;
|
| 236 |
+
--text-primary: #1e293b;
|
| 237 |
+
--text-secondary: #64748b;
|
| 238 |
+
--text-muted: #94a3b8;
|
| 239 |
+
}
|
| 240 |
|
| 241 |
.gradio-container {
|
| 242 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
| 243 |
+
background-color: var(--background) !important;
|
| 244 |
+
color: var(--text-primary) !important;
|
| 245 |
min-height: 100vh;
|
| 246 |
+
line-height: 1.5;
|
|
|
|
| 247 |
}
|
| 248 |
|
| 249 |
+
/* Professional Header */
|
| 250 |
+
.platform-header {
|
| 251 |
+
background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
|
| 252 |
color: white !important;
|
| 253 |
+
padding: 16px 24px !important;
|
| 254 |
+
border-bottom: 3px solid var(--primary-color) !important;
|
| 255 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
|
|
|
|
|
|
|
| 256 |
}
|
| 257 |
|
| 258 |
+
.platform-title {
|
| 259 |
+
font-size: 24px !important;
|
| 260 |
+
font-weight: 700 !important;
|
| 261 |
+
letter-spacing: -0.025em !important;
|
|
|
|
|
|
|
| 262 |
}
|
| 263 |
|
| 264 |
+
.platform-subtitle {
|
| 265 |
+
font-size: 14px !important;
|
| 266 |
+
opacity: 0.8 !important;
|
| 267 |
+
margin-top: 4px !important;
|
|
|
|
| 268 |
}
|
| 269 |
|
| 270 |
+
/* Navigation */
|
| 271 |
+
.nav-breadcrumb {
|
| 272 |
+
background-color: #f1f5f9 !important;
|
| 273 |
+
padding: 12px 24px !important;
|
| 274 |
+
font-size: 13px !important;
|
| 275 |
+
color: var(--text-secondary) !important;
|
| 276 |
+
border-bottom: 1px solid var(--border) !important;
|
| 277 |
}
|
| 278 |
|
| 279 |
+
/* Container System */
|
| 280 |
+
.enterprise-container {
|
| 281 |
+
background-color: var(--surface) !important;
|
| 282 |
+
border: 1px solid var(--border) !important;
|
| 283 |
+
border-radius: 12px !important;
|
| 284 |
+
margin: 20px !important;
|
| 285 |
+
overflow: hidden !important;
|
| 286 |
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
.container-header {
|
| 290 |
+
background: linear-gradient(to right, #f8fafc, #f1f5f9) !important;
|
| 291 |
+
border-bottom: 1px solid var(--border) !important;
|
| 292 |
+
padding: 16px 24px !important;
|
| 293 |
+
font-weight: 600 !important;
|
| 294 |
font-size: 16px !important;
|
| 295 |
+
color: var(--text-primary) !important;
|
| 296 |
+
display: flex !important;
|
| 297 |
+
align-items: center !important;
|
| 298 |
+
gap: 8px !important;
|
| 299 |
}
|
| 300 |
|
| 301 |
+
.container-content {
|
| 302 |
+
padding: 24px !important;
|
| 303 |
}
|
| 304 |
|
| 305 |
+
/* Professional Buttons */
|
| 306 |
+
.btn-primary {
|
| 307 |
+
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
|
| 308 |
color: white !important;
|
| 309 |
+
border: none !important;
|
| 310 |
+
border-radius: 8px !important;
|
| 311 |
+
padding: 12px 24px !important;
|
| 312 |
font-size: 14px !important;
|
| 313 |
font-weight: 500 !important;
|
|
|
|
| 314 |
transition: all 0.2s ease !important;
|
| 315 |
+
box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2) !important;
|
| 316 |
}
|
| 317 |
|
| 318 |
+
.btn-primary:hover {
|
| 319 |
+
transform: translateY(-1px) !important;
|
| 320 |
+
box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3) !important;
|
| 321 |
}
|
| 322 |
|
| 323 |
+
.btn-secondary {
|
| 324 |
+
background-color: var(--surface) !important;
|
| 325 |
+
color: var(--text-primary) !important;
|
| 326 |
+
border: 1px solid var(--border) !important;
|
| 327 |
+
border-radius: 8px !important;
|
| 328 |
+
padding: 12px 24px !important;
|
| 329 |
font-size: 14px !important;
|
| 330 |
font-weight: 500 !important;
|
|
|
|
| 331 |
transition: all 0.2s ease !important;
|
| 332 |
}
|
| 333 |
|
| 334 |
+
.btn-secondary:hover {
|
| 335 |
+
background-color: #f8fafc !important;
|
| 336 |
+
border-color: var(--secondary-color) !important;
|
| 337 |
}
|
| 338 |
|
| 339 |
+
.btn-danger {
|
| 340 |
+
background: linear-gradient(135deg, var(--danger-color) 0%, #b91c1c 100%) !important;
|
| 341 |
color: white !important;
|
| 342 |
+
border: none !important;
|
| 343 |
+
border-radius: 8px !important;
|
| 344 |
+
padding: 12px 24px !important;
|
| 345 |
font-size: 14px !important;
|
| 346 |
font-weight: 500 !important;
|
| 347 |
+
transition: all 0.2s ease !important;
|
| 348 |
+
box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2) !important;
|
| 349 |
}
|
| 350 |
|
| 351 |
+
/* Status Indicators */
|
| 352 |
+
.status-online {
|
| 353 |
+
background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%) !important;
|
| 354 |
+
color: var(--success-color) !important;
|
| 355 |
+
border: 1px solid #86efac !important;
|
| 356 |
+
border-radius: 8px !important;
|
| 357 |
+
padding: 16px !important;
|
| 358 |
+
font-weight: 600 !important;
|
| 359 |
+
text-align: center !important;
|
| 360 |
}
|
| 361 |
|
| 362 |
+
.status-offline {
|
| 363 |
+
background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
|
| 364 |
+
color: var(--danger-color) !important;
|
| 365 |
+
border: 1px solid #fca5a5 !important;
|
| 366 |
+
border-radius: 8px !important;
|
| 367 |
+
padding: 16px !important;
|
| 368 |
+
font-weight: 600 !important;
|
| 369 |
+
text-align: center !important;
|
| 370 |
}
|
| 371 |
|
| 372 |
+
.status-warning {
|
| 373 |
+
background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%) !important;
|
| 374 |
+
color: var(--warning-color) !important;
|
| 375 |
+
border: 1px solid #fde68a !important;
|
| 376 |
+
border-radius: 8px !important;
|
| 377 |
+
padding: 16px !important;
|
| 378 |
+
font-weight: 600 !important;
|
| 379 |
+
text-align: center !important;
|
| 380 |
}
|
| 381 |
|
| 382 |
+
/* Code Editor */
|
| 383 |
+
.code-editor-professional {
|
| 384 |
+
font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace !important;
|
| 385 |
+
background: #1e1e1e !important;
|
| 386 |
+
border: 2px solid var(--border) !important;
|
| 387 |
+
border-radius: 8px !important;
|
| 388 |
font-size: 14px !important;
|
| 389 |
+
line-height: 1.5 !important;
|
| 390 |
+
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06) !important;
|
| 391 |
}
|
| 392 |
|
| 393 |
+
.requirements-editor {
|
| 394 |
+
font-family: 'JetBrains Mono', monospace !important;
|
| 395 |
+
background: #2d2d2d !important;
|
| 396 |
+
border: 2px solid var(--border) !important;
|
| 397 |
+
border-radius: 8px !important;
|
| 398 |
font-size: 13px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
line-height: 1.4 !important;
|
| 400 |
}
|
| 401 |
|
| 402 |
+
/* Logs Terminal */
|
| 403 |
+
.terminal-logs {
|
| 404 |
+
font-family: 'JetBrains Mono', monospace !important;
|
| 405 |
+
background: #0f172a !important;
|
| 406 |
+
color: #e2e8f0 !important;
|
| 407 |
+
border: 2px solid #334155 !important;
|
| 408 |
+
border-radius: 8px !important;
|
| 409 |
+
font-size: 13px !important;
|
| 410 |
+
line-height: 1.6 !important;
|
| 411 |
+
padding: 16px !important;
|
| 412 |
}
|
| 413 |
|
| 414 |
+
/* Sidebar */
|
| 415 |
+
.monitoring-panel {
|
| 416 |
+
background-color: var(--surface) !important;
|
| 417 |
+
border: 1px solid var(--border) !important;
|
| 418 |
+
border-radius: 12px !important;
|
| 419 |
+
overflow: hidden !important;
|
| 420 |
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
|
| 421 |
height: fit-content !important;
|
| 422 |
}
|
| 423 |
|
| 424 |
+
.panel-header {
|
| 425 |
+
background: linear-gradient(to right, #f1f5f9, #e2e8f0) !important;
|
|
|
|
| 426 |
padding: 12px 16px !important;
|
| 427 |
+
font-weight: 600 !important;
|
|
|
|
| 428 |
font-size: 14px !important;
|
| 429 |
+
color: var(--text-primary) !important;
|
| 430 |
+
border-bottom: 1px solid var(--border) !important;
|
| 431 |
}
|
| 432 |
|
| 433 |
+
.panel-content {
|
| 434 |
padding: 16px !important;
|
| 435 |
}
|
| 436 |
|
| 437 |
+
/* Form Elements */
|
| 438 |
+
.form-group {
|
| 439 |
+
margin-bottom: 20px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
}
|
| 441 |
|
| 442 |
+
.form-label {
|
| 443 |
+
font-size: 14px !important;
|
| 444 |
+
font-weight: 500 !important;
|
| 445 |
+
color: var(--text-primary) !important;
|
| 446 |
+
margin-bottom: 6px !important;
|
| 447 |
+
display: block !important;
|
| 448 |
}
|
| 449 |
|
| 450 |
+
.info-badge {
|
| 451 |
+
background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
|
| 452 |
+
color: var(--primary-color) !important;
|
| 453 |
+
border: 1px solid #93c5fd !important;
|
| 454 |
+
border-radius: 6px !important;
|
| 455 |
+
padding: 12px 16px !important;
|
| 456 |
+
font-size: 13px !important;
|
| 457 |
+
font-weight: 500 !important;
|
| 458 |
}
|
| 459 |
|
| 460 |
+
/* Metrics */
|
| 461 |
+
.metric-card {
|
| 462 |
text-align: center !important;
|
| 463 |
+
padding: 16px !important;
|
| 464 |
+
border-right: 1px solid var(--border) !important;
|
| 465 |
}
|
| 466 |
|
| 467 |
+
.metric-card:last-child {
|
| 468 |
border-right: none !important;
|
| 469 |
}
|
| 470 |
|
| 471 |
+
.metric-value {
|
| 472 |
+
font-size: 28px !important;
|
| 473 |
+
font-weight: 700 !important;
|
| 474 |
+
color: var(--primary-color) !important;
|
| 475 |
+
line-height: 1 !important;
|
| 476 |
}
|
| 477 |
|
| 478 |
+
.metric-label {
|
| 479 |
font-size: 12px !important;
|
| 480 |
+
color: var(--text-secondary) !important;
|
| 481 |
margin-top: 4px !important;
|
| 482 |
+
font-weight: 500 !important;
|
| 483 |
+
text-transform: uppercase !important;
|
| 484 |
+
letter-spacing: 0.025em !important;
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
/* Professional spacing */
|
| 488 |
+
.section-divider {
|
| 489 |
+
height: 1px !important;
|
| 490 |
+
background: var(--border) !important;
|
| 491 |
+
margin: 24px 0 !important;
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
.mb-4 {
|
| 495 |
+
margin-bottom: 16px !important;
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
.mt-4 {
|
| 499 |
+
margin-top: 16px !important;
|
| 500 |
}
|
| 501 |
"""
|
| 502 |
|
|
|
|
| 507 |
return sandbox.fetch_logs()
|
| 508 |
|
| 509 |
def load_sample_files():
|
| 510 |
+
"""Load professional sample files"""
|
| 511 |
return SAMPLE_MAIN_PY, SAMPLE_REQUIREMENTS_TXT
|
| 512 |
|
| 513 |
+
# Build the professional interface
|
| 514 |
+
with gr.Blocks(css=professional_css, title="Sandbox Compute Platform", theme=gr.themes.Default()) as demo:
|
| 515 |
|
| 516 |
+
# Platform Header
|
| 517 |
gr.HTML("""
|
| 518 |
+
<div class="platform-header">
|
| 519 |
+
<div class="platform-title">Sandbox Compute Platform</div>
|
| 520 |
+
<div class="platform-subtitle">Enterprise-grade cloud computing infrastructure</div>
|
|
|
|
|
|
|
|
|
|
| 521 |
</div>
|
| 522 |
+
<div class="nav-breadcrumb">
|
| 523 |
+
Dashboard β Compute Services β Sandbox Management Console
|
| 524 |
</div>
|
| 525 |
""")
|
| 526 |
|
|
|
|
|
|
|
|
|
|
| 527 |
with gr.Row():
|
| 528 |
# Main Content Area
|
| 529 |
with gr.Column(scale=3):
|
| 530 |
+
# Infrastructure Management
|
| 531 |
+
with gr.Group(elem_classes=["enterprise-container"]):
|
| 532 |
+
gr.HTML('<div class="container-header">π§ Infrastructure Management</div>')
|
| 533 |
+
with gr.Group(elem_classes=["container-content"]):
|
| 534 |
with gr.Row():
|
| 535 |
+
connect_btn = gr.Button("Initialize Connection", elem_classes=["btn-primary"])
|
| 536 |
+
load_samples_btn = gr.Button("Load Templates", elem_classes=["btn-secondary"])
|
| 537 |
|
| 538 |
+
gr.HTML('<div class="form-label mt-4">Active Compute Engine</div>')
|
| 539 |
current_engine_display = gr.Textbox(
|
| 540 |
value="No engine selected",
|
|
|
|
| 541 |
interactive=False,
|
| 542 |
+
elem_classes=["info-badge"],
|
| 543 |
+
show_label=False
|
| 544 |
)
|
| 545 |
|
| 546 |
+
gr.HTML('<div class="form-label mt-4">Connection Status</div>')
|
| 547 |
connection_status = gr.Textbox(
|
| 548 |
+
value="DISCONNECTED",
|
|
|
|
| 549 |
interactive=False,
|
| 550 |
+
elem_classes=["status-offline"],
|
| 551 |
+
show_label=False
|
| 552 |
)
|
| 553 |
|
| 554 |
+
# Development Environment
|
| 555 |
+
with gr.Group(elem_classes=["enterprise-container"]):
|
| 556 |
+
gr.HTML('<div class="container-header">π» Development Environment</div>')
|
| 557 |
+
with gr.Group(elem_classes=["container-content"]):
|
| 558 |
+
with gr.Tab("main.py"):
|
| 559 |
+
gr.HTML('<div class="form-label">Application Source Code</div>')
|
| 560 |
+
main_py_editor = gr.Code(
|
| 561 |
+
value="# Enterprise Python Application\nprint('Sandbox Compute Platform - Ready')",
|
| 562 |
+
language="python",
|
| 563 |
+
lines=20,
|
| 564 |
+
elem_classes=["code-editor-professional"],
|
| 565 |
+
show_label=False
|
| 566 |
+
)
|
|
|
|
| 567 |
|
| 568 |
+
with gr.Tab("requirements.txt"):
|
| 569 |
+
gr.HTML('<div class="form-label">Dependency Specifications</div>')
|
| 570 |
+
requirements_editor = gr.Textbox(
|
| 571 |
+
value="# Production dependencies\n# Specify exact versions for reproducibility",
|
| 572 |
+
lines=20,
|
| 573 |
+
elem_classes=["requirements-editor"],
|
| 574 |
+
show_label=False,
|
| 575 |
+
max_lines=25
|
| 576 |
+
)
|
|
|
|
| 577 |
|
| 578 |
+
# Deployment Controls
|
| 579 |
+
gr.HTML('<div class="section-divider"></div>')
|
| 580 |
with gr.Row():
|
| 581 |
+
launch_btn = gr.Button("Deploy Application", elem_classes=["btn-primary"], size="lg")
|
| 582 |
+
kill_btn = gr.Button("Terminate Instance", elem_classes=["btn-danger"], size="lg")
|
| 583 |
|
| 584 |
+
gr.HTML('<div class="form-label mt-4">Deployment Output</div>')
|
|
|
|
| 585 |
launch_output = gr.Textbox(
|
| 586 |
lines=6,
|
| 587 |
interactive=False,
|
| 588 |
+
placeholder="Deployment logs and status information will appear here...",
|
| 589 |
+
elem_classes=["terminal-logs"],
|
| 590 |
show_label=False
|
| 591 |
)
|
| 592 |
|
| 593 |
+
# Monitoring Panel
|
| 594 |
with gr.Column(scale=1):
|
| 595 |
+
# System Status
|
| 596 |
+
with gr.Group(elem_classes=["monitoring-panel"]):
|
| 597 |
+
gr.HTML('<div class="panel-header">π System Monitor</div>')
|
| 598 |
+
with gr.Group(elem_classes=["panel-content"]):
|
| 599 |
+
gr.HTML('<div class="form-label">Instance Status</div>')
|
| 600 |
status_display = gr.Textbox(
|
| 601 |
+
value="OFFLINE",
|
|
|
|
| 602 |
interactive=False,
|
| 603 |
+
elem_classes=["status-offline"],
|
| 604 |
+
show_label=False
|
| 605 |
)
|
| 606 |
|
| 607 |
+
status_refresh_btn = gr.Button("Refresh Status", elem_classes=["btn-secondary"], size="sm")
|
| 608 |
|
| 609 |
+
gr.HTML('<div class="section-divider"></div>')
|
| 610 |
|
| 611 |
+
gr.HTML('<div class="form-label">Monitoring Settings</div>')
|
|
|
|
| 612 |
auto_refresh_status_cb = gr.Checkbox(
|
| 613 |
+
label="Auto-refresh status (5s interval)",
|
| 614 |
value=False
|
| 615 |
)
|
| 616 |
auto_refresh_logs_cb = gr.Checkbox(
|
| 617 |
+
label="Auto-refresh logs (10s interval)",
|
| 618 |
value=False
|
| 619 |
)
|
| 620 |
|
| 621 |
+
# System Metrics
|
| 622 |
+
with gr.Group(elem_classes=["monitoring-panel"]):
|
| 623 |
+
gr.HTML('<div class="panel-header">π Performance Metrics</div>')
|
| 624 |
+
gr.HTML('''
|
| 625 |
+
<div style="padding: 16px;">
|
| 626 |
+
<div class="metric-card">
|
| 627 |
+
<div class="metric-value">--</div>
|
| 628 |
+
<div class="metric-label">CPU Usage</div>
|
| 629 |
</div>
|
| 630 |
+
<div class="metric-card">
|
| 631 |
+
<div class="metric-value">--</div>
|
| 632 |
+
<div class="metric-label">Memory</div>
|
| 633 |
</div>
|
| 634 |
+
<div class="metric-card">
|
| 635 |
+
<div class="metric-value">--</div>
|
| 636 |
+
<div class="metric-label">Uptime</div>
|
| 637 |
</div>
|
| 638 |
+
</div>
|
| 639 |
+
''')
|
| 640 |
|
| 641 |
+
# System Logs
|
| 642 |
+
with gr.Group(elem_classes=["enterprise-container"]):
|
| 643 |
+
gr.HTML('<div class="container-header">π System Logs</div>')
|
| 644 |
+
with gr.Group(elem_classes=["container-content"]):
|
| 645 |
with gr.Row():
|
| 646 |
+
fetch_logs_btn = gr.Button("Fetch Application Logs", elem_classes=["btn-secondary"])
|
| 647 |
gr.HTML('<div style="flex-grow: 1;"></div>')
|
| 648 |
|
| 649 |
+
gr.HTML('<div class="form-label mt-4">Runtime Logs</div>')
|
| 650 |
logs_display = gr.Textbox(
|
| 651 |
+
lines=14,
|
| 652 |
interactive=False,
|
| 653 |
+
elem_classes=["terminal-logs"],
|
| 654 |
+
placeholder="[SYSTEM] Application logs will be displayed here...\n[INFO] Logs are captured in real-time from your running application\n[DEBUG] Use 'Fetch Application Logs' to retrieve the latest output",
|
| 655 |
show_label=False
|
| 656 |
)
|
| 657 |
|
|
|
|
| 716 |
outputs=[logs_timer]
|
| 717 |
)
|
| 718 |
|
| 719 |
+
# Professional Footer
|
| 720 |
gr.HTML("""
|
| 721 |
+
<div style="text-align: center; margin-top: 40px; padding: 24px; background: linear-gradient(to right, #f8fafc, #f1f5f9); border-top: 1px solid #e2e8f0; color: #64748b; font-size: 13px;">
|
| 722 |
+
<p style="font-weight: 500; margin-bottom: 8px;">Sandbox Compute Platform</p>
|
| 723 |
+
<p style="font-size: 12px; margin-top: 12px; opacity: 0.8;">
|
| 724 |
+
Runtime Engines: SANDBOXBACKEND2, SANDBOX_BACKEND
|
| 725 |
+
</p>
|
| 726 |
</div>
|
| 727 |
""")
|
| 728 |
|