Update build_logic.py
Browse files- build_logic.py +1 -29
build_logic.py
CHANGED
@@ -848,35 +848,7 @@ def build_logic_add_comment(hf_api_key, repo_id, comment_text):
|
|
848 |
|
849 |
def build_logic_like_space(hf_api_key, repo_id):
|
850 |
logger.info(f"Attempting to like space '{repo_id}'.")
|
851 |
-
|
852 |
-
token, err = _get_api_token(hf_api_key)
|
853 |
-
if err or not token:
|
854 |
-
logger.error(f"Token error liking space: {err or 'Token not found'}")
|
855 |
-
return f"Error getting token: {err or 'Token not found.'}"
|
856 |
-
|
857 |
-
# Use the new public API method like
|
858 |
-
hf_like(
|
859 |
-
repo_id=repo_id,
|
860 |
-
token=token,
|
861 |
-
timeout=10
|
862 |
-
)
|
863 |
-
|
864 |
-
logger.info(f"Successfully liked space: {repo_id}")
|
865 |
-
return f"Successfully liked space: `{repo_id}`."
|
866 |
-
|
867 |
-
except HfHubHTTPError as e_http:
|
868 |
-
logger.error(f"HTTP error liking space {repo_id}: {e_http}")
|
869 |
-
status_code = e_http.response.status_code if e_http.response else 'N/A'
|
870 |
-
if status_code == 409:
|
871 |
-
return f"Like Error ({status_code}): Space '{repo_id}' already liked."
|
872 |
-
if status_code in (401, 403):
|
873 |
-
return f"Like Error ({status_code}): Access denied or authentication required to like '{repo_id}'. Check token permissions."
|
874 |
-
if status_code == 404:
|
875 |
-
return f"Like Error ({status_code}): Space '{repo_id}' not found."
|
876 |
-
return f"Like HTTP Error ({status_code}): {e_http.response.text if e_http.response else str(e_http)}"
|
877 |
-
except Exception as e:
|
878 |
-
logger.exception(f"Error liking space {repo_id}:")
|
879 |
-
return f"Like Error: {e}"
|
880 |
|
881 |
|
882 |
def duplicate_space(hf_api_key, source_repo_id, target_repo_id, private: bool = False):
|
|
|
848 |
|
849 |
def build_logic_like_space(hf_api_key, repo_id):
|
850 |
logger.info(f"Attempting to like space '{repo_id}'.")
|
851 |
+
return "'Like system' not installed."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
|
853 |
|
854 |
def duplicate_space(hf_api_key, source_repo_id, target_repo_id, private: bool = False):
|