File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import sys
66from pathlib import Path
77
8- # Add project root to path for imports
8+ # Add project root to path for local development
99sys .path .insert (0 , str (Path (__file__ ).parent .parent .parent ))
1010
1111import gradio as gr
12- from apps .shared .custom_components import AppBase
13- from config .settings import LOCAL_PORTS
12+
13+ # Support both local (apps.shared) and HF Spaces (shared) imports
14+ try :
15+ from apps .shared .custom_components import AppBase
16+ from config .settings import LOCAL_PORTS
17+ except ImportError :
18+ from shared .custom_components import AppBase
19+ from config .settings import LOCAL_PORTS
1420
1521
1622class AnalyticsApp (AppBase ):
Original file line number Diff line number Diff line change 55import sys
66from pathlib import Path
77
8- # Add project root to path for imports
8+ # Add project root to path for local development
99sys .path .insert (0 , str (Path (__file__ ).parent .parent .parent ))
1010
1111import gradio as gr
12- from apps .shared .custom_components import AppBase
13- from config .settings import LOCAL_PORTS
12+
13+ # Support both local (apps.shared) and HF Spaces (shared) imports
14+ try :
15+ from apps .shared .custom_components import AppBase
16+ from config .settings import LOCAL_PORTS
17+ except ImportError :
18+ from shared .custom_components import AppBase
19+ from config .settings import LOCAL_PORTS
1420
1521
1622class DashboardApp (AppBase ):
Original file line number Diff line number Diff line change 99
1010from abc import ABC , abstractmethod
1111import gradio as gr
12- from config .app_registry import get_app_info
13- from apps .shared .ui_components import header , footer , navigation
12+
13+ # Support both local and HF Spaces imports
14+ try :
15+ from config .app_registry import get_app_info
16+ from apps .shared .ui_components import header , footer , navigation
17+ except ImportError :
18+ from config .app_registry import get_app_info
19+ from shared .ui_components import header , footer , navigation
1420
1521
1622class AppBase (ABC ):
Original file line number Diff line number Diff line change 55"""
66
77import gradio as gr
8- from config .app_registry import APPS_REGISTRY , get_app_info , get_all_apps
9- from config .settings import get_app_url
8+
9+ # Support both local and HF Spaces imports
10+ try :
11+ from config .app_registry import APPS_REGISTRY , get_app_info , get_all_apps
12+ from config .settings import get_app_url
13+ except ImportError :
14+ # When running on HF Spaces, config is at root level
15+ import sys
16+ sys .path .insert (0 , "/app" )
17+ from config .app_registry import APPS_REGISTRY , get_app_info , get_all_apps
18+ from config .settings import get_app_url
1019
1120
1221def header (title : str , subtitle : str | None = None ) -> gr .Markdown :
You can’t perform that action at this time.
0 commit comments