Giter VIP home page Giter VIP logo

hub-sdk's Introduction


๐Ÿš€ Ultralytics HUB-SDK

HUB-SDK CI codecov Discord

Welcome to the Ultralytics HUB-SDK documentation! ๐Ÿ“– Our aim is to guide you through the installation process and help you get started with using HUB-SDK for your machine learning endeavors.

๐Ÿ›  Quickstart: Installing HUB-SDK

Ready to dive into HUB-SDK? Follow these steps to set it up on your machine.

Prerequisites

Ensure you have the following requirements met before proceeding:

  • Python: HUB-SDK requires Python. Download and install Python from python.org if it's not already installed on your system.

  • Git (Optional): If you're looking to install HUB-SDK via the GitHub repository, you'll need Git. Grab Git from git-scm.com if you don't have it.

Installation Methods

Choose from the following options to install HUB-SDK:

Installing from PyPI

PyPI version Downloads

For the latest stable release of HUB-SDK, use PyPI by running the following command:

pip install hub-sdk

๐Ÿš€ Usage

Let's begin using the HUB-SDK to perform CRUD operations for Models, Datasets, and Projects.

1. Import HUB-SDK

Start by importing the HUBClient from the hub_sdk module:

from hub_sdk import HUBClient

2. Authenticate with Credentials

Set your credentials using one of the following methods:

Using API Key
# Authenticate using an API key
credentials = {"api_key": "YOUR_API_KEY"}

or

Using Email and Password
# Authenticate using your email and password
credentials = {"email": "YOUR_EMAIL", "password": "YOUR_PASSWORD"}

3. Initialize the HUBClient

With your credentials ready, initialize the HUBClient:

# Initialize the client with your credentials
client = HUBClient(credentials)

Operations

Below are code snippets demonstrating create, read, update, and delete (CRUD) operations for Projects, Models, and Datasets.

Project Operations

Managing projects is simple:

# Manipulate a project with the given ID
project = client.project("PROJECT_ID")

# Create a new project with the specified data
create_project = project.create_project("PROJECT_DATA")

# Update the existing project with new data
update_project = project.update("UPDATE_DATA")

# Delete the project
deleted_project = project.delete()

Model Operations

Handle models effortlessly:

# Engage with a model using the given ID
model = client.model("MODEL_ID")

# Create a new model providing the necessary data
create_model = model.create_project("MODEL_DATA")

# Update the model using provided data
update_model = model.update("UPDATE_DATA")

# Remove the model from the system
deleted_model = model.delete()

Dataset Operations

Datasets operations are straightforward:

# Interact with a dataset using the specified ID
dataset = client.dataset("DATASET_ID")

# Establish a new dataset given the data
create_dataset = dataset.create_project("DATASET_DATA")

# Adjust the dataset with updated information
update_dataset = dataset.update("UPDATE_DATA")

# Erase the dataset
deleted_dataset = dataset.delete()

๐Ÿš€ Ultralytics HUB

Experience seamless AI with Ultralytics HUB โญ, the all-in-one solution for data visualization, YOLOv5 and YOLOv8 ๐Ÿš€ model training and deployment, without any coding. Transform images into actionable insights and bring your AI visions to life with ease using our cutting-edge platform and user-friendly Ultralytics App. Start your journey for Free now!

Ultralytics HUB preview image

๐Ÿ’ก Contribute

We're thrilled to have you contribute to Ultralytics' open-source projects! Your support and contributions make a world of difference. Get involved by checking out our Contributing Guide, and share your feedback through our Survey. A massive thank you ๐Ÿ™ to everyone who contributes!

Ultralytics open-source contributors

๐Ÿ“„ License

Ultralytics provides two types of licensing options:

  • AGPL-3.0 License: An OSI-approved open-source license. Ideal for academics, researchers, and enthusiasts, this license promotes sharing knowledge and collaboration. See the LICENSE file for details.

  • Enterprise License: Tailored for commercial applications, this license allows for the integration of Ultralytics software into proprietary products and services. If you're considering using our solutions commercially, please get in touch through Ultralytics Licensing.

๐Ÿค Contact

  • Submit Ultralytics bug reports and feature requests via GitHub Issues.
  • Join our Discord for assistance, questions, and discussions with the community and team!

Ultralytics GitHub space Ultralytics LinkedIn space Ultralytics Twitter space Ultralytics YouTube space Ultralytics TikTok space Ultralytics Instagram space Ultralytics Discord

hub-sdk's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar glenn-jocher avatar hassaanfarooq01 avatar kalenmike avatar pderrenger avatar sergiuwaxmann avatar ultralyticsassistant avatar yogendrasinghx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hub-sdk's Issues

Repo is missing CI

@kalenmike @hassaanfarooq01 I don't see any CI actions running on my recent PR #47. We need to have CI running on schedule and push events in this repo to follow best practices, otherwise we don't know if package releases have introduced bugs or if PRs are potentially introducing bugs.

CT Error

Search before asking

  • I have searched the HUB-SDK issues and found no similar bug report.

HUB-SDK Component

Other

Bug

@yogendrasinghx 3 failing CI tests here introduced in #116

See https://github.com/ultralytics/hub-sdk/actions/runs/8650461977/job/23719232082

=================================== FAILURES ===================================
___________________________ TestModel.test_model_001 ___________________________

self = <functional.test_model.TestModel object at 0x7fe415d86120>

    @pytest.mark.smoke
    def test_model_001(self):
        """Verify successful retrieval of a model by ID."""
    
        model_id = TestData().get_models_data()["valid_model_ID"]
        object_manager = ObjectManager(self.client)
        model_obj = object_manager.get_model()
    
        log = self.getLogger()
        log.info(f"Attempting to retrieve model with ID: {model_id}")
    
        model = model_obj.get_model_by_id(model_id)
    
        log.info(f"Model retrieved successfully. Model data: {model.data}")
    
>       assert "config" in model.data, "Config information not found in the model data"
E       AssertionError: Config information not found in the model data
E       assert 'config' in {}
E        +  where {} = <hub_sdk.modules.models.Models object at 0x7fe413bfc770>.data

tests/functional/test_model.py:23: AssertionError
----------------------------- Captured stderr call -----------------------------
2024-04-11 17:05:01,098 - hub_sdk.helpers.logger - ERROR - Unknown error occurred.
2024-04-11 17:05:01,099 - hub_sdk.helpers.logger - ERROR - Received no response from the server for model id pmcIKukVlTQfnkk3FxgJ
------------------------------ Captured log call -------------------------------
INFO     test_model_001:test_model.py:17 Attempting to retrieve model with ID: pmcIKukVlTQfnkk3FxgJ
ERROR    hub_sdk.helpers.logger:api_client.py:111 Unknown error occurred.
ERROR    hub_sdk.helpers.logger:models.py:87 Received no response from the server for model id pmcIKukVlTQfnkk3FxgJ
INFO     test_model_001:test_model.py:21 Model retrieved successfully. Model data: {}
___________________________ TestModel.test_model_008 ___________________________

self = <functional.test_model.TestModel object at 0x7fe415d872c0>
clear_export_model = None

    @pytest.mark.smoke
    def test_model_008(self, clear_export_model):
        """Verify successful export of a model."""
    
        log = self.getLogger()
    
        # Retrieve necessary data
        model_id = TestData().get_models_data()["valid_model_ID"]
        object_manager = ObjectManager(self.client)
        model_obj = object_manager.get_model()
        desired_format = TestData().get_models_data()["desired_model_format"]
    
        # Export the model
        log.info(f"Exporting model {model_id} in {desired_format} format")
        model_obj.export_model(model_id, format_name=desired_format)
    
        # Check if the model is successfully exported
        export_status = model_obj.is_model_exported(model_id, format_name=desired_format)
        log.info(f"Model export status: {'Success' if export_status else 'Failure'}")
    
>       assert export_status
E       assert False

tests/functional/test_model.py:207: AssertionError
----------------------------- Captured stderr call -----------------------------
2024-04-11 17:05:34,109 - hub_sdk.helpers.logger - ERROR - Unknown error occurred.
2024-04-11 17:05:34,110 - hub_sdk.helpers.logger - ERROR - Received no response from the server for model id pmcIKukVlTQfnkk3FxgJ
2024-04-11 17:05:35,269 - hub_sdk.helpers.logger - ERROR - Unknown error occurred.
------------------------------ Captured log call -------------------------------
INFO     test_model_008:test_model.py:200 Exporting model pmcIKukVlTQfnkk3FxgJ in ncnn format
ERROR    hub_sdk.helpers.logger:api_client.py:111 Unknown error occurred.
ERROR    hub_sdk.helpers.logger:models.py:87 Received no response from the server for model id pmcIKukVlTQfnkk3FxgJ
ERROR    hub_sdk.helpers.logger:api_client.py:111 Unknown error occurred.
INFO     test_model_008:test_model.py:205 Model export status: Failure
___________________________ TestModel.test_model_009 ___________________________

self = <functional.test_model.TestModel object at 0x7fe415d874a0>

    @pytest.mark.smoke
    def test_model_009(self):
        """Verify successful retrieval of model storage URL."""
    
        log = self.getLogger()
    
        model_id = TestData().get_models_data()["valid_model_ID"]
    
        log.info(f"Attempting to retrieve the storage URL for model with ID: {model_id}")
    
        object_manager = ObjectManager(self.client)
        model_obj = object_manager.get_model()
    
        # Get the model storage URL
        link = model_obj.get_model_download_link(model_id)
    
        log.info(f"Storage URL retrieved successfully. URL: {link}")
    
>       assert f"{model_id}/best.pt" in link, f"Model ID not found in the storage URL: {link}"
E       TypeError: argument of type 'NoneType' is not iterable

tests/functional/test_model.py:227: TypeError
----------------------------- Captured stderr call -----------------------------
2024-04-11 17:06:37,[62](https://github.com/ultralytics/hub-sdk/actions/runs/8650461977/job/23719232082#step:6:63)8 - hub_sdk.helpers.logger - ERROR - Unknown error occurred.
2024-04-11 17:06:37,629 - hub_sdk.helpers.logger - ERROR - Received no response from the server for model id pmcIKukVlTQfnkk3FxgJ
------------------------------ Captured log call -------------------------------
INFO     test_model_009:test_model.py:217 Attempting to retrieve the storage URL for model with ID: pmcIKukVlTQfnkk3FxgJ
ERROR    hub_sdk.helpers.logger:api_client.py:111 Unknown error occurred.
ERROR    hub_sdk.helpers.logger:models.py:87 Received no response from the server for model id pmcIKukVlTQfnkk3FxgJ
INFO     test_model_009:test_model.py:225 Storage URL retrieved successfully. URL: None
=============================== warnings summary ===============================
<frozen importlib._bootstrap>:488
  <frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

<frozen importlib._bootstrap>:488
  <frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/functional/test_model.py::TestModel::test_model_001 - AssertionError: Config information not found in the model data
assert 'config' in {}
 +  where {} = <hub_sdk.modules.models.Models object at 0x7fe413bfc7[70](https://github.com/ultralytics/hub-sdk/actions/runs/8650461977/job/23719232082#step:6:71)>.data
FAILED tests/functional/test_model.py::TestModel::test_model_008 - assert False
FAILED tests/functional/test_model.py::TestModel::test_model_009 - TypeError: argument of type 'NoneType' is not iterable
======= 3 failed, 21 passed, 1 skipped, 2 warnings in 162.00s (0:02:42) ========

Environment

No response

Minimal Reproducible Example

No response

Additional

Also a few deprecation warnings here, but lower priority.

Screenshot 2024-04-11 at 19 13 22

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.