htahir1 commited on
Commit
da5e80d
β€’
1 Parent(s): a6e15cd

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: πŸ¦€
5
  colorFrom: purple
6
  colorTo: purple
7
  sdk: gradio
8
- sdk_version: 3.1.7
9
  app_file: app.py
10
  pinned: false
11
  license: apache-2.0
 
5
  colorFrom: purple
6
  colorTo: purple
7
  sdk: gradio
8
+ sdk_version: 3.50.2
9
  app_file: app.py
10
  pinned: false
11
  license: apache-2.0
steps/__pycache__/deploy_to_huggingface.cpython-38.pyc CHANGED
Binary files a/steps/__pycache__/deploy_to_huggingface.cpython-38.pyc and b/steps/__pycache__/deploy_to_huggingface.cpython-38.pyc differ
 
steps/deploy_to_huggingface.py CHANGED
@@ -15,11 +15,10 @@
15
  # limitations under the License.
16
  #
17
 
18
- import os
19
- from typing import Optional, List
20
  from huggingface_hub import create_branch, login, HfApi
21
 
22
- from zenml import step
23
  from zenml.client import Client
24
  from zenml.logger import get_logger
25
 
@@ -30,7 +29,7 @@ logger = get_logger(__name__)
30
  @step(enable_cache=False)
31
  def deploy_to_huggingface(
32
  repo_name: str,
33
- ):
34
  """
35
  This step deploy the model to huggingface.
36
 
@@ -51,8 +50,20 @@ def deploy_to_huggingface(
51
  "this step will not work outside of a ZenML repo where the gradio folder is present."
52
  )
53
  raise
54
- space = api.upload_folder(
55
  folder_path=zenml_repo_root, repo_id=hf_repo.repo_id, repo_type="space",
56
  )
57
- logger.info(f"Space created: {space}")
 
 
 
 
 
 
 
 
 
 
 
58
  ### YOUR CODE ENDS HERE ###
 
 
15
  # limitations under the License.
16
  #
17
 
18
+ from typing_extensions import Annotated
 
19
  from huggingface_hub import create_branch, login, HfApi
20
 
21
+ from zenml import step, log_artifact_metadata
22
  from zenml.client import Client
23
  from zenml.logger import get_logger
24
 
 
29
  @step(enable_cache=False)
30
  def deploy_to_huggingface(
31
  repo_name: str,
32
+ ) -> Annotated[str, "huggingface_url"]:
33
  """
34
  This step deploy the model to huggingface.
35
 
 
50
  "this step will not work outside of a ZenML repo where the gradio folder is present."
51
  )
52
  raise
53
+ url = api.upload_folder(
54
  folder_path=zenml_repo_root, repo_id=hf_repo.repo_id, repo_type="space",
55
  )
56
+ repo_commits = api.list_repo_commits(
57
+ repo_id=hf_repo.repo_id,
58
+ repo_type="model",
59
+ )
60
+ log_artifact_metadata(
61
+ artifact_name="huggingface_url",
62
+ metadata={
63
+ "repo_id": hf_repo.repo_id,
64
+ "revision": repo_commits[0].commit_id,
65
+ },
66
+ )
67
+ logger.info(f"Model updated: {url}")
68
  ### YOUR CODE ENDS HERE ###
69
+ return url