KTBS built-in method implementations

Implementation of the built-in methods shipped with kTBS.

Interface

I define the interface of a method implementation.

class ktbs.methods.interface.IMethod[source]

I define the interface of a method implementation.

compute_trace_description(computed_trace)[source]

I set the computed properties (model, origin) of the given trace

Parameters:computed_trace – a engine.trace.ComputedTrace
Return type:rdfrest.util.Diagnosis

The returned diagnosis must be non-empty if the model and/or the origin could not be set, or if it is predicatable that compute_obsels will fail. It can be non-empty in other situations, but the message should then make it clear that it is a mere warning (rather than an error).

Note also that after this method is called, compute_obsels() is expected to start afresh.

compute_obsels(computed_trace, from_scratch=False)[source]

I update the obsels of the given computed trace

Parameters:
  • computed_trace – a engine.trace.ComputedTrace
  • from_scratch – force a complete recalculation, regardless of the state of the sources
Return type:

rdfrest.util.Diagnosis

Filter

Implementation of the filter builtin methods.

Fusion

Implementation of the fusion builtin methods.

FSA

Implementation of the fsa builtin methods.

ktbs.methods.fsa.match_obseltype(transition, event, token, fsa)[source]

The ‘obseltype’ matcher.

With this matcher, transition conditions are interpreted as obseltype URIs.

ktbs.methods.fsa.match_sparql_ask(transition, event, token, fsa)[source]

The ‘sparql-ask’ matcher.

With this matcher, transition conditions are interpreted as the WHERE clause of a SPARQL Ask query, where variable ?obs is bound to the considered obsel, and prefix m: is bound to the source trace URI.

SPARQL

Implementation of the sparql builtin methods.

External

Implementation of the external builtin methods.

IMPORTANT: this method allows kTBS users to run arbitrary commands on the server, with the priviledges of the user running kTBS. Therefore, it is mostly intended for single-user localhost instances of kTBS.

ktbs.plugins.meth_external.start_plugin(_config)[source]

I get the configuration values from the main kTBS configuration.

Note

This function is called automatically by the kTBS. It is called once when the kTBS starts, not at each request.

Utilities for implementing method

Utility functions for method implementations.

ktbs.methods.utils.replace_obsels(computed_trace, raw_graph, inherit=False)[source]

Replace the @obsels graph of computed_trace with raw_graph.

If raw_graph contains blank obsels, a URI will be generated for them. Except for that, no processing or verification is done on raw_graph, so it must be valid.

ktbs.methods.utils.translate_node(node, transformed_trace, src_uri, multiple_sources, prevent=None)[source]

If node is a URI, translate its URI to put it in transfored_trace. Else, leave it unchanged.

ktbs.methods.utils.copy_obsel(obsel_uri, computed_trace, source_trace, new_obs_uri=None, check_new_obs=None)[source]

I prepare a graph for an transformed obsel being a copy of obsel.