Skip to content

Commit 2f47b56

Browse files
committed
Improve doc
1 parent 96b29d0 commit 2f47b56

File tree

4 files changed

+64
-47
lines changed

4 files changed

+64
-47
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Template expansion is typically zero-copy and nearly instantaneous, and the buil
88
maplib is written in Rust, it is built on [Apache Arrow](https://arrow.apache.org/) using [Pola.rs](https://www.pola.rs/) and uses libraries from [Oxigraph](https://github.com/oxigraph/oxigraph) for handling linked data as well as parsing SPARQL queries.
99

1010
## Installing
11-
The package is published on [PyPi](https://pypi.org/project/maplib/) and the API documented [here](https://datatreehouse.github.io/maplib/maplib/maplib.html):
11+
The package is published on [PyPi](https://pypi.org/project/maplib/) and the API documented [here](https://datatreehouse.github.io/maplib/maplib.html):
1212
```shell
1313
pip install maplib
1414
```
@@ -142,15 +142,15 @@ Indeed, we have added the triple:
142142
| "<https://github.com/DataTreehouse/maplib/pizza#Hawaiian>" |
143143

144144
## API
145-
The [API](https://datatreehouse.github.io/maplib/maplib/maplib.html) is simple, and contains only one class and a few methods for:
145+
The [API](https://datatreehouse.github.io/maplib/maplib.html) is simple, and contains only one class and a few methods for:
146146
- expanding templates
147147
- querying with SPARQL
148148
- validating with SHACL
149149
- importing triples (Turtle, RDF/XML, NTriples)
150150
- writing triples (Turtle, RDF/XML, NTriples)
151151
- creating a new Mapping object (sprout) based on queries over the current Mapping object.
152152

153-
The API is documented [HERE](https://datatreehouse.github.io/maplib/maplib/maplib.html)
153+
The API is documented [HERE](https://datatreehouse.github.io/maplib/maplib.html)
154154

155155
## Roadmap of features and optimizations
156156
Spring 2025

py_maplib/maplib/__init__.py

+49-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
1-
import pathlib
1+
r'''
2+
# Overview
3+
4+
'''
25

6+
__all__ = [
7+
"Mapping",
8+
"a",
9+
"Triple",
10+
"SolutionMappings",
11+
"IndexingOptions",
12+
"Instance",
13+
"Template",
14+
"Argument",
15+
"Variable",
16+
"RDFType",
17+
"XSD",
18+
"IRI",
19+
"BlankNode",
20+
"explore",
21+
"add_triples"]
22+
23+
import pathlib
324
from .maplib import *
425
from .add_triples import add_triples
526

6-
PATH_HERE = pathlib.Path(__file__).parent.resolve()
7-
8-
if (PATH_HERE / "graph_explorer").exists():
27+
if (pathlib.Path(__file__).parent.resolve() / "graph_explorer").exists():
928
from .graph_explorer import explore
29+
else:
30+
async def explore(
31+
m: "Mapping",
32+
host: str = "localhost",
33+
port: int = 8000,
34+
bind: str = "localhost",
35+
popup=True,
36+
fts=True,
37+
):
38+
"""Starts a graph explorer session.
39+
To run from Jupyter Notebook use:
40+
>>> from maplib import explore
41+
>>>
42+
>>> await explore(m)
43+
44+
This will block further execution of the notebook until you stop the cell.
45+
46+
:param m: The Mapping to explore
47+
:param host: The hostname that we will point the browser to.
48+
:param port: The port where the graph explorer webserver listens on.
49+
:param bind: Bind to the following host / ip.
50+
:param popup: Pop up the browser window.
51+
:param fts: Enable full text search indexing
52+
"""
53+
print("Contact Data Treehouse to try!")
54+

py_maplib/maplib/maplib.pyi renamed to py_maplib/maplib/__init__.pyi

+4-39
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from typing import Union, List, Dict, Optional, Callable, Tuple, Literal as Lite
33
from polars import DataFrame
44
from datetime import datetime, date
55

6+
67
class RDFType:
78
"""
89
The type of a column containing a RDF variable.
@@ -670,7 +671,7 @@ class Mapping:
670671
def create_sprout(self):
671672
"""
672673
A sprout is a simplified way of dealing with multiple graphs.
673-
See also `maplib.maplib.Mapping.insert_sprout` and `maplib.maplib.Mapping.detach_sprout`
674+
See also `Mapping.insert_sprout` and `Mapping.detach_sprout`
674675
675676
:return:
676677
"""
@@ -692,7 +693,7 @@ class Mapping:
692693
Insert the results of a Construct query in a sprouted graph, which is created if no sprout is active.
693694
Sprouts are simplified way of dealing with multiple graphs.
694695
Useful for being able to use the same query for inspecting what will be inserted and actually inserting.
695-
See also `maplib.maplib.Mapping.detach_sprout`
696+
See also `Mapping.detach_sprout`
696697
697698
Usage:
698699
@@ -726,7 +727,7 @@ class Mapping:
726727
"""
727728
Detaches and returns the sprout from the mapping.
728729
729-
@return: The sprout as its own Mapping.
730+
:return: The sprout as its own Mapping.
730731
"""
731732

732733
def get_predicate_iris(
@@ -757,39 +758,3 @@ class Mapping:
757758
:param graph: The graph where indexes should be added
758759
:return:
759760
"""
760-
761-
async def explore(
762-
m: Mapping,
763-
host: str = "localhost",
764-
port: int = 8000,
765-
bind: str = "localhost",
766-
popup=True,
767-
fts=True,):
768-
"""
769-
Starts a graph explorer session.
770-
To run from Jupyter Notebook use:
771-
>>> from maplib import explore
772-
>>>
773-
>>> await explore(m)
774-
775-
This will block further execution of the notebook until you stop the cell.
776-
777-
:param m: The Mapping to explore
778-
:param host: The hostname that we will point the browser to.
779-
:param port: The port where the graph explorer webserver listens on.
780-
:param bind: Bind to the following host / ip.
781-
:param popup: Pop up the browser window.
782-
:param fts: Enable full text search indexing
783-
"""
784-
785-
def add_triples(
786-
source: Mapping, target: Mapping, source_graph: str = None, target_graph: str = None
787-
):
788-
"""
789-
(Zeroy) copy the triples from one Mapping into another.
790-
791-
:param source: The source mapping
792-
:param target: The target mapping
793-
:param source_graph: The named graph in the source mapping to copy from. None means default graph.
794-
:param target_graph: The named graph in the target mapping to copy into. None means default graph.
795-
"""

py_maplib/maplib/add_triples.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
from maplib import Mapping, Template, IRI, Triple, Variable
1+
from maplib.maplib import Mapping, Template, IRI, Triple, Variable
22

33

44
def add_triples(
55
source: Mapping, target: Mapping, source_graph: str = None, target_graph: str = None
66
):
7+
"""(Zero) copy the triples from one Mapping into another.
8+
9+
:param source: The source mapping
10+
:param target: The target mapping
11+
:param source_graph: The named graph in the source mapping to copy from. None means default graph.
12+
:param target_graph: The named graph in the target mapping to copy into. None means default graph.
13+
"""
714
for p in source.get_predicate_iris(source_graph):
815
subject = Variable("subject")
916
object = Variable("object")

0 commit comments

Comments
 (0)