Derivation Client
PyDerivationClient ¶
PyDerivationClient(derivation_instance_base_url: str, query_endpoint: str, update_endpoint: str, kg_user: str = None, kg_password: str = None)
This is a wrapper class for the java class uk.ac.cam.cares.jps.base.derivation.DerivationClient
.
Only the methods that commonly used are wrapped here. For other methods, one may access them via
self.derivation_client.nameOfJavaMethod(args)
.
Attributes:
Name | Type | Description |
---|---|---|
derivation_client |
The Java DerivationClient object |
|
jpsBaseLib_view |
The JVM module view for accessing Java classes |
Methods:
Name | Description |
---|---|
createDerivation |
Create a normal derivation markup. |
createSyncDerivationForNewInfo |
Create a synchronous derivation for new info to be computed by the agent. |
createSyncDerivationForNewInfoWithHttpUrl |
Create a synchronous derivation for new info to be computed by the agent with the agent URL provided. |
bulkCreateDerivations |
Create multiple normal derivations in one go. |
createDerivationWithTimeSeries |
Create a time series derivation markup. |
bulkCreateDerivationsWithTimeSeries |
Create multiple time series derivations in one go. |
createAsyncDerivation |
Create an asynchronous derivation markup. |
createAsyncDerivationFromDerivation |
Create an asynchronous derivation markup from an existing derivation. |
bulkCreateAsyncDerivations |
Create multiple asynchronous derivations in one go. |
createAsyncDerivationForNewInfo |
Create an asynchronous derivation markup for new information. |
bulkCreateAsyncDerivationsForNewInfo |
Create multiple asynchronous derivations for new information in one go. |
validateDerivations |
Validate all derivations and their inputs are attached with timestamps, also no circular dependencies. |
createOntoAgentInstance |
Register an OntoAgent instance in the triple store. |
addTimeInstance |
Add a time instance to each entity in the list of entities. |
addTimeInstanceCurrentTimestamp |
Add time instance with current timestamp to the given entities. |
updateTimestamp |
Update the timestamp of the entity to the current time. |
updateTimestamps |
Update the timestamp of all entities in the list. |
dropTimestampsOf |
Drop the timestamp of the given entities. |
getDerivations |
Get the derivations of the given agent. |
getDerivationsOf |
Get the derivations of the given entities. |
unifiedUpdateDerivation |
Unified update derivation method. |
updatePureSyncDerivation |
Update a single synchronous derivation. |
updatePureSyncDerivations |
Update a list of synchronous derivations. |
updatePureSyncDerivationsInParallel |
Update a list of synchronous derivations in parallel. |
updateAllSyncDerivations |
Update all synchronous derivations within the knowledge graph. |
updateMixedAsyncDerivation |
Update a directed acyclic graph of a-/sync derivations. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
derivation_instance_base_url
|
str
|
base url of the derivation instance to be created by the client |
required |
query_endpoint
|
str
|
query endpoint of the knowledge graph |
required |
update_endpoint
|
str
|
update endpoint of the knowledge graph |
required |
kg_user
|
str
|
username for the knowledge graph endpoint. Defaults to None. |
None
|
kg_password
|
str
|
password for the knowledge graph endpoint. Defaults to None. |
None
|
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createDerivation ¶
Create a normal derivation markup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entities
|
List[str]
|
List of entities that belongsTo the derivation |
required |
agentIRI
|
str
|
List of agents that the derivation isDerivedUsing |
required |
inputs
|
List[str]
|
List of inputs that the derivation isDerivedFrom |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
IRI of the created derivation |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createSyncDerivationForNewInfo ¶
createSyncDerivationForNewInfo(agentIRI: str, inputsIRI: List[str], derivationType: str) -> Derivation
Create a sync derivation for new info to be computed by the agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agentIRI
|
str
|
IRI of the agent that the derivation isDerivedUsing |
required |
inputsIRI
|
List[str]
|
List of inputs that the derivation isDerivedFrom |
required |
derivationType
|
str
|
IRI of the synchronous derivation type to be created |
required |
Returns:
Name | Type | Description |
---|---|---|
Derivation |
Derivation
|
Object of the created derivation |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createSyncDerivationForNewInfoWithHttpUrl ¶
createSyncDerivationForNewInfoWithHttpUrl(agentIRI: str, agentURL: str, inputsIRI: List[str], derivationType: str) -> Derivation
Create a sync derivation for new info to be computed by the agent with the agent url provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agentIRI
|
str
|
IRI of the agent that the derivation isDerivedUsing |
required |
agentURL
|
str
|
HTTP URL of the agent that the derivation isDerivedUsing |
required |
inputsIRI
|
List[str]
|
List of inputs that the derivation isDerivedFrom |
required |
derivationType
|
str
|
IRI of the synchronous derivation type to be created |
required |
Returns:
Name | Type | Description |
---|---|---|
Derivation |
Derivation
|
Object of the created derivation |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
bulkCreateDerivations ¶
bulkCreateDerivations(entitiesList: List[List[str]], agentIRIList: List[str], inputsList: List[List[str]]) -> List[str]
Create multiple normal derivations in one go.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entitiesList
|
List[List[str]]
|
List of list of entities that belongsTo the derivations |
required |
agentIRIList
|
List[str]
|
List of agents that the derivations isDerivedUsing |
required |
inputsList
|
List[List[str]]
|
List of list of inputs that the derivations isDerivedFrom |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of IRIs of the created derivations |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createDerivationWithTimeSeries ¶
Create a time series derivation markup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entities
|
List[str]
|
List of entities that belongsTo the derivation |
required |
agentIRI
|
str
|
IRI of the agent that the derivation isDerivedUsing |
required |
inputs
|
List[str]
|
List of inputs that the derivation isDerivedFrom |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
IRI of the created time series derivation |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
bulkCreateDerivationsWithTimeSeries ¶
bulkCreateDerivationsWithTimeSeries(entitiesList: List[List[str]], agentIRIList: List[str], inputsList: List[List[str]]) -> List[str]
Create multiple time series derivations in one go.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entitiesList
|
List[List[str]]
|
List of list of entities that belongsTo the derivations |
required |
agentIRIList
|
List[str]
|
List of agents that the derivations isDerivedUsing |
required |
inputsList
|
List[List[str]]
|
List of list of inputs that the derivations isDerivedFrom |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of IRIs of the created time series derivations |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createAsyncDerivation ¶
createAsyncDerivation(entities: List[str], agentIRI: str, inputs: List[str], forUpdate: bool) -> str
Create an asynchronous derivation markup. If forUpdate
is True, the derivation will be marked as "Requested"
with a timestamp of 0. Otherwise, the derivation will be marked without status but with a current timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entities
|
List[str]
|
List of entities that belongsTo the derivation |
required |
agentIRI
|
str
|
IRI of the agent that the derivation isDerivedUsing |
required |
inputs
|
List[str]
|
List of inputs that the derivation isDerivedFrom |
required |
forUpdate
|
bool
|
Boolean flag to indicate if the derivation markup is for update |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
IRI of the created asynchronous derivation |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createAsyncDerivationFromDerivation ¶
createAsyncDerivationFromDerivation(entities: List[str], agentIRI: str, derivation: str, forUpdate: bool) -> str
Create an asynchronous derivation markup from an existing derivation. If forUpdate
is True, the derivation
will be marked as "Requested" with a timestamp of 0. Otherwise, the derivation will be marked without status but
with a current timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entities
|
List[str]
|
List of entities that belongsTo the derivation |
required |
agentIRI
|
str
|
IRI of the agent that the derivation isDerivedUsing |
required |
derivation
|
str
|
IRI of an existing derivation whose outputs the new derivation isDerivedFrom |
required |
forUpdate
|
bool
|
Boolean flag to indicate if the derivation markup is for update |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
IRI of the created asynchronous derivation |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
bulkCreateAsyncDerivations ¶
bulkCreateAsyncDerivations(entitiesList: List[List[str]], agentIRIList: List[str], inputsList: List[List[str]], forUpdateFlagList: List[bool]) -> List[str]
Create multiple asynchronous derivations in one go. If the flag in forUpdateFlagList
is True, the corresponding
derivation will be marked as "Requested" with a timestamp of 0. Otherwise, the derivation will be marked without
status but with a current timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entitiesList
|
List[List[str]]
|
List of list of entities that belongsTo the derivations |
required |
agentIRIList
|
List[str]
|
List of agents that the derivations isDerivedUsing |
required |
inputsList
|
List[List[str]]
|
List of list of inputs that the derivations isDerivedFrom |
required |
forUpdateFlagList
|
List[bool]
|
List of boolean flags to indicate if the derivation markup is for update |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of IRIs of the created asynchronous derivations |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createAsyncDerivationForNewInfo ¶
Create an asynchronous derivation markup for new information. The derivation will be marked as "Requested" with
a timestamp of 0. The outputs of the derivation will be computed by the agent in due course. Note that all IRIs in
the inputsAndDerivations
list will be directly connected to the derivation as its inputs. Therefore, existing IRIs
of the derivation outputs should be provided if applicable, instead of the IRI of that derivation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agentIRI
|
str
|
IRI of the agent that the derivation isDerivedUsing |
required |
inputsAndDerivations
|
List[str]
|
List of inputs and derivations that the derivation isDerivedFrom |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
IRI of the created asynchronous derivation for new information |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
bulkCreateAsyncDerivationsForNewInfo ¶
bulkCreateAsyncDerivationsForNewInfo(agentIRIList: List[str], inputsAndDerivationsList: List[List[str]]) -> List[str]
Create multiple asynchronous derivations for new information in one go. The derivations will be marked as
"Requested" with a timestamp of 0. The outputs of the derivations will be computed by the agents in due course.
Note that all IRIs in the inputsAndDerivationsList
list will be directly connected to the derivations as their
inputs. Therefore, existing IRIs of the derivation outputs should be provided if applicable, instead of the IRI
of that derivation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agentIRIList
|
List[str]
|
List of agents that the derivations isDerivedUsing |
required |
inputsAndDerivationsList
|
List[List[str]]
|
List of list of inputs and derivations that the derivations isDerivedFrom |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of IRIs of the created asynchronous derivations for new information |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
validateDerivations ¶
validateDerivations() -> bool
This checks for any circular dependency and ensures that all the linked inputs have a suitable timestamp attached. NOTE however, this method does not check for everything, e.g. instances having appropriate rdf:types, and the agent design.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Whether the created derivations are valid, i.e. no circular dependency, timestamps correctly attached |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
createOntoAgentInstance ¶
createOntoAgentInstance(ontoAgentServiceIRI: str, ontoAgentOperationHttpUrl: str, inputTypes: List[str], outputTypes: List[str])
Register an OntoAgent instance in the triple store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ontoAgentServiceIRI
|
str
|
IRI of the agent's OntoAgent:Service |
required |
ontoAgentOperationHttpUrl
|
str
|
IRI of the agent's operation HTTP URL |
required |
inputTypes
|
List[str]
|
List of IRI of the agent's input types |
required |
outputTypes
|
List[str]
|
List of IRI of the agent's output types |
required |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
addTimeInstance ¶
addTimeInstanceCurrentTimestamp ¶
updateTimestamp ¶
updateTimestamp(entity: str)
Update the timestamp of the entity to the current time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity
|
str
|
IRI of the entity to update the timestamp of |
required |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
updateTimestamps ¶
dropTimestampsOf ¶
getDerivations ¶
Get the derivations of the given agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agentIRI
|
str
|
IRI of the agent |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
List[str]
|
List of IRIs of the derivations that isDerivedUsing the given agent |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
getDerivationsOf ¶
Get the derivations of the given entities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entities
|
List[str]
|
List of entities |
required |
Returns:
Type | Description |
---|---|
Dict[str, str]
|
Dict[str, str]: The dictionary with the entity IRIs as keys and the derivation IRIs as values |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
unifiedUpdateDerivation ¶
unifiedUpdateDerivation(derivationIRI: str)
Unified update derivation method. This methods updates the specified derivation and all its upstream derivations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
derivationIRI
|
str
|
IRI of the derivation to be updated |
required |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
updatePureSyncDerivation ¶
updatePureSyncDerivation(derivationIRI: str)
Update the specified synchronous derivation and all its upstream derivations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
derivationIRI
|
str
|
IRI of the derivation to be updated |
required |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
updatePureSyncDerivations ¶
Update the specified list of synchronous derivations and all their upstream derivations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
derivationIRIs
|
List[str]
|
List of IRIs of the derivations to be updated |
required |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
updatePureSyncDerivationsInParallel ¶
Update the specified list of synchronous derivations and all their upstream derivations in parallel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
derivationIRIs
|
List[str]
|
List of IRIs of the derivations to be updated |
required |
Source code in JPS_BASE_LIB/python_wrapper/twa/kg_operations/derivation_client.py
updateAllSyncDerivations ¶
Update all synchronous derivations in the knowledge graph.
updateMixedAsyncDerivation ¶
updateMixedAsyncDerivation(derivationIRI: str)
Update a directed acyclic graph (DAG) of pure asynchronous derivations or asynchronous derivations depending on synchronous derivations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
derivationIRI
|
str
|
IRI of the derivation to be updated |
required |