# hub

Python API: `hubai_sdk.utils.hub`

## Functions

### full_slug_to_id

```python
def full_slug_to_id(slug: str, endpoint: Literal['models', 'modelVersions', 'modelInstances']) -> str:
```

Resolve a full HubAI slug to a resource ID using the slug API.

### get_configs

```python
def get_configs(path: str | None, opts: list[str] | dict[str, Any] | None = None) -> tuple[Config, NNArchiveConfig | None, str | None]:
```

Sets up the configuration.

Parameters

 * `path` (`str | None`): Path to the configuration file or NN Archive.
 * `opts` (`list[str] | dict[str, Any] | None`): Optional CLI overrides for the config file.

Returns

 * `tuple[Config, NNArchiveConfig | None, str | None]`: The parsed modelconverter configuration, optional NN Archive
   configuration, and main stage key.

### get_output_dir_name

```python
def get_output_dir_name(target: Target, name: str, output_dir: str | None) -> Path:
```

Build an output directory path for a conversion result.

### get_resource_id

```python
def get_resource_id(identifier: str, endpoint: Literal['models', 'modelVersions', 'modelInstances']) -> str:
```

Resolve a UUID, HubAI ID, or slug into a resource ID.

Parameters

 * `identifier` (`str`): User-supplied UUID, HubAI ID, or slug.
 * `endpoint` (`Literal['models', 'modelVersions', 'modelInstances']`): Resource endpoint to resolve against.

Returns

 * `str`: The resolved HubAI resource ID.

Raises

 * `ValueError`: If the identifier cannot be resolved.

### get_resource_info

```python
def get_resource_info(identifier: str, endpoint: ResourceEndpoint) -> dict[str, Any]:
```

Fetch raw HubAI resource data for a resolved identifier.

### get_target_specific_options

```python
def get_target_specific_options(target: Target, cfg: SingleStageConfig, tool_version: str | None = None) -> dict[str, Any]:
```

Build export options for a target from a parsed config.

### get_variant_name

```python
def get_variant_name(cfg: SingleStageConfig, model_type: ModelType, name: str) -> str:
```

Derive a variant name, appending input resolution when known.

### get_version_number

```python
def get_version_number(model_id: str) -> str:
```

Return the next patch version for a model's variants.

### init_dirs

```python
def init_dirs():
```

Create the SDK working directories if they do not exist.

### is_hubai_id

```python
def is_hubai_id(identifier: str) -> bool:
```

Return whether an identifier looks like a HubAI resource ID.

### is_valid_uuid

```python
def is_valid_uuid(uuid_string: str) -> bool:
```

Return whether a string is a valid UUID.

### print_hub_ls

```python
def print_hub_ls(data: list[dict[str, Any]], keys: list[str], rename: dict[str, str] | None = None):
```

Render a list of HubAI resources as a rich table.

### print_hub_resource_info

```python
def print_hub_resource_info(model: dict[str, Any], keys: list[str], json: bool, rename: dict[str, str] | None = None, **kwargs):
```

Render a single HubAI resource in CLI-friendly rich output.

### raise_for_hub_error

```python
def raise_for_hub_error(exc: HTTPError, *, identifier: str | None = None, endpoint: ResourceEndpoint | Literal['jobs'] | None = None, conflict_message: str | None = None) -> NoReturn:
```

Translate a requests HTTP error into an SDK-specific exception.

### resolve_resource_id

```python
def resolve_resource_id(identifier: str, endpoint: ResourceEndpoint) -> str:
```

Resolve an identifier and translate lookup failures to SDK errors.

### run_cli

```python
def run_cli(action: Callable[[], T]) -> T:
```

Run a CLI action and convert SDK exceptions into clean exits.

### slug_to_id

```python
def slug_to_id(slug: str, endpoint: Literal['models', 'modelVersions', 'modelInstances']) -> str:
```

Resolve a simple slug to a resource ID by querying HubAI.

### wait_for_job

```python
def wait_for_job(job_id: str) -> JobMessageResponse:
```

Poll a HubAI job until it completes or fails.

Parameters

 * `job_id` (`str`): HubAI job ID.

Returns

 * `JobMessageResponse`: The completed job response.

Raises

 * `HubApiError`: If the job fails or ends in a terminal non-success status.

## Attributes

### ResourceEndpoint

### T
