Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve hf hub push test #35

Merged
merged 1 commit into from
Jan 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions tests/test_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ def run(cmd):
def test_detection_upload():
import platform
from packaging.version import Version
from huggingface_hub.utils._errors import HfHubHTTPError

# run following lines if linux and python major == 3 and python minor == 10 (python micor can be anything)
print(f'platform.system(): {platform.system()}')
print(f'platform.python_version(): {platform.python_version()}')
print(f'os.getenv("RUNNER_OS"): {os.getenv("RUNNER_OS")}')
print(f'Version(platform.python_version()) >= Version("3.10"): {Version(platform.python_version()) >= Version("3.10")}')
if platform.system() == 'Linux' and Version(platform.python_version()) >= Version("3.10"):
print('training started')
run('yolo train detect model=yolov8n.pt data=coco8.yaml imgsz=32 epochs=1')
Expand All @@ -83,12 +80,16 @@ def test_detection_upload():
if hf_token is None:
raise ValueError('Please set HF_TOKEN environment variable to your HuggingFace token.')
print('push to hub started')
push_to_hfhub(
hf_model_id="fcakyon/yolov8n-test",
exp_dir='runs/detect/train',
hf_token=os.getenv('HF_TOKEN'),
hf_private=True,
hf_dataset_id="fcakyon/football-detection",
thumbnail_text='YOLOv8s Football Detection'
)
print('push to hub ended')
try:
push_to_hfhub(
hf_model_id="fcakyon/yolov8n-test",
exp_dir='runs/detect/train',
hf_token=os.getenv('HF_TOKEN'),
hf_private=True,
hf_dataset_id="fcakyon/football-detection",
thumbnail_text='YOLOv8s Football Detection'
)
print('push to hub succeeded')
except HfHubHTTPError as e:
print('push to hub failed')
print(e)