Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Reason given by maintainers: buggy

RDFLib Ontology LSP

rdflib-ontology-lsp is a Python language server that adds autocomplete for rdflib.Namespace terms in Python files.

If your workspace contains:

from rdflib import Namespace

SKG = Namespace("https://sakuna.ph/")

and an ontology file contains:

@prefix skg: <https://sakuna.ph/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

skg:Person a owl:Class .
skg:hasName a owl:DatatypeProperty .
skg:worksFor a owl:ObjectProperty .

then typing SKG. in a Python file can suggest Person, hasName, and worksFor.

Features

  • Scans Python files for Namespace(...), rdflib.Namespace(...), aliased imports such as from rdflib import Namespace as NS, and simple string constants passed to Namespace(BASE_IRI).
  • Scans ontology files matching **/*.ttl, **/*.owl, **/*.rdf, **/*.nt, and **/*.jsonld.
  • Suggests only ontology local names that are valid Python dot-access identifiers.
  • Includes the ontology type, full IRI, and source file in completion metadata.
  • Shows rdfs:comment or skos:definition text in completion documentation when present.
  • Refreshes the in-memory index when Python or ontology files change.
  • Includes built-in suggestions for RDF, RDFS, SKOS, OWL, PROV-O, and GeoSPARQL namespace imports from RDFLib.

Install

From this repository:

python -m pip install -e ".[dev]"

This installs the server and development test dependency. Runtime dependencies are pygls and rdflib.

Run the Language Server

python -m rdflib_ontology_lsp.server

The server communicates over stdio, which is what the VS Code client uses.

Run Tests

python -m pytest

Example Files

The examples/ directory contains:

  • examples/ontology.ttl
  • examples/example.py

They demonstrate the https://sakuna.ph/ namespace and ontology terms.

VS Code Extension Development

  1. Install the Python server from the repository root:

    python -m pip install -e ".[dev]"
    
  2. Install and build the VS Code client:

    cd vscode-client
    npm install
    npm run compile
    
  3. Open this repository, or vscode-client, in VS Code.

  4. Press F5 to launch an Extension Development Host. The launch config opens this repository in the development host.

  5. Type SKG. in examples/example.py after the detected Namespace("https://sakuna.ph/") assignment.

The client also adds the parent repository src directory to PYTHONPATH for local development, so it can run the server from source.

If suggestions do not appear automatically, run Trigger Suggest in VS Code or press Ctrl+Space after SKG.. Check Output: RDFLib Ontology Autocomplete for the Python executable, server cwd, and workspace scan messages.

Configuration

Default settings:

{
  "rdflibOntologyAutocomplete.ontologyFiles": [
    "**/*.ttl",
    "**/*.owl",
    "**/*.rdf",
    "**/*.nt",
    "**/*.jsonld"
  ],
  "rdflibOntologyAutocomplete.exclude": [
    "**/.venv/**",
    "**/venv/**",
    "**/node_modules/**",
    "**/.git/**"
  ],
  "rdflibOntologyAutocomplete.enableDiagnostics": false,
  "rdflibOntologyAutocomplete.enableStandardVocabularies": true,
  "rdflibOntologyAutocomplete.pythonPath": "",
  "rdflibOntologyAutocomplete.logLevel": "info"
}

Set rdflibOntologyAutocomplete.pythonPath to a Python executable or virtual environment directory if you want the extension to use a specific interpreter. The setting supports ${workspaceFolder}.

Set rdflibOntologyAutocomplete.enableStandardVocabularies to false if you only want suggestions from ontology files in the workspace.

Supported Ontology Types

The scanner indexes subjects with these RDF types:

  • owl:Class
  • rdfs:Class
  • rdf:Property
  • owl:ObjectProperty
  • owl:DatatypeProperty
  • owl:AnnotationProperty

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdflib_ontology_lsp-0.1.0.tar.gz (7.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdflib_ontology_lsp-0.1.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file rdflib_ontology_lsp-0.1.0.tar.gz.

File metadata

  • Download URL: rdflib_ontology_lsp-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rdflib_ontology_lsp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8215ec258f161d8c00614c3a284cebacd6771115f8067c7ca6c5880f2a9ee03a
MD5 0326e0a83d96df963d8d2522b8c4fde8
BLAKE2b-256 8ec1b3c25b41990c1c63279483713898ab5e142461a432f81efea2f42f5219e9

See more details on using hashes here.

File details

Details for the file rdflib_ontology_lsp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rdflib_ontology_lsp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aeec3aa6b32330f81a85f66bcf84333715769078adcb33eb37c8e568f344244b
MD5 d59069591114b7a49fbbf6c260408e80
BLAKE2b-256 08658442fa6542c31e8764840a3419cbabea81416325d3e45108e4a35234917f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page