Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import docker
|
|
| 9 |
from huggingface_hub import HfApi, create_repo
|
| 10 |
import importlib
|
| 11 |
import os
|
|
|
|
| 12 |
|
| 13 |
hf_api = HfApi()
|
| 14 |
|
|
@@ -287,16 +288,16 @@ def run_docker_container(image_name, port):
|
|
| 287 |
container = client.containers.run(image_name, detach=True, ports={f'{port}/tcp': port})
|
| 288 |
return container
|
| 289 |
|
| 290 |
-
def
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
|
| 301 |
if __name__ == "__main__":
|
| 302 |
db.create_all() # Create the database tables if they don't exist
|
|
|
|
| 9 |
from huggingface_hub import HfApi, create_repo
|
| 10 |
import importlib
|
| 11 |
import os
|
| 12 |
+
from huggingface_hub import HfApi, create_repo
|
| 13 |
|
| 14 |
hf_api = HfApi()
|
| 15 |
|
|
|
|
| 288 |
container = client.containers.run(image_name, detach=True, ports={f'{port}/tcp': port})
|
| 289 |
return container
|
| 290 |
|
| 291 |
+
def deploy_space_to_hf(project_name, hf_token):
|
| 292 |
+
repository_name = f"my-awesome-space_{datetime.now().timestamp()}"
|
| 293 |
+
files = get_built_space_files()
|
| 294 |
+
commit_response = deploy_to_git(project_name, repository_name, files)
|
| 295 |
+
if commit_response:
|
| 296 |
+
api = HfApi(token=hf_token) # Corrected import statement
|
| 297 |
+
api.create(repository_name, files=files, push_to_hub=True)
|
| 298 |
+
return f"Space '{repository_name}' deployed successfully."
|
| 299 |
+
else:
|
| 300 |
+
return "Failed to commit changes to Space."
|
| 301 |
|
| 302 |
if __name__ == "__main__":
|
| 303 |
db.create_all() # Create the database tables if they don't exist
|