Reference for hub_sdk/modules/projects.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/modules/projects.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.modules.projects.Projects
Projects(
project_id: Optional[str] = None, headers: Optional[Dict[str, Any]] = None
)
Bases: CRUDClient
A class representing a client for interacting with Projects through CRUD operations.
This class extends the CRUDClient class and provides specific methods for working with Projects.
Attributes:
Name | Type | Description |
---|---|---|
hub_client |
ProjectUpload
|
An instance of ProjectUpload used for interacting with model uploads. |
id |
str | None
|
The unique identifier of the project, if available. |
data |
Dict
|
A dictionary to store project data. |
Note
The 'id' attribute is set during initialization and can be used to uniquely identify a project. The 'data' attribute is used to store project data fetched from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
Project ID for retrieving data. |
None
|
headers
|
Dict[str, Any]
|
A dictionary of HTTP headers to be included in API requests. |
None
|
Source code in hub_sdk/modules/projects.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
create_project
create_project(project_data: Dict) -> None
Create a new project with the provided data and set the project ID for the current instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_data
|
Dict
|
A dictionary containing the data for creating the project. |
required |
Source code in hub_sdk/modules/projects.py
77 78 79 80 81 82 83 84 85 86 |
|
delete
delete(hard: Optional[bool] = False) -> Optional[Response]
Delete the project resource represented by this instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hard
|
bool
|
If True, perform a hard (permanent) delete. |
False
|
Note
The 'hard' parameter determines whether to perform a soft delete (default) or a hard delete. In a soft delete, the project might be marked as deleted but retained in the system. In a hard delete, the project is permanently removed from the system.
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the delete request, or None if delete fails. |
Source code in hub_sdk/modules/projects.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
get_data
get_data() -> None
Retrieve data for the current project instance.
If a valid project ID has been set, it sends a request to fetch the project data and stores it in the instance. If no project ID has been set, it logs an error message.
Source code in hub_sdk/modules/projects.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
update
update(data: Dict) -> Optional[Response]
Update the project resource represented by this instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Dict
|
The updated data for the project resource. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the update request, or None if update fails. |
Source code in hub_sdk/modules/projects.py
105 106 107 108 109 110 111 112 113 114 115 |
|
upload_image
upload_image(file: str) -> Optional[Response]
Upload an image file to the hub associated with this client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
str
|
The file path or URL of the image to be uploaded. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the uploaded image request, or None if upload fails. |
Source code in hub_sdk/modules/projects.py
117 118 119 120 121 122 123 124 125 126 127 |
|
hub_sdk.modules.projects.ProjectList
ProjectList(
page_size: Optional[int] = None,
public: Optional[bool] = None,
headers: Optional[Dict] = None,
)
Bases: PaginatedList
Provides a paginated list interface for querying project resources from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page_size
|
int
|
The number of items to request per page. |
None
|
public
|
bool
|
Whether the items should be publicly accessible. |
None
|
headers
|
Dict
|
Headers to be included in API requests. |
None
|
Source code in hub_sdk/modules/projects.py
133 134 135 136 137 138 139 140 141 142 143 |
|