Automatically create Model via Pystardog, not available in Studio

Hi,

I create a .ttl file in Python containing a named graph. Then, I use pystardog to push that .ttl file to the database I built:

# Convert named graph file into Stardog content
stardog_named_graph = stardog.content.ImportFile(named_graph_file_path, content_type=stardog.content_types.TURTLE)

# Push to Stardog Cloud
with stardog.Connection(database=build_database, **conn_details) as conn:
     conn.begin()
     conn.add(stardog_named_graph, graph_uri=urn, server_side=False)
     conn.commit()

However, when I go to Stardog Studio they are not located under 'Models':

I am able to get them to appear but clicking 'Create Model' and then choosing the "Named Graph" and adding a "Model Name".
image

Is there a way to automate that last step? This is an important step because our knowledge graph will be rebuilt routinely and any user using Stardog Studio will have to add the model again after each rebuild.

Any thoughts / solutions?

Hi,

you can add the reasoning schema using the CLI with the reasoning schema --add command. For example:

reasoning schema --add MyModel --graphs urn:MyModel -- myDB

In pystardog, you should be able to modify the reasoning.schemas option with an Admin connection on the selected db as follows:

db.set_options({"reasoning.schemas": ["default=tag:stardog:api:context:schema", "MyModel=urn:MyModel"]})

Best regards
Lars