Skip to content

Support for project ontology change #1972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025

Conversation

paulnoirel
Copy link
Contributor

Description

Elevenlabs requested this change. It reverts a restriction so users can change a project's ontology.

Changes

  • The MediaType of an ontology is now accessible: Ontology.media_type

Example

Common

def simple_ontology():
    classifications = [
        {
            "name": "test_ontology",
            "instructions": "Which class is this?",
            "type": "radio",
            "options": [
                {"value": c, "label": c} for c in ["one", "two", "three"]
            ],
            "required": True,
        }
    ]

    return {"tools": [], "classifications": classifications}
  1. Working case - same media type for project and ontology
# Create a project with Image media type
project = client.create_project(
    name="my_image_project",
    media_type=MediaType.Image
)

# Create and connect first ontology
first_ontology = client.create_ontology(
    "first_ontology",
    simple_ontology(),
    media_type=MediaType.Image
)
project.connect_ontology(first_ontology)

# Create and connect second ontology with same media type
second_ontology = client.create_ontology(
    "second_ontology",
    simple_ontology(),
    media_type=MediaType.Image
)
project.connect_ontology(second_ontology)  # This works because media types match
  1. Working case - media type unknown for the ontology
# Create a project with Image media type
project = client.create_project(
    name="my_image_project",
    media_type=MediaType.Image
)

# Create and connect first ontology
first_ontology = client.create_ontology(
    "first_ontology",
    simple_ontology(),
    media_type=MediaType.Image
)
project.connect_ontology(first_ontology)

# Create and connect second ontology with same media type
second_ontology = client.create_ontology(
    "second_ontology",
    simple_ontology()
)
project.connect_ontology(second_ontology)  # This works because media types match
  1. Non-working case - different media type for project and ontology
# Create a project with Image media type
project = client.create_project(
    name="my_image_project",
    media_type=MediaType.Image
)

# Create and connect first ontology
first_ontology = client.create_ontology(
    "first_ontology",
    simple_ontology(),
    media_type=MediaType.Image
)
project.connect_ontology(first_ontology)

# Create and connect second ontology with different media type
second_ontology = client.create_ontology(
    "second_ontology",
    simple_ontology(),
    media_type=MediaType.Video
)
project.connect_ontology(second_ontology)  # ValueError: Ontology and project must share the same type, unless the ontology has no type

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Document change (fix typo or modifying any markdown files, code comments or anything in the examples folder only)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

New Feature Submissions

  • Does your submission pass tests?
  • Have you added thorough tests for your new feature?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Have you added a Docstring?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

@paulnoirel paulnoirel force-pushed the pno/PLT-2447-update_connect_ontology branch from 6369334 to 75c8f24 Compare May 29, 2025 18:29
@paulnoirel paulnoirel merged commit 1784891 into develop Jun 5, 2025
4 of 5 checks passed
@paulnoirel paulnoirel deleted the pno/PLT-2447-update_connect_ontology branch June 5, 2025 17:01
@paulnoirel paulnoirel changed the title Support project change of ontology Support for project ontology change Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants