owmeta_core.data module

class owmeta_core.data.Data(conf=None, **kwargs)[source]

Bases: Configuration

Provides configuration for access to the database.

Usually doesn’t need to be accessed directly

rdf.graph

An RDFLib ConjunctiveGraph, possibly a Dataset. Configured according to rdf.source and any other variables used by the RDFSource corresponding

rdf.namespace

Default namespace bound to an empty string in the the namespace manager, rdf.namespace_manager

rdf.namespace_manager

RDFLib Namespace Manager. Typically, this is generated automatically during a call to init

rdf.namespace_manager.store

RDFLib store name specific to namespaces

rdf.namespace_manager.store_conf

Configuration for RDFLib store specified with rdf.namespace_manager.store

transaction_manager.provider

A provider for a transaction manager. Provider must resolve to a callable that accepts a Data instance.

transaction_manager

Transaction manager for RDFLib stores. Provided by transaction_manager.provider if that’s defined. Should be passed to IDataManager instances within the scope of a given Data instance.

rdf.source

A string corresponding to a key in SOURCES

Parameters
confConfiguration

The base configuration from which this configuration will be built. This configuration will be copied into this one, but no direct reference will be retained

close()

Close a the configured database

closeDatabase()

Close a the configured database

destroy()[source]

Close a the configured database

init()[source]

Open the configured database

init_database()

Open the configured database

classmethod load(file_name)[source]

Load a file into a new Data instance storing configuration in a JSON format

classmethod open(file_name)[source]

Load a file into a new Data instance storing configuration in a JSON format

classmethod process_config(config_dict, **kwargs)[source]

Load a file into a new Data instance storing configuration in a JSON format

class owmeta_core.data.DataUser(*args, **kwargs)[source]

Bases: Configurable

A convenience wrapper for users of the database

Classes which use the database should inherit from DataUser.

add_reference(g, reference_iri)[source]

Add a citation to a set of statements in the database

Parameters

triples – A set of triples to annotate

add_statements(graph)[source]

Add a set of statements to the database. Annotates the addition with uploader name, etc

Parameters

graph – An iterable of triples

infer()[source]

Fire FuXi rule engine to infer triples

retract_statements(graph)[source]

Remove a set of statements from the database.

Parameters

graph – An iterable of triples

class owmeta_core.data.DefaultSource(**kwargs)[source]

Bases: RDFSource

Reads from and queries against a configured database.

The default configuration.

The database store is configured with:

"rdf.source" = "default"
"rdf.store" = <your rdflib store name here>
"rdf.store_conf" = <your rdflib store configuration here>

Leaving unconfigured simply gives an in-memory data store.

class owmeta_core.data.RDFSource(**kwargs)[source]

Bases: Configurable, ConfigValue

Base class for data sources.

Alternative sources should derive from this class

open()[source]

Called on owmeta_core.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.

class owmeta_core.data.SPARQLSource(**kwargs)[source]

Bases: RDFSource

Reads from and queries against a remote data store

"rdf.source" = "sparql_endpoint"
class owmeta_core.data.SleepyCatSource(**kwargs)[source]

Bases: RDFSource

Reads from and queries against a local Sleepycat database

The database can be configured like:

"rdf.source" = "Sleepycat"
"rdf.store_conf" = <your database location here>
class owmeta_core.data.ZODBSource(*args, **kwargs)[source]

Bases: RDFSource

Reads from and queries against a configured Zope Object Database.

If the configured database does not exist, it is created.

The database store is configured with:

"rdf.source" = "ZODB"
"rdf.store_conf" = <location of your ZODB database>

Leaving unconfigured simply gives an in-memory data store.

owmeta_core.data.NAMESPACE_MANAGER_KEY = 'rdf.namespace_manager'

Constant for rdf.namespace_manager

owmeta_core.data.NAMESPACE_MANAGER_STORE_CONF_KEY = 'rdf.namespace_manager.store_conf'

Constant for rdf.namespace_manager.store_conf

owmeta_core.data.NAMESPACE_MANAGER_STORE_KEY = 'rdf.namespace_manager.store'

Constant for rdf.namespace_manager.store

owmeta_core.data.SOURCES = {'default': <class 'owmeta_core.data.DefaultSource'>, 'mysql': <class 'owmeta_core.data.MySQLSource'>, 'postgresql': <class 'owmeta_core.data.PostgreSQLSource'>, 'sleepycat': <class 'owmeta_core.data.SleepyCatSource'>, 'sparql_endpoint': <class 'owmeta_core.data.SPARQLSource'>, 'sqlite': <class 'owmeta_core.data.SQLiteSource'>, 'zodb': <class 'owmeta_core.data.ZODBSource'>}

Table of possible sources for rdf.source

owmeta_core.data.TRANSACTION_MANAGER_KEY = 'transaction_manager'

Constant for transaction_manager

owmeta_core.data.TRANSACTION_MANAGER_PROVIDER_KEY = 'transaction_manager.provider'

Constant for transaction_manager.provider