Skip to content

Data Catalog

Key Features

  • Discover Datasets: Easily discover datasets related to your area of interest through intuitive search and exploration functionalities.

  • Explore Metadata: Gain insights into dataset details, including metadata, versions, contributors, and associated documentation.

  • Manage Datasets: Create, update, and delete datasets, including metadata, versions, contributors, and associated documentation.

  • Search Capabilities: Leverage powerful search capabilities to find datasets based on keywords, tags, contributors, and other criteria.

Examples

Client functions

get

Get resource by name or UUID.

Arguments

  • ref ( UUID| str): Resource reference.

Yields

  • Resources: Resources matching the provided reference.

Example

from odp.client import OdpClient

client = OdpClient()

resource_manifest = client.catalog.get("catalog.hubocean.io/dataCollection/1e3401d4-9630-40cd-a9cf-d875cb310449-glodap")

print(resource_manifest)

same_resource_manifest = client.catalog.get(resource_manifest.metadata.uuid)

print(same_resource_manifest)
list

List all resources based on the provided filter.

Arguments

  • oqs_filter (Optional[dict]): OQS filter. Read more about OQS here.
  • cursor (Optional[str]): Optional cursor for pagination.

Yields

  • Resources: Resources matching the provided filter.

Example

from odp.client import OdpClient

client = OdpClient()

# Assuming oqs_filter is a valid OQS filter
oqs_filter = {...}

for resource in client.catalog.list(oqs_filter=oqs_filter):
    print(resource)
create

Create a resource from a manifest.

Arguments

  • manifest (DatasetDto): Resource manifest containing information required for creation.

Returns

The manifest of the created resource, populated with uuid and status.

Raises

  • OdpValidationError: Raised when the input manifest is invalid.
  • OdpResourceExistsError: Raised when the resource already exists.

Example

from odp.client import OdpClient
from odp.dto import Metadata
from odp.dto.catalog import DatasetDto, DatasetSpec
from odp.dto.common.contact_info import ContactInfo
from odp.client.exc import OdpResourceExistsError, OdpValidationError

client = OdpClient()

# DatasetDto
manifest = {...}

try:
    created_resource_manifest = client.catalog.create(manifest)
    print("Resource created successfully:", created_resource_manifest)
except OdpValidationError as e:
    print("Validation Error:", e)
except OdpResourceExistsError as e:
    print("Resource Already Exists Error:", e)
update

Update a resource from a manifest.

Arguments

  • manifest_update (DatasetDto or dict): Resource manifest or JSON patch containing the updates.
  • ref (Optional[str or UUID]): Optional reference to the resource to update.

Returns

The manifest of the updated resource, populated with the updated fields.

Raises

  • OdpValidationError: Raised when the input is invalid.
  • OdpResourceNotFoundError: Raised when the resource is not found.

Example

from odp.client import OdpClient
from odp.dto import Metadata
from odp.dto.catalog import DatasetDto, DatasetSpec
from odp.dto.common.contact_info import ContactInfo
from odp.client.exc import OdpResourceNotFoundError, OdpValidationError

client = OdpClient()

# DatasetDto
manifest_update = {...}

try:
    updated_resource_manifest = client.catalog.update(manifest_update)
    print("Resource updated successfully:", updated_resource_manifest)
except OdpValidationError as e:
    print("Validation Error:", e)
except OdpResourceNotFoundError as e:
    print("Resource Not Found Error:", e)
delete

Delete a resource by reference.

Arguments

  • ref (UUID, str, or DatasetDto): Resource reference. If a ResourceDto is passed, the reference will be extracted from the metadata.

Raises

  • OdpResourceNotFoundError: Raised if the resource does not exist.

Example

import uuid
from odp.client import OdpClient
from odp.client.exc import OdpResourceNotFoundError

client = OdpClient()

# Assuming ref is a valid UUID, string, or ResourceDto
ref = "dataset_name"

try:
    client.catalog.delete(ref)
    print("Resource deleted successfully.")
except OdpResourceNotFoundError as e:
    print("Resource Not Found Error:", e)