Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -33,13 +33,21 @@ logger = logging.getLogger(__name__)
|
|
| 33 |
# CONFIGURATION
|
| 34 |
# ============================================================================
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
MODELS_DIR.mkdir(exist_ok=True)
|
| 38 |
|
| 39 |
-
DATASETS_DIR =
|
| 40 |
DATASETS_DIR.mkdir(exist_ok=True)
|
| 41 |
|
| 42 |
-
NOTEBOOKS_DIR =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# Model types available for training
|
| 45 |
MODEL_TYPES = {
|
|
@@ -108,20 +116,22 @@ def execute_notebook(notebook_name: str, progress=gr.Progress()) -> Tuple[str, s
|
|
| 108 |
output_path = NOTEBOOKS_DIR / f"output_{notebook_name}"
|
| 109 |
|
| 110 |
if not notebook_path.exists():
|
| 111 |
-
|
|
|
|
|
|
|
| 112 |
|
| 113 |
progress(0.1, desc="Starting notebook execution...")
|
| 114 |
|
| 115 |
try:
|
| 116 |
-
# Execute notebook using nbconvert
|
| 117 |
cmd = [
|
| 118 |
sys.executable, "-m", "nbconvert",
|
| 119 |
"--to", "notebook",
|
| 120 |
"--execute",
|
| 121 |
-
"--output", str(output_path.
|
| 122 |
"--ExecutePreprocessor.timeout=600",
|
| 123 |
"--ExecutePreprocessor.kernel_name=python3",
|
| 124 |
-
str(notebook_path)
|
| 125 |
]
|
| 126 |
|
| 127 |
progress(0.3, desc="Executing cells...")
|
|
|
|
| 33 |
# CONFIGURATION
|
| 34 |
# ============================================================================
|
| 35 |
|
| 36 |
+
# Get the directory where app.py is located
|
| 37 |
+
APP_DIR = Path(__file__).parent.absolute()
|
| 38 |
+
|
| 39 |
+
MODELS_DIR = APP_DIR / "trained_models"
|
| 40 |
MODELS_DIR.mkdir(exist_ok=True)
|
| 41 |
|
| 42 |
+
DATASETS_DIR = APP_DIR / "datasets"
|
| 43 |
DATASETS_DIR.mkdir(exist_ok=True)
|
| 44 |
|
| 45 |
+
NOTEBOOKS_DIR = APP_DIR / "notebooks"
|
| 46 |
+
|
| 47 |
+
# Log paths for debugging
|
| 48 |
+
logger.info(f"APP_DIR: {APP_DIR}")
|
| 49 |
+
logger.info(f"NOTEBOOKS_DIR: {NOTEBOOKS_DIR}")
|
| 50 |
+
logger.info(f"NOTEBOOKS_DIR exists: {NOTEBOOKS_DIR.exists()}")
|
| 51 |
|
| 52 |
# Model types available for training
|
| 53 |
MODEL_TYPES = {
|
|
|
|
| 116 |
output_path = NOTEBOOKS_DIR / f"output_{notebook_name}"
|
| 117 |
|
| 118 |
if not notebook_path.exists():
|
| 119 |
+
# Debug: list what's actually in the directory
|
| 120 |
+
available = list(NOTEBOOKS_DIR.glob("*.ipynb")) if NOTEBOOKS_DIR.exists() else []
|
| 121 |
+
return f"Error: Notebook not found: {notebook_path}\nAvailable: {available}\nDir exists: {NOTEBOOKS_DIR.exists()}", ""
|
| 122 |
|
| 123 |
progress(0.1, desc="Starting notebook execution...")
|
| 124 |
|
| 125 |
try:
|
| 126 |
+
# Execute notebook using nbconvert with absolute paths
|
| 127 |
cmd = [
|
| 128 |
sys.executable, "-m", "nbconvert",
|
| 129 |
"--to", "notebook",
|
| 130 |
"--execute",
|
| 131 |
+
"--output", str(output_path.absolute()),
|
| 132 |
"--ExecutePreprocessor.timeout=600",
|
| 133 |
"--ExecutePreprocessor.kernel_name=python3",
|
| 134 |
+
str(notebook_path.absolute())
|
| 135 |
]
|
| 136 |
|
| 137 |
progress(0.3, desc="Executing cells...")
|