omerXfaruq commited on
Commit
41930b6
1 Parent(s): 8805249

- refactor documentation

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -138,25 +138,25 @@ class SpaceBuilder:
138
  return True
139
 
140
  @classmethod
141
- def create_space(cls, names: str, space_name: str, hf_token: str, title: str, description: str) -> bool:
142
  """
143
- Creates the space.
144
 
145
- :param names: Input space name_list
146
- :param space_name: Target space_name
147
  :param hf_token: HuggingFace Write Token
148
  :param title: Target Interface Title
149
  :param description: Target Interface Description
150
  :return: True if success
151
  """
152
- name_list = cls.split_space_names(names)
153
  try:
154
- create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
155
  except Exception as ex:
156
  print(ex)
157
  cls.error_message = "Please provide a correct space name as Only regular characters and '-', '_', '.' accepted. '--' and '..' are forbidden. '-' and '.' cannot start or end the name."
158
  return False
159
- repo_name = get_full_repo_name(model_id=space_name, token=hf_token)
160
 
161
  try:
162
  file_string = cls.file_as_a_string(name_list, title, description)
@@ -213,9 +213,7 @@ class SpaceBuilder:
213
  return SpaceBuilder.error_message
214
  if not SpaceBuilder.load_and_check_spaces(names=space_names):
215
  return SpaceBuilder.error_message
216
- if not SpaceBuilder.create_space(
217
- names=space_names, space_name=target_space_name, hf_token=hf_token, title=interface_title, description=interface_description
218
- ):
219
  return SpaceBuilder.error_message
220
 
221
  return SpaceBuilder.url
 
138
  return True
139
 
140
  @classmethod
141
+ def create_space(cls, input_space_names: str, target_space_name: str, hf_token: str, title: str, description: str) -> bool:
142
  """
143
+ Creates the target space with the given space names.
144
 
145
+ :param input_space_names: Input space name_list
146
+ :param target_space_name: Target space_name
147
  :param hf_token: HuggingFace Write Token
148
  :param title: Target Interface Title
149
  :param description: Target Interface Description
150
  :return: True if success
151
  """
152
+ name_list = cls.split_space_names(input_space_names)
153
  try:
154
+ create_repo(name=target_space_name, token=hf_token, repo_type="space", space_sdk="gradio")
155
  except Exception as ex:
156
  print(ex)
157
  cls.error_message = "Please provide a correct space name as Only regular characters and '-', '_', '.' accepted. '--' and '..' are forbidden. '-' and '.' cannot start or end the name."
158
  return False
159
+ repo_name = get_full_repo_name(model_id=target_space_name, token=hf_token)
160
 
161
  try:
162
  file_string = cls.file_as_a_string(name_list, title, description)
 
213
  return SpaceBuilder.error_message
214
  if not SpaceBuilder.load_and_check_spaces(names=space_names):
215
  return SpaceBuilder.error_message
216
+ if not SpaceBuilder.create_space(input_space_names=space_names, target_space_name=target_space_name, hf_token=hf_token, title=interface_title, description=interface_description):
 
 
217
  return SpaceBuilder.error_message
218
 
219
  return SpaceBuilder.url