Spaces:
Running
Running
WIP - HuggingFace launcher
Browse files- backend +1 -1
- huggingface_overlay/start_HuggingFace.py +35 -18
backend
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
Subproject commit
|
|
|
|
| 1 |
+
Subproject commit 868a3f7c85cdc522b43315d946b0c32686cf3712
|
huggingface_overlay/start_HuggingFace.py
CHANGED
|
@@ -12,12 +12,12 @@ root_data_dir: str = "./data/"
|
|
| 12 |
root_data_dir_path = pathlib.Path(root_data_dir).resolve()
|
| 13 |
print(f"{root_data_dir_path=}")
|
| 14 |
|
| 15 |
-
artifacts_dir_path = root_data_dir_path / "artifacts"
|
| 16 |
-
logs_dir_path = root_data_dir_path / "logs"
|
| 17 |
|
| 18 |
root_data_dir_path.mkdir(parents=True, exist_ok=True)
|
| 19 |
-
artifacts_dir_path.mkdir(parents=True, exist_ok=True)
|
| 20 |
-
logs_dir_path.mkdir(parents=True, exist_ok=True)
|
| 21 |
# endregion
|
| 22 |
|
| 23 |
# region: DB Configuration
|
|
@@ -27,12 +27,16 @@ print(f"{database_uri=}")
|
|
| 27 |
# endregion
|
| 28 |
|
| 29 |
# region: Storage configuration
|
| 30 |
-
from cloud_pipelines.orchestration.storage_providers import local_storage
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
storage_provider =
|
| 33 |
|
| 34 |
-
artifacts_root_uri = artifacts_dir_path.as_posix()
|
| 35 |
-
logs_root_uri = logs_dir_path.as_posix()
|
|
|
|
|
|
|
| 36 |
# endregion
|
| 37 |
|
| 38 |
# region: Launcher configuration
|
|
@@ -46,6 +50,22 @@ logs_root_uri = logs_dir_path.as_posix()
|
|
| 46 |
# client=docker_client,
|
| 47 |
# )
|
| 48 |
launcher = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# endregion
|
| 50 |
|
| 51 |
# region: Orchestrator configuration
|
|
@@ -124,9 +144,9 @@ logger = logging.getLogger(__name__)
|
|
| 124 |
# endregion
|
| 125 |
|
| 126 |
# region: Database engine initialization
|
| 127 |
-
from cloud_pipelines_backend import
|
| 128 |
|
| 129 |
-
db_engine =
|
| 130 |
database_uri=database_uri,
|
| 131 |
)
|
| 132 |
# endregion
|
|
@@ -146,12 +166,6 @@ from cloud_pipelines.orchestration.storage_providers import (
|
|
| 146 |
from cloud_pipelines_backend import orchestrator_sql
|
| 147 |
|
| 148 |
|
| 149 |
-
def create_db_and_tables(db_engine: sqlalchemy.Engine):
|
| 150 |
-
from cloud_pipelines_backend import backend_types_sql
|
| 151 |
-
|
| 152 |
-
backend_types_sql._TableBase.metadata.create_all(db_engine)
|
| 153 |
-
|
| 154 |
-
|
| 155 |
def run_orchestrator(
|
| 156 |
db_engine: sqlalchemy.Engine,
|
| 157 |
storage_provider: storage_interfaces.StorageProvider,
|
|
@@ -211,11 +225,12 @@ import fastapi
|
|
| 211 |
from fastapi import staticfiles
|
| 212 |
|
| 213 |
from cloud_pipelines_backend import api_router
|
|
|
|
| 214 |
|
| 215 |
|
| 216 |
@contextlib.asynccontextmanager
|
| 217 |
async def lifespan(app: fastapi.FastAPI):
|
| 218 |
-
|
| 219 |
threading.Thread(
|
| 220 |
target=run_configured_orchestrator,
|
| 221 |
daemon=True,
|
|
@@ -267,7 +282,9 @@ found_frontend_build_files = False
|
|
| 267 |
for web_app_dir in web_app_search_dirs:
|
| 268 |
if web_app_dir.exists():
|
| 269 |
found_frontend_build_files = True
|
| 270 |
-
logger.info(
|
|
|
|
|
|
|
| 271 |
# The Web app base URL is currently static and hardcoded.
|
| 272 |
# TODO: Remove this mount once the base URL becomes relative.
|
| 273 |
app.mount(
|
|
|
|
| 12 |
root_data_dir_path = pathlib.Path(root_data_dir).resolve()
|
| 13 |
print(f"{root_data_dir_path=}")
|
| 14 |
|
| 15 |
+
# artifacts_dir_path = root_data_dir_path / "artifacts"
|
| 16 |
+
# logs_dir_path = root_data_dir_path / "logs"
|
| 17 |
|
| 18 |
root_data_dir_path.mkdir(parents=True, exist_ok=True)
|
| 19 |
+
# artifacts_dir_path.mkdir(parents=True, exist_ok=True)
|
| 20 |
+
# logs_dir_path.mkdir(parents=True, exist_ok=True)
|
| 21 |
# endregion
|
| 22 |
|
| 23 |
# region: DB Configuration
|
|
|
|
| 27 |
# endregion
|
| 28 |
|
| 29 |
# region: Storage configuration
|
| 30 |
+
# from cloud_pipelines.orchestration.storage_providers import local_storage
|
| 31 |
+
# storage_provider = local_storage.LocalStorageProvider()
|
| 32 |
+
from cloud_pipelines_backend.storage_providers import huggingface_repo_storage
|
| 33 |
|
| 34 |
+
storage_provider = huggingface_repo_storage.HuggingFaceRepoStorageProvider()
|
| 35 |
|
| 36 |
+
# artifacts_root_uri = artifacts_dir_path.as_posix()
|
| 37 |
+
# logs_root_uri = logs_dir_path.as_posix()
|
| 38 |
+
artifacts_root_uri = os.environ.get("DATA_DIR_URI")
|
| 39 |
+
logs_root_uri = artifacts_root_uri
|
| 40 |
# endregion
|
| 41 |
|
| 42 |
# region: Launcher configuration
|
|
|
|
| 50 |
# client=docker_client,
|
| 51 |
# )
|
| 52 |
launcher = None
|
| 53 |
+
try:
|
| 54 |
+
from cloud_pipelines_backend.launchers import huggingface_launchers
|
| 55 |
+
|
| 56 |
+
launcher = huggingface_launchers.HuggingFaceJobsContainerLauncher()
|
| 57 |
+
except Exception as ex:
|
| 58 |
+
print(ex)
|
| 59 |
+
pass
|
| 60 |
+
|
| 61 |
+
try:
|
| 62 |
+
import huggingface_hub
|
| 63 |
+
|
| 64 |
+
huggingface_hub.list_repo_tree(repo_id="Ark-kun/tangle_data", repo_type="dataset")
|
| 65 |
+
except Exception as ex:
|
| 66 |
+
print(ex)
|
| 67 |
+
pass
|
| 68 |
+
|
| 69 |
# endregion
|
| 70 |
|
| 71 |
# region: Orchestrator configuration
|
|
|
|
| 144 |
# endregion
|
| 145 |
|
| 146 |
# region: Database engine initialization
|
| 147 |
+
from cloud_pipelines_backend import database_ops
|
| 148 |
|
| 149 |
+
db_engine = database_ops.create_db_engine(
|
| 150 |
database_uri=database_uri,
|
| 151 |
)
|
| 152 |
# endregion
|
|
|
|
| 166 |
from cloud_pipelines_backend import orchestrator_sql
|
| 167 |
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
def run_orchestrator(
|
| 170 |
db_engine: sqlalchemy.Engine,
|
| 171 |
storage_provider: storage_interfaces.StorageProvider,
|
|
|
|
| 225 |
from fastapi import staticfiles
|
| 226 |
|
| 227 |
from cloud_pipelines_backend import api_router
|
| 228 |
+
from cloud_pipelines_backend import database_ops
|
| 229 |
|
| 230 |
|
| 231 |
@contextlib.asynccontextmanager
|
| 232 |
async def lifespan(app: fastapi.FastAPI):
|
| 233 |
+
database_ops.initialize_and_migrate_db(db_engine=db_engine)
|
| 234 |
threading.Thread(
|
| 235 |
target=run_configured_orchestrator,
|
| 236 |
daemon=True,
|
|
|
|
| 282 |
for web_app_dir in web_app_search_dirs:
|
| 283 |
if web_app_dir.exists():
|
| 284 |
found_frontend_build_files = True
|
| 285 |
+
logger.info(
|
| 286 |
+
f"Found the Web app static files at {str(web_app_dir)}. Mounting them."
|
| 287 |
+
)
|
| 288 |
# The Web app base URL is currently static and hardcoded.
|
| 289 |
# TODO: Remove this mount once the base URL becomes relative.
|
| 290 |
app.mount(
|