Skip to content

Commit

Permalink
Polish notes in notebooks on what runs with what (Model / Store) (#37)
Browse files Browse the repository at this point in the history
* Add notes in notebooks on what runs with what (Model / Store)

* Fix some of RdfModel failing tests

* Address reviews
  • Loading branch information
pafonta committed Jul 14, 2020
1 parent 7e4d6c5 commit 1f1c47b
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docs/build
**/.ipynb_checkpoints/*
version.py
examples/notebooks/getting-started/mappings/
examples/notebooks/getting-started/downloaded/
.gitreview
examples/configurations/forge.yml
examples/models/neuroshapes/
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: If you are on Binder, you don't need to execute the follwing command."
"Note: If you are on Binder, you don't need to execute the following command."
]
},
{
Expand Down
16 changes: 12 additions & 4 deletions examples/notebooks/getting-started/02 - Datasets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(associations)"
Expand Down Expand Up @@ -290,7 +292,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(dataset)"
Expand Down Expand Up @@ -410,7 +414,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(dataset)"
Expand Down Expand Up @@ -498,7 +504,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(dataset)"
Expand Down
93 changes: 72 additions & 21 deletions examples/notebooks/getting-started/04 - Querying.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,6 @@
"jane_v1 == jane_v1_tag"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(jane_v1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -240,7 +231,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(resource)"
"resource is None"
]
},
{
Expand All @@ -254,7 +245,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: DemoModel and RdfModel schemas have not been synchronized yet. This section is to be run with RdfModel."
"Note: DemoModel and RdfModel schemas have not been synchronized yet. This section is to be run with RdfModel. Commented lines are for DemoModel."
]
},
{
Expand All @@ -281,6 +272,7 @@
"metadata": {},
"outputs": [],
"source": [
"# association_jane = Resource(type=\"Association\", agent=jane)\n",
"association_jane = Resource(type=\"Dataset\", contribution=jane)"
]
},
Expand All @@ -290,6 +282,7 @@
"metadata": {},
"outputs": [],
"source": [
"# association_john = Resource(type=\"Association\", agent=john)\n",
"association_john = Resource(type=\"Dataset\", contribution=john)"
]
},
Expand All @@ -315,7 +308,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"`Entity` is a known type by the Model, and the `paths` method will load the data structure for the given type. Refer to the `11 - Modeling.ipynb` notebook to learn about Modeling and Types."
"The `paths` method load the data structure for the given type.\n",
"\n",
"Please refer to the [Modeling.ipynb](11%20-%20Modeling.ipynb) notebook to learn about modeling and types."
]
},
{
Expand All @@ -324,6 +319,7 @@
"metadata": {},
"outputs": [],
"source": [
"# p = forge.paths(\"Association\")\n",
"p = forge.paths(\"Dataset\")"
]
},
Expand All @@ -334,12 +330,20 @@
"You have autocompletion on `p` and this can be used to build a search."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: There is a known issue for RdfModel which requires using `p.type.id` instead of `p.type`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# resources = forge.search(p.type == \"Association\")\n",
"resources = forge.search(p.type.id == \"Dataset\", limit=3)"
]
},
Expand Down Expand Up @@ -402,13 +406,21 @@
"You have autocompletion on `p` but also on nested properties like `p.agent`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: There is a known issue for RdfModel which prevents from searching on the name."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"resources = forge.search(p.type.id == \"Dataset\", p.contribution.name == \"John Smith\", limit=3)"
"# resources = forge.search(p.type == \"Association\", p.agent.name == \"John Smith\")\n",
"resources = forge.search(p.type.id == \"Dataset\", p.contribution.type == \"Person\", limit=3)"
]
},
{
Expand All @@ -423,10 +435,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(resources[0])"
"forge.as_dataframe(resources)"
]
},
{
Expand All @@ -435,11 +449,27 @@
"source": [
"## Graph traversing\n",
"\n",
"SPARQL is used to traverse the graph. The user can provide simplified queries: no prefixes, no compacted URIs, nor full URIs is required, only the term (property) available in the Model to the user. Refer to the `11 - Modeling.ipynb` notebook to learn about Templates.\n",
"SPARQL is used as a query language.\n",
"\n",
"A SPARQL query rewriting strategy lets users write simplified queries without using prefix declarations, prefix names or long IRIs. With this strategy, the user could only provides type and property names. For a given entity, these names could be seen in its template.\n",
"\n",
"Please refer to the [Modeling.ipynb](11%20-%20Modeling.ipynb) notebook to learn about templates."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: DemoStore doesn't implement SPARQL operations yet. Please use another store for this section."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: DemoModel and RdfModel schemas have not been synchronized yet. This section is to be run with RdfModel. Commented lines are for DemoModel."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -464,6 +494,7 @@
"metadata": {},
"outputs": [],
"source": [
"# association = Resource(type=\"Association\", agent=[jane, john])\n",
"association = Resource(type=\"Dataset\", contribution=[jane, john])"
]
},
Expand All @@ -479,9 +510,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# forge.template(\"Association\")\n",
"forge.template(\"Dataset\")"
]
},
Expand All @@ -491,11 +525,19 @@
"metadata": {},
"outputs": [],
"source": [
"# query = \"\"\"\n",
"# SELECT ?id ?name\n",
"# WHERE {\n",
"# ?id a Association ;\n",
"# agent ?agent .\n",
"# ?agent name ?name .\n",
"# }\n",
"# \"\"\"\n",
"query = \"\"\"\n",
" SELECT ?x ?name\n",
" SELECT ?id ?name\n",
" WHERE {\n",
" ?x a Dataset ;\n",
" contribution ?contributor .\n",
" ?id a Dataset ;\n",
" contribution ?contributor .\n",
" ?contributor name ?name .\n",
" }\n",
"\"\"\""
Expand Down Expand Up @@ -537,6 +579,15 @@
"type(resources[0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"forge.as_dataframe(resources)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -550,7 +601,7 @@
"metadata": {},
"outputs": [],
"source": [
"forge.sparql(query, debug=True)"
"resources = forge.sparql(query, limit=3, debug=True)"
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions examples/notebooks/getting-started/05 - Versioning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(association)"
Expand Down Expand Up @@ -265,7 +267,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(association)"
Expand Down
4 changes: 3 additions & 1 deletion examples/notebooks/getting-started/07 - DataFrame IO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(john)"
Expand Down
4 changes: 3 additions & 1 deletion examples/notebooks/getting-started/10 - Reshaping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(jane)"
Expand Down
10 changes: 9 additions & 1 deletion examples/notebooks/getting-started/11 - Modeling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@
"### error handling"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: DemoModel and RdfModel schemas have not been synchronized yet. This section is to be run with RdfModel. Commented lines are for DemoModel."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -430,7 +437,8 @@
"metadata": {},
"outputs": [],
"source": [
"resource = Resource(type=\"Entity\", agent=mistake)"
"# resource = Resource(type=\"Association\", agent=mistake)\n",
"resource = Resource(type=\"Dataset\", contribution=mistake)"
]
},
{
Expand Down
11 changes: 9 additions & 2 deletions examples/notebooks/getting-started/12 - Mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
"### basics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: DemoModel and RdfModel schemas have not been synchronized yet. The following cell is to be run with DemoModel."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -262,7 +269,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: RdfModel doesn't implement managed mappings operations yet. Please use another model for this section."
"Note: RdfModel doesn't implement managed mappings operations yet. Please use DemoModel for this section."
]
},
{
Expand Down Expand Up @@ -348,7 +355,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: RdfModel doesn't implement managed mappings operations yet. Please use another model for this section."
"Note: RdfModel doesn't implement managed mappings operations yet. Please use DemoModel for this section."
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion examples/notebooks/getting-started/13 - JSON-LD IO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"pp(forge.as_jsonld(jane))"
Expand Down
Loading

0 comments on commit 1f1c47b

Please sign in to comment.