|
|
@ -56,13 +56,13 @@ def has_hf_hub(necessary=False):
|
|
|
|
if hf_hub_url is None and necessary:
|
|
|
|
if hf_hub_url is None and necessary:
|
|
|
|
# if no HF Hub module installed and it is necessary to continue, raise error
|
|
|
|
# if no HF Hub module installed and it is necessary to continue, raise error
|
|
|
|
raise RuntimeError(
|
|
|
|
raise RuntimeError(
|
|
|
|
'HuggignFace Hub model specified but package not installed. Run `pip install huggingface_hub`.')
|
|
|
|
'Hugging Face hub model specified but package not installed. Run `pip install huggingface_hub`.')
|
|
|
|
return hf_hub_url is not None
|
|
|
|
return hf_hub_url is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def hf_split(hf_id):
|
|
|
|
def hf_split(hf_id):
|
|
|
|
rev_split = hf_id.split('#')
|
|
|
|
rev_split = hf_id.split('#')
|
|
|
|
assert 0 < len(rev_split) <= 2, 'HuggingFace HUB identifier should only contain on # character to identify revision.'
|
|
|
|
assert 0 < len(rev_split) <= 2, 'hf_hub id should only contain one # character to identify revision.'
|
|
|
|
hf_model_id = rev_split[0]
|
|
|
|
hf_model_id = rev_split[0]
|
|
|
|
hf_revision = rev_split[-1] if len(rev_split) > 1 else None
|
|
|
|
hf_revision = rev_split[-1] if len(rev_split) > 1 else None
|
|
|
|
return hf_model_id, hf_revision
|
|
|
|
return hf_model_id, hf_revision
|
|
|
|