> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/unitlabclient-and-resource-namespaces.md).

# UnitlabClient और resource namespaces

Python SDK में UnitlabClient बनाएँ, उसके resource namespaces से हर Unitlab रिसोर्स तक पहुँचें, टाइमआउट व retry समझें और क्लाइंट को सही तरह बंद करें।

`UnitlabClient` Python SDK का एंट्री पॉइंट है। यह एक HTTP connection pool रखता है और हर Unitlab रिसोर्स को एक namespace के रूप में देता है।

```python
from unitlab import UnitlabClient

client = UnitlabClient()              # reads UNITLAB_API_KEY and UNITLAB_API_URL
try:
    for project in client.projects.list():
        print(project.id, project.name)
finally:
    client.close()
```

`UnitlabClient(api_key=None, api_url=None)` key और URL पहले अपने आर्ग्यूमेंट से, फिर environment से, फिर `unitlab configure` से लेता है। [ऑथेंटिकेशन और API keys](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/authentication-and-api-keys.md) देखें।

## Namespaces <a href="#namespaces" id="namespaces"></a>

| Namespace                 | लौटाता है                   | इस्तेमाल                                                            |
| ------------------------- | --------------------------- | ------------------------------------------------------------------- |
| `client.projects`         | `Project`                   | प्रोजेक्ट की सूची, get और create; upload, attach, workflow, imports |
| `client.assets`           | `Asset`, `Folder`           | वर्कस्पेस लाइब्रेरी फ़ाइलें, फ़ोल्डर, कस्टम मेटाडेटा, Data Groups   |
| `client.datasets`         | `Dataset`, `DatasetVersion` | क्यूरेटेड ड्राफ़्ट और पब्लिश वर्ज़न                                 |
| `client.ontologies`       | `Ontology`                  | दोबारा इस्तेमाल होने वाली क्लास और प्रॉपर्टी परिभाषाएँ              |
| `client.releases`         | `Release`                   | एक्सपोर्ट बनाना, उनका इंतज़ार करना और डाउनलोड करना                  |
| `client.cloud_storages`   | `CloudStorage`              | सेव किए गए S3, GCS, Azure और S3-compatible कनेक्शन                  |
| `client.embedding_spaces` | `EmbeddingSpace`            | अपने vectors और similarity search                                   |

तीन shortcut प्रोजेक्ट handle के बिना काम करते हैं:

| कॉल                                                                   | लौटाता है                                   |
| --------------------------------------------------------------------- | ------------------------------------------- |
| `client.get_workflow_task(task_id)`                                   | `WorkflowTask`, Agent और मॉडल सर्विस के लिए |
| `client.get_data_unit(project_id, unit_id)`                           | एक `DataUnit`                               |
| `client.attach_dataset(project, dataset, version="latest", fps=None)` | `AttachResult`                              |

## Handles और IDs <a href="#handles-and-ids" id="handles-and-ids"></a>

हर namespace typed handle लौटाता है। Handle अपनी raw API row `.raw` में रखता है और उस पर काम करने वाले methods देता है:

```python
project = client.projects.get("PROJECT_ID")
batch = project.upload("./images")
release = client.releases.create(project, export_type="COCO")
```

जहाँ भी कोई method रिसोर्स लेता है, आप handle या उसकी ID string दे सकते हैं।

## Client का जीवनकाल <a href="#client-lifetime" id="client-lifetime"></a>

* हर process या worker के लिए एक client बनाएँ और उसे दोबारा इस्तेमाल करें। क्रमिक कॉल में इसे साझा करना सुरक्षित है।
* काम खत्म होने पर `client.close()` कॉल करें, या काम को `try`/`finally` में रखें।
* multiprocessing इस्तेमाल करते समय हर process में अलग client बनाएँ।

## टाइमआउट और retry <a href="#timeouts-and-retries" id="timeouts-and-retries"></a>

| सेटिंग               | मान                                                                  |
| -------------------- | -------------------------------------------------------------------- |
| HTTP request timeout | 60 सेकंड (रिलीज़ बनाने के लिए 600 सेकंड)                             |
| Connection errors    | 3 बार retry, 0, 0.5 और 1 सेकंड के बाद                                |
| Proxies              | `HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY` और `NO_PROXY` माने जाते हैं |

HTTP errors अपने-आप retry नहीं होते। [Exceptions, टाइमआउट और retry](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/exceptions-timeouts-and-retries.md) देखें।

## संबंधित पेज <a href="#related" id="related"></a>

[Python SDK क्विकस्टार्ट](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/python-sdk-quickstart.md) · [Return types और fields](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/return-types-and-fields.md) · [प्रोजेक्ट](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/projects.md)
