mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Bug Fix: Update hub.py to fix NoneType error (#33315)
* Bug Fix: Update hub.py Bug: TypeError: argument of type 'NoneType' is not iterable Analysis: The error `TypeError: argument of type 'NoneType' is not iterable` suggests that `model_card.data.tags` is `None`, and the code is trying to iterate through it using `not in`. Fix: 1. **Check if `model_card.data.tags` is `None` before the loop**: Since you're checking the variable `tags` before the loop, you should also ensure that `model_card.data.tags` is not `None`. You can do this by initializing `model_card.data.tags` to an empty list if it's `None`. 2. **Updated code**: Add a check and initialize the `tags` if it is `None` before proceeding with the iteration. This way, if `model_card.data.tags` is `None`, it gets converted to an empty list before checking the contents. This prevents the `TypeError`. * Update hub.py
This commit is contained in:
parent
96429e74a8
commit
6ed2b10942
@ -1198,6 +1198,9 @@ def create_and_tag_model_card(
|
||||
model_card = ModelCard.from_template(card_data, model_description=model_description)
|
||||
|
||||
if tags is not None:
|
||||
# Ensure model_card.data.tags is a list and not None
|
||||
if model_card.data.tags is None:
|
||||
model_card.data.tags = []
|
||||
for model_tag in tags:
|
||||
if model_tag not in model_card.data.tags:
|
||||
model_card.data.tags.append(model_tag)
|
||||
|
Loading…
Reference in New Issue
Block a user