sayakpaul HF Staff commited on
Commit
3625a6b
·
1 Parent(s): f61fb8b
Files changed (2) hide show
  1. app.py +2 -6
  2. hub_utils.py +2 -2
app.py CHANGED
@@ -30,17 +30,13 @@ def push_to_hub(repo_id, filename, oauth_token: gr.OAuthToken):
30
  start = time.perf_counter()
31
  compiled_transformer = compile_transformer(pipe, prompt="prompt")
32
  end = time.perf_counter()
33
- print(f"Compilation took: {start - end} seconds.")
34
 
35
  token = oauth_token.token
36
  out = _push_compiled_graph_to_hub(
37
  compiled_transformer.archive_file, repo_id=repo_id, token=token, path_in_repo=filename
38
  )
39
- if not isinstance(out, str) and hasattr(out, "commit_url"):
40
- commit_url = out.commit_url
41
- return f"[{commit_url}]({commit_url})"
42
- else:
43
- return out
44
  except Exception as e:
45
  raise gr.Error(
46
  f"""Oops, you forgot to login. Please use the loggin button on the top left to migrate your repo {e}"""
 
30
  start = time.perf_counter()
31
  compiled_transformer = compile_transformer(pipe, prompt="prompt")
32
  end = time.perf_counter()
33
+ print(f"Compilation took: {end - start} seconds.")
34
 
35
  token = oauth_token.token
36
  out = _push_compiled_graph_to_hub(
37
  compiled_transformer.archive_file, repo_id=repo_id, token=token, path_in_repo=filename
38
  )
39
+ return out
 
 
 
 
40
  except Exception as e:
41
  raise gr.Error(
42
  f"""Oops, you forgot to login. Please use the loggin button on the top left to migrate your repo {e}"""
hub_utils.py CHANGED
@@ -6,7 +6,7 @@ import os
6
  DEFAULT_ARCHIVE_FILENAME = "archived_graph.pt2"
7
 
8
 
9
- def _push_compiled_graph_to_hub(archive: BytesIO, repo_id, **kwargs):
10
  if not isinstance(archive, BytesIO):
11
  raise NotImplementedError("Incorrect type of `archive` provided.")
12
 
@@ -29,7 +29,7 @@ def _push_compiled_graph_to_hub(archive: BytesIO, repo_id, **kwargs):
29
  commit_message=commit_message,
30
  token=token,
31
  )
32
- return info
33
  except Exception as e:
34
  print(f"File couldn't be pushed to the Hub with the following error: {e}.")
35
  return e
 
6
  DEFAULT_ARCHIVE_FILENAME = "archived_graph.pt2"
7
 
8
 
9
+ def _push_compiled_graph_to_hub(archive: BytesIO, repo_id, **kwargs) -> str:
10
  if not isinstance(archive, BytesIO):
11
  raise NotImplementedError("Incorrect type of `archive` provided.")
12
 
 
29
  commit_message=commit_message,
30
  token=token,
31
  )
32
+ return info.commit_url
33
  except Exception as e:
34
  print(f"File couldn't be pushed to the Hub with the following error: {e}.")
35
  return e