Skip to content

hopsworks.core.tag_schemas_api #

TagSchemasApi #

Manage the platform's typed tag-schema registry.

All write operations on this class require the platform-administrator role (HOPS_ADMIN); read operations require any authenticated user.

For backwards compatibility hopsworks.core.tag_schemas_api.TagSchemasApi is still available as hsfs.core.tag_schemas_api.TagSchemasApi. The use of this alias is discouraged as it is to be deprecated.

create #

create(name: str, schema: dict | str) -> dict[str, Any]

Register a new schematized tag.

Tag schemas are JSON-Schema definitions that constrain the value clients can attach via TagsApi.add(...). A schema must be valid JSON Schema (type, properties, etc.); the backend rejects malformed payloads.

Requires HOPS_ADMIN (platform administrator). Project-level Data Owner is not sufficient.

Example
from hopsworks_common.core.tag_schemas_api import TagSchemasApi

schema = {
    "type": "object",
    "properties": {
        "owner": {"type": "string"},
        "version": {"type": "integer"},
    },
    "required": ["owner"],
}
TagSchemasApi().create("ownership", schema)
PARAMETER DESCRIPTION
name

Unique schema name (used later by clients to attach tag instances to entities).

TYPE: str

schema

JSON-Schema definition. May be a Python dict (the preferred form) or a JSON string already serialized.

TYPE: dict | str

RETURNS DESCRIPTION
dict[str, Any]

The created schema payload as returned by the backend.

RAISES DESCRIPTION
PermissionError

If the caller lacks HOPS_ADMIN.

ValueError

If name is empty or schema is not a dict or a JSON string.

hopsworks.client.exceptions.RestAPIError

If the schema payload is rejected by the backend (invalid JSON Schema, duplicate name, etc.).

delete #

delete(name: str) -> None

Remove a tag schema from the registry.

Requires HOPS_ADMIN. Project-level Data Owner is not sufficient.

PARAMETER DESCRIPTION
name

Schema name.

TYPE: str

RAISES DESCRIPTION
PermissionError

If the caller lacks HOPS_ADMIN.

hopsworks.client.exceptions.RestAPIError

If the schema does not exist or the backend otherwise rejects the request.

get #

get(name: str) -> dict[str, Any]

Fetch a single tag schema by name.

PARAMETER DESCRIPTION
name

Schema name.

TYPE: str

RETURNS DESCRIPTION
dict[str, Any]

The raw schema payload from the backend.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the schema does not exist.

list #

list() -> dict[str, Any]

List all registered tag schemas.

RETURNS DESCRIPTION
dict[str, Any]

The raw schema-list payload from the backend.