wikibase-sync
| License |
|
| Build Status |
|
| Coverage |
|
Python library to synchronise data between RDF files and Wikibase instances.
It updates your wikibase instance based on the changes of the RDF ontology.
How to install
You can install it manually from the source code:
git clone https://github.com/weso/wikibase-sync
cd wikibase-sync
python setup.py install
Python 3.7+ is recommended.
Examples
With the following code you can synchronize the modification of two RDF files to a given Wikibase instance:
from wbsync.triplestore import WikibaseAdapter
from wbsync.synchronization import GraphDiffSyncAlgorithm, OntologySynchronizer
mediawiki_api_url='wikibase_api_endpoint'
sparql_endpoint_url='wikibase_sparql_endpoint'
username='wikibase_username'
password='wikibase_password'
adapter = WikibaseAdapter(mediawiki_api_url, sparql_endpoint_url, username, password)
algorithm = GraphDiffSyncAlgorithm()
synchronizer = OntologySynchronizer(algorithm)
source_content = "original rdf content goes here"
target_content = "final rdf content goes here"
ops = synchronizer.synchronize(source_content, target_content)
for op in ops:
res = op.execute(adapter)
if not res.successful:
print(f"Error synchronizing triple: {res.message}")
Leaving the source_content empty will be equivalent to adding the target contents to the Wikibase, while leaving the target_content empty will be equivalent to removing the source_content from the Wikibase if present. Additional examples about synchronizing RDF files with a Wikibase instance can be seen in the Synchronization notebook.
Executing batch operations
There is the possibility of performing batch operations (executing at once all of the statements of a given entity). This type of synchronization will have a better performance at the risk that an invalid statement will cancel the entire batch operation. The following code can be used to execute batch operations:
from wbsync.synchronization.operations import optimize_ops
def execute_batch_synchronization(source_content, target_content, synchronizer, adapter):
ops = synchronizer.synchronize(source_content, target_content)
batch_ops = optimize_ops(ops)
for op in batch_ops:
res = op.execute(adapter)
if not res.successful:
print(f"Error synchronizing triple: {res.message}")
More information about these operations and time gained with them can be explored in the Benchmarks notebook.
Metadata
Release files for wbsync 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wbsync-0.1.4.tar.gz | 13.9 kB | Without provenance | Details for wbsync-0.1.4.tar.gz |
Release files / wbsync-0.1.4.tar.gz
| Download URL | wbsync-0.1.4.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0371c62d571a7158095e08a0565a9507241bf929aef48dd57443ccbb13c86355
|
|
BLAKE2b-256 checksum How to use checksums |
8c7a2aaafdce186021df220acce8990784b1860e56a4b26b8efe41cef3b5bfb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.0
|
Security for wbsync 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.