apple muncy commited on
Commit
bb8fbdc
·
1 Parent(s): cfe943a

add logging

Browse files

Signed-off-by: apple muncy <[email protected]>

Files changed (2) hide show
  1. mcp_server.py +13 -1
  2. tag.log +0 -0
mcp_server.py CHANGED
@@ -10,6 +10,16 @@ from huggingface_hub import HfApi, model_info, ModelCard, ModelCardData
10
  from huggingface_hub.utils import HfHubHTTPError
11
  from dotenv import load_dotenv
12
 
 
 
 
 
 
 
 
 
 
 
13
  load_dotenv()
14
 
15
  # Configuration
@@ -26,7 +36,7 @@ mcp = FastMCP("hf-tagging-bot")
26
  def get_current_tags(repo_id: str) -> str:
27
  """Get current tags from a HuggingFace model repository"""
28
  print(f"🔧 get_current_tags called with repo_id: {repo_id}")
29
-
30
  if not hf_api:
31
  error_result = {"error": "HF token not configured"}
32
  json_str = json.dumps(error_result)
@@ -35,6 +45,7 @@ def get_current_tags(repo_id: str) -> str:
35
 
36
  try:
37
  print(f"📡 Fetching model info for: {repo_id}")
 
38
  info = model_info(repo_id=repo_id, token=HF_TOKEN)
39
  current_tags = info.tags if info.tags else []
40
  print(f"🏷️ Found {len(current_tags)} tags: {current_tags}")
@@ -181,4 +192,5 @@ This PR adds the `{new_tag}` tag to the model repository.
181
 
182
 
183
  if __name__ == "__main__":
 
184
  mcp.run()
 
10
  from huggingface_hub.utils import HfHubHTTPError
11
  from dotenv import load_dotenv
12
 
13
+ #adding logger
14
+ import logging
15
+ logger = logging.getLogger(__name__)
16
+ logging.basicConfig(filename='tag.log', encoding='utf-8', level=logging.DEBUG)
17
+ #for testing logger
18
+ logger.debug('This message should go to the log file')
19
+ logger.info('So should this')
20
+ logger.warning('And this, too')
21
+ logger.error('And non-ASCII stuff, too, like Øresund and Malmö')
22
+
23
  load_dotenv()
24
 
25
  # Configuration
 
36
  def get_current_tags(repo_id: str) -> str:
37
  """Get current tags from a HuggingFace model repository"""
38
  print(f"🔧 get_current_tags called with repo_id: {repo_id}")
39
+ logger.info('🔧 get_current_tags called with repo_id %s', {repo_id})
40
  if not hf_api:
41
  error_result = {"error": "HF token not configured"}
42
  json_str = json.dumps(error_result)
 
45
 
46
  try:
47
  print(f"📡 Fetching model info for: {repo_id}")
48
+ logger.info('📡 Fetching model info for: %', {repo_id})
49
  info = model_info(repo_id=repo_id, token=HF_TOKEN)
50
  current_tags = info.tags if info.tags else []
51
  print(f"🏷️ Found {len(current_tags)} tags: {current_tags}")
 
192
 
193
 
194
  if __name__ == "__main__":
195
+ logger.info('main')
196
  mcp.run()
tag.log ADDED
File without changes