Get an ontology object with meda reference property in code repo

Hi guys! I’m trying to do a super simple thing - get an ontology object property back from my custom python function in code repository (so I can manipulate with the property in the future more easily). I did that hundred of times, but with this specific scenario - when an ontology object has media reference property I get the following error:

BetaWarning: Media types are in beta and may change in future versions. Please import AllowBetaFeatures from foundry_sdk_runtime and execute your code within its context. For example: from foundry_sdk_runtime import AllowBetaFeatures with AllowBetaFeatures(): <your code>. Error Parameters: { "input": "document" }

When I format the code following the suggestion above, I still get the same error. Anyone knows what this is about? And why can’t I access non media reference properties at all?

My function (all imports are valid, and SCO_Document does exist):

@function
def get_title_recommendation(document: SCO_Document) -> str:
    return "No content available"

Try n1 - the same error:

@function
@AllowBetaFeatures()
def get_title_recommendation(document: SCO_Document) -> str:
    return "No content available"

OR

@function
def get_title_recommendation(document: SCO_Document) -> str:
    with AllowBetaFeatures():
         return "No content available"

Try n2 - does not recognise the function at all:

@AllowBetaFeatures()
@function
def get_title_recommendation(document: SCO_Document) -> str:
    return "No content available"

My second idea was to create another object similar to this one, but without media reference properties. This works, but not very memory friendly.

@Jan1 did you find a solution for this? I’m hitting the same roadblock currently in Python functions when trying to work with an object that has a media reference property.

Still nothing. I’ve created another object holding a media reference property and a primary key, and removed the media reference from the primary object itself. This way I can access it both in the workshop module (as a media preview) and the code repo.

1 Like