From c229f5c789bb9824672056a96d3c91402a3383c0 Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 11:18:47 +0200 Subject: [PATCH 01/17] Wrong value for format keyword in custom owl ontologies (#150) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Edit values of the format keyword to match rdflib's source code. Authored-by: kysrpex Authored-by: José Manuel Domínguez --- docs/source/owl.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/owl.md b/docs/source/owl.md index 8faf366..1dbe581 100644 --- a/docs/source/owl.md +++ b/docs/source/owl.md @@ -44,9 +44,10 @@ functionality of [Protégé](https://protege.stanford.edu/). **format**: File format of the ontology file to be parsed. We support all the formats that [RDFLib](https://rdflib.readthedocs.io/en/stable/plugin_parsers.html) supports: -XML (`xml`, default), RDF/XML (`rdf+xml`), N3 (`n3`), NTriples (`nt`), -N-Quads (`nquads`), Turtle (`turtle`), TriX (`trix`), -RDFa (`rdfa`, `rdfa1.0`, `rdfa1.1`) and Microdata (`mdata`). +XML (`xml`, `application/rdf+xml`, default), Turtle (`turtle`, `ttl`, +`text/turtle`), N3 (`n3`,`text/n3`), NTriples (`nt`, `nt11`, +`application/n-triples`), N-Quads (`nquads`, `application/n-quads`), +TriX (`trix`, `application/trix`) and TriG (`trig`, `application/trig`). **reference_by_label** (default False): Whether the label should be used or the IRI suffix to reference entity from within OSP-core. In case of EMMO it is true, because IRI suffixes are not From df0cdcca2ebaf9e876f5cb4106774e46beb55c79 Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 11:20:32 +0200 Subject: [PATCH 02/17] Fix caption of figure in overview. (#152) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix wrong caption in `overview.md`. Authored-by: kysrpex Authored-by: José Manuel Domínguez --- docs/source/overview.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/overview.md b/docs/source/overview.md index 10f4691..5dca740 100644 --- a/docs/source/overview.md +++ b/docs/source/overview.md @@ -61,7 +61,7 @@ At this point, the results could be fetched again and for example, visualized wi Exactly in the same way that the data can be moved between a database and a simulation engine using their respective wrappers, it can also be moved between simulation engines. -This functionality facilitates the coupling and linking between such simulation engines. For example, in the domain of materials science, a certain engine might be useful for representing structures made up of atomistic particles (molecular dynamics), while another software tool could be focussed on representing bodies of fluids (fluid dynamics). As SimPhoNy can enable communication between the two tools, they could both be run and synced simultaneously to create more complex scenarios. +This functionality facilitates the coupling and linking between such simulation engines. For example, in the domain of materials science, a certain engine might be useful for representing structures made up of atomistic particles (molecular dynamics), while another software tool could be focussed on representing bodies of fluids (fluid dynamics). As SimPhoNy can enable communication between the two tools, they could both be run and synced simultaneously to create more complex scenarios, such as a multi-scale simulation.
@@ -83,7 +83,9 @@ In order achieve that, it would be necessary to translate the input and output f
-_Coupling of two simulation engines, one that handles free traffic and another that exclusively handles traffic lights._ +_Coupling of two simulation engines, one that handles fluid dynamics +(macroscopic behavior) and another that takes care of molecular dynamics +(microscopic behavior)._
From 25301ded56c4030cae3838bee8898af71026669c Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Tue, 25 May 2021 07:58:15 +0200 Subject: [PATCH 03/17] Fix minor errors (#153) * Apply fixes. Authored-by: pablo-de-andres Authored-by: dea --- docs/source/fundamentals.md | 2 +- docs/source/ontologies_included.md | 1 - docs/source/ontology_intro.md | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/source/fundamentals.md b/docs/source/fundamentals.md index 743826e..6d8fb40 100644 --- a/docs/source/fundamentals.md +++ b/docs/source/fundamentals.md @@ -139,7 +139,7 @@ CUDS, or Common Universal Data Structure, is the ontology compliant data format - **CUDS is an ontology individual**: each CUDS object is an instantiation of a class in the ontology. If we assume a food ontology that describes classes like pizza or pasta, a CUDS object could represent one specific pizza or pasta dish, that exists in the real world. Similar to ontology individuals, CUDS objects can be related with other individuals/CUDS by relations defined in the ontology. Like a _pizza_ that 'hasPart' _tomato sauce_ -- **CUDS is API**: To allow users to interact with the ontology individuals and their data, CUDS provide a CRUD API. +- **CUDS is API**: To allow users to interact with the ontology individuals and their data, CUDS provides a CRUD API. - **CUDS is a container**: Depending on the relationship connecting two CUDS objects, a certain instance can be seen as a container of other instances. We call a relationship that express containment an 'active relationship'. In the pizza example, 'hasPart' would be an 'active relationship'. If one would like to share the pizza CUDS object with others, one would like to share also the tomato sauce. diff --git a/docs/source/ontologies_included.md b/docs/source/ontologies_included.md index 3474e0d..a9d337d 100644 --- a/docs/source/ontologies_included.md +++ b/docs/source/ontologies_included.md @@ -13,7 +13,6 @@ ontology. We used [Ontology2Dot](utils.md#ontology2dot) for that: ![ontology2dot sample image](./_static/img/ontology2dot.png) -eval_rst To use the city ontology you have to install it using the tool [Pico](utils.md#pico-installs-cuds-ontologies): ```sh diff --git a/docs/source/ontology_intro.md b/docs/source/ontology_intro.md index 5957b20..fe6a55d 100644 --- a/docs/source/ontology_intro.md +++ b/docs/source/ontology_intro.md @@ -10,4 +10,4 @@ the representational primitives include information about their meaning and constraints on their logically consistent application. (Source: ) -TODO extend \ No newline at end of file +[//]: # (TODO Extend) From a72db45c19200a19c54a5683241ea0c594e66994 Mon Sep 17 00:00:00 2001 From: kysrpex Date: Tue, 25 May 2021 13:11:28 +0000 Subject: [PATCH 04/17] Create draft PR for #147 From d757c494eb50d75110979e0015fc8597bc61d642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Dom=C3=ADnguez?= Date: Tue, 25 May 2021 15:30:29 +0200 Subject: [PATCH 05/17] Change the way in which the utils API reference is documented (use the __all__ keyword). --- docs/source/api_ref.md | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/docs/source/api_ref.md b/docs/source/api_ref.md index 6fb951f..c5c69e8 100644 --- a/docs/source/api_ref.md +++ b/docs/source/api_ref.md @@ -81,18 +81,7 @@ This document is for developers and/or advanced users of OSP-core, it contains a ## Utilities ```eval_rst -.. autoclass:: osp.core.utils.cuds2dot.Cuds2dot - :members: - -.. automodule:: osp.core.utils.general - :members: - -.. automodule:: osp.core.utils.pretty_print - :members: - -.. automodule:: osp.core.utils.simple_search - :members: - -.. automodule:: osp.core.utils.wrapper_development - :members: +.. automodule:: osp.core.utils + :imported-members: + :members: ``` \ No newline at end of file From a04386ed3562d0f091fc376b5695012b4540b95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Dom=C3=ADnguez?= <43052541+kysrpex@users.noreply.github.com> Date: Tue, 25 May 2021 15:51:20 +0200 Subject: [PATCH 06/17] Freeze jinja2 to version `2.11.2` Freeze jinja2 to version `2.11.2`, otherwise nbsphinx breaks in the docker image (see https://github.com/spatialaudio/nbsphinx/issues/563). --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 285a2ad..1196407 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,4 @@ ipython==7.22.0 jupyter==1.0.0 sphinx-autobuild==2021.3.14 sphinx-panels==0.5.2 +jinja2==2.11.2 From 169fae99d441be7528d7da0a163f0386adb3a617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Dom=C3=ADnguez?= <43052541+kysrpex@users.noreply.github.com> Date: Tue, 25 May 2021 15:54:31 +0200 Subject: [PATCH 07/17] Bump docs version to 2.4.1. --- docs/source/links.md | 3 ++- packageinfo.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/links.md b/docs/source/links.md index 76ac9b7..2f76edc 100644 --- a/docs/source/links.md +++ b/docs/source/links.md @@ -48,7 +48,8 @@ The following table describes the compatibilities between of SimPhoNy docs and O ============= ========== SimPhoNy docs OSP-core ============= ========== - 2.4.x 3.5.2-beta + 2.4.1 3.5.3.1-beta + 2.4.0 3.5.2-beta 2.3.x 3.4.0-beta 2.2.x 3.3.5-beta 2.1.x 3.3.0-beta diff --git a/packageinfo.py b/packageinfo.py index 3c6c186..163873d 100644 --- a/packageinfo.py +++ b/packageinfo.py @@ -1,2 +1,2 @@ NAME = "simphony_docs" -VERSION = "2.4.0" +VERSION = "2.4.1" From a813657714f092dde109417728c36f05c76048b6 Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Fri, 28 May 2021 10:27:59 +0200 Subject: [PATCH 08/17] Add tutorial --- docs/source/index.md | 1 + docs/source/jupyter/import_export.ipynb | 62 +++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 docs/source/jupyter/import_export.ipynb diff --git a/docs/source/index.md b/docs/source/index.md index 68c2045..392fb97 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -81,6 +81,7 @@ SimPhoNy is an ontology-based [open-source](./license.md) Python framework that jupyter/sessions_and_vars.ipynb utils.md jupyter/multiple_wrappers.ipynb + jupyter/import_export.ipynb jupyter/simlammps.ipynb jupyter/quantum_espresso.ipynb diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb new file mode 100644 index 0000000..54edf85 --- /dev/null +++ b/docs/source/jupyter/import_export.ipynb @@ -0,0 +1,62 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "boxed-professional", + "metadata": {}, + "source": [ + "# Tutorial: Import and Export" + ] + }, + { + "cell_type": "markdown", + "id": "operational-honey", + "metadata": {}, + "source": [ + "In this tutorial we will be covering the import and export capabilities of OSP-core. The utility functions that provide these functionalities are `import_cuds` and `export_cuds`, respectively." + ] + }, + { + "cell_type": "markdown", + "id": "qualified-works", + "metadata": {}, + "source": [ + "
\n", + "
**Tip**
\n", + " The full API specifictions of the import and export functions can be found in the [utilities API reference page](../api_ref.md).\n", + "
" + ] + }, + { + "source": [ + "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.ipynb). We first import the necessary entities into our Python code:" + ], + "cell_type": "markdown", + "metadata": {} + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from osp.core.namespaces import city\n", + "from osp.core.utils import import_cuds, export_cuds" + ] + }, + { + "source": [], + "cell_type": "markdown", + "metadata": {} + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file From 1293160d4126de8c1da3bf98208d88cb1e85f1d3 Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Fri, 28 May 2021 10:41:16 +0200 Subject: [PATCH 09/17] Docs for how to query a namespace (#154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Tip inside box: namespaces support IPython autocompletion. * Added sentence: "Namespaces are iterable, so one can print all items in a namespace using list(namespace)". Authored-by: kysrpex Authored-by: José Manuel Domínguez --- docs/source/jupyter/ontology_interface.ipynb | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/source/jupyter/ontology_interface.ipynb b/docs/source/jupyter/ontology_interface.ipynb index 9529d98..8344f62 100644 --- a/docs/source/jupyter/ontology_interface.ipynb +++ b/docs/source/jupyter/ontology_interface.ipynb @@ -201,6 +201,28 @@ "- When the keyword `reference_by_label` is set to `False` (disabled) or not set, the dot notation is a shorthand for fetching by suffix instead. This keyword is **disabled** in the `city` namespace." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To get a list of all the entities available within a namespace, run `list(namespace)`." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "
\n", + "
Tip
\n", + " \n", + "The dot notation supports IPython autocompletion. For example, when working on a Jupyter notebook, once the namespace has been imported, it is possible to get suggestions for the entity names by writing `namespace.` and pressing TAB.\n", + "\n", + "
\n", + "
\n", + "" + ] + }, { "cell_type": "markdown", "metadata": {}, From 69bb19f4e7591dc80b0bb809058106a7c7bed4f0 Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 00:00:39 +0200 Subject: [PATCH 10/17] Finish tutorial --- docs/source/jupyter/import_export.ipynb | 243 ++++++++++++++++++++++-- 1 file changed, 229 insertions(+), 14 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index 54edf85..3da03b4 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -5,7 +5,7 @@ "id": "boxed-professional", "metadata": {}, "source": [ - "# Tutorial: Import and Export" + "# Tutorial: Import and export" ] }, { @@ -22,41 +22,256 @@ "metadata": {}, "source": [ "
\n", - "
**Tip**
\n", - " The full API specifictions of the import and export functions can be found in the [utilities API reference page](../api_ref.md).\n", - "
" + "
Tip
\n", + "The full API specifictions of the import and export functions can be found in the\n", + "[utilities API reference page](../api_ref.md).\n", + "\n", + "\n" ] }, { + "cell_type": "markdown", + "id": "driving-injury", + "metadata": {}, "source": [ - "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.ipynb). We first import the necessary entities into our Python code:" + "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.ipynb). First, let's create a few CUDS objects:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "considered-leonard", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } ], + "source": [ + "from osp.core.namespaces import city\n", + "\n", + "c = city.City(name=\"Freiburg\", coordinates=[47, 7])\n", + "p1 = city.Citizen(name=\"Peter\")\n", + "p2 = city.Citizen(name=\"Anne\")\n", + "c.add(p1, rel=city.hasInhabitant)\n", + "c.add(p2, rel=city.hasInhabitant)" + ] + }, + { "cell_type": "markdown", - "metadata": {} + "id": "worth-province", + "metadata": {}, + "source": [ + "Now we can use the `export_cuds` methods to export the data into a file:" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, + "id": "monthly-anxiety", "metadata": {}, "outputs": [], "source": [ - "from osp.core.namespaces import city\n", - "from osp.core.utils import import_cuds, export_cuds" + "from osp.core.utils import export_cuds\n", + "export_cuds(c, file='./data.ttl', format='turtle')" ] }, { - "source": [], "cell_type": "markdown", - "metadata": {} + "id": "determined-nursing", + "metadata": {}, + "source": [ + "This will create the file `data.ttl` with the following content:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "outstanding-wound", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "@prefix city: .\n", + "@prefix cuba: .\n", + "@prefix rdf: .\n", + "@prefix xsd: .\n", + "\n", + "cuba:_serialization rdf:first \"d886f8ce-1326-40f5-a98b-c4c893b8c085\" .\n", + "\n", + " a city:Citizen ;\n", + " city:INVERSE_OF_hasInhabitant ;\n", + " city:age 25 ;\n", + " city:name \"Anne\" .\n", + "\n", + " a city:Citizen ;\n", + " city:INVERSE_OF_hasInhabitant ;\n", + " city:age 25 ;\n", + " city:name \"Peter\" .\n", + "\n", + " a city:City ;\n", + " city:coordinates \"[47, 7]\"^^ ;\n", + " city:hasInhabitant ,\n", + " ;\n", + " city:name \"Freiburg\" .\n", + "\n" + ] + } + ], + "source": [ + "from sys import platform\n", + "\n", + "if platform == 'win32':\n", + " !more data.ttl\n", + "else:\n", + " !cat data.ttl" + ] + }, + { + "cell_type": "markdown", + "id": "offshore-cotton", + "metadata": {}, + "source": [ + "You can change the format by entering a different value for the parameter `format`. The supported formats are “xml”, “n3”, “turtle”, “nt”, “pretty-xml”, “trix”, “trig” and “nquads”." + ] + }, + { + "cell_type": "markdown", + "id": "derived-advancement", + "metadata": {}, + "source": [ + "To import data, we can use the `import` method. Let's assume we wish to import data into an SQLite session. The following code will help us to achieve our aim:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "stable-session", + "metadata": {}, + "outputs": [], + "source": [ + "from osp.wrappers.sqlite import SqliteSession\n", + "from osp.core.utils import import_cuds\n", + "\n", + "with SqliteSession(\"test.db\") as session:\n", + " wrapper = city.CityWrapper(session=session)\n", + " c = import_cuds('./data.ttl')\n", + " wrapper.add(c)\n", + " session.commit()" + ] + }, + { + "cell_type": "markdown", + "id": "unable-copyright", + "metadata": {}, + "source": [] + }, + { + "cell_type": "markdown", + "id": "higher-short", + "metadata": {}, + "source": [ + "Now we can verify the data was indeed imported:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "suspended-albert", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "- Cuds object:\n", + " uid: 064d9794-a12d-4331-9821-44f0538ed48a\n", + " type: city.CityWrapper\n", + " superclasses: city.CityWrapper, cuba.Entity, cuba.Wrapper\n", + " description: \n", + " To Be Determined\n", + "\n", + " |_Relationship city.hasPart:\n", + " - city.City cuds object named :\n", + " . uid: 72595bc4-1b68-46a3-97e9-8f3de2650f2c\n", + " . coordinates: [47 7]\n", + " . |_Relationship city.hasInhabitant:\n", + " . - city.Citizen cuds object named :\n", + " . . uid: 92a00459-0927-438c-a305-a26512ac7f03\n", + " . . age: 25\n", + " . - city.Citizen cuds object named :\n", + " . uid: 27d1e83b-4ee9-4f4f-adb5-0b01a3cc2c1b\n", + " . age: 25\n", + " - city.City cuds object named :\n", + " uid: d886f8ce-1326-40f5-a98b-c4c893b8c085\n", + " coordinates: [47 7]\n", + " |_Relationship city.hasInhabitant:\n", + " - city.Citizen cuds object named :\n", + " . uid: 2b5d0a3f-81a5-4746-aab9-40adcb65e71f\n", + " . age: 25\n", + " - city.Citizen cuds object named :\n", + " uid: 766b320a-7e9a-43ec-a696-96b4f9ee494d\n", + " age: 25\n" + ] + } + ], + "source": [ + "from osp.core.utils import pretty_print\n", + "\n", + "with SqliteSession(\"test.db\") as session:\n", + " wrapper = city.CityWrapper(session=session)\n", + " pretty_print(wrapper) " + ] + }, + { + "cell_type": "markdown", + "id": "virgin-river", + "metadata": {}, + "source": [ + "
\n", + "
Notes
\n", + " \n", + "1. The format is automatically inferred from the file extension. To specify it explicitly, you can add the `format` paramter, like so: `import_cuds('./data.ttl', format='turtle')`.\n", + "1. The `session` parameter is optional and inferred automatically from the context that created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", + " \n", + "
\n", + "" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.7.4 64-bit", "language": "python", - "name": "python3" + "name": "python37464bit7e5bfc198a4544d1be12f13215aed90d" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + }, + "metadata": { + "interpreter": { + "hash": "301cd6007de04cbbf15bca26f0bc1cb48004d089278091d760363de622bdd0c8" + } } }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} From c3d6a6e1b21aaa78402f2a30792709eac966b940 Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 09:23:01 +0200 Subject: [PATCH 11/17] Remove redundant div tag --- docs/source/jupyter/import_export.ipynb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index 3da03b4..7c61785 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -240,10 +240,8 @@ "
\n", "
Notes
\n", " \n", - "1. The format is automatically inferred from the file extension. To specify it explicitly, you can add the `format` paramter, like so: `import_cuds('./data.ttl', format='turtle')`.\n", + "1. The format is automatically inferred from the file extension. To specify it explicitly, you can add the `format` parameter, like so: `import_cuds('./data.ttl', format='turtle')`.\n", "1. The `session` parameter is optional and inferred automatically from the context that created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", - " \n", - "
\n", "" ] } From 1426d95ab93e4181d9e685aa6c722e92bc6ce9c1 Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 09:31:34 +0200 Subject: [PATCH 12/17] Fix grammar mistake --- docs/source/jupyter/import_export.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index 7c61785..0144227 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -241,7 +241,7 @@ "
Notes
\n", " \n", "1. The format is automatically inferred from the file extension. To specify it explicitly, you can add the `format` parameter, like so: `import_cuds('./data.ttl', format='turtle')`.\n", - "1. The `session` parameter is optional and inferred automatically from the context that created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", + "1. The `session` parameter is optional and inferred automatically from the context that is created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", "" ] } From 9cbc4ad478aa88ad5001ef8b4e25efdb60ffcf6d Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 10:45:58 +0200 Subject: [PATCH 13/17] Add anchor --- docs/source/jupyter/import_export.ipynb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index 0144227..585c636 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -13,6 +13,12 @@ "id": "operational-honey", "metadata": {}, "source": [ + "
\n", + " \n", + "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/simphony/docs/master?filepath=docs%2Fsource%2Fjupyter%2Fimport_export.ipynb \\\"Click to run the tutorial yourself!\\\")\n", + " \n", + "
\n", + "\n", "In this tutorial we will be covering the import and export capabilities of OSP-core. The utility functions that provide these functionalities are `import_cuds` and `export_cuds`, respectively." ] }, @@ -24,7 +30,7 @@ "
\n", "
Tip
\n", "The full API specifictions of the import and export functions can be found in the\n", - "[utilities API reference page](../api_ref.md).\n", + "[utilities API reference page](../api_ref.html#osp.core.utils.export_cuds).\n", "
\n", "\n" ] @@ -34,7 +40,7 @@ "id": "driving-injury", "metadata": {}, "source": [ - "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.ipynb). First, let's create a few CUDS objects:" + "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.html). First, let's create a few CUDS objects:" ] }, { @@ -80,6 +86,7 @@ "outputs": [], "source": [ "from osp.core.utils import export_cuds\n", + "\n", "export_cuds(c, file='./data.ttl', format='turtle')" ] }, @@ -241,7 +248,7 @@ "
Notes
\n", " \n", "1. The format is automatically inferred from the file extension. To specify it explicitly, you can add the `format` parameter, like so: `import_cuds('./data.ttl', format='turtle')`.\n", - "1. The `session` parameter is optional and inferred automatically from the context that is created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", + "1. The `session` parameter is optional and inferred automatically from the context that created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", "" ] } @@ -272,4 +279,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file From 374762030c89af30b49746edc3e81b493b651767 Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 10:57:55 +0200 Subject: [PATCH 14/17] Install city ontology --- docs/source/jupyter/import_export.ipynb | 80 ++++++++++++++++++------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index 585c636..f9c826e 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -30,7 +30,7 @@ "
\n", "
Tip
\n", "The full API specifictions of the import and export functions can be found in the\n", - "[utilities API reference page](../api_ref.html#osp.core.utils.export_cuds).\n", + "[utilities API reference page](../api_ref.md).\n", "
\n", "\n" ] @@ -40,22 +40,52 @@ "id": "driving-injury", "metadata": {}, "source": [ - "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.html). First, let's create a few CUDS objects:" + "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.html#osp.core.utils.export_cuds). First, make sure the city ontology is installed. If not, run the following command:" ] }, { "cell_type": "code", "execution_count": 1, + "id": "decent-affiliation", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO 2021-05-31 10:55:51,839 [osp.core.ontology.installation]: Will install the following namespaces: ['city']\n", + "INFO 2021-05-31 10:55:51,879 [osp.core.ontology.yml.yml_parser]: Parsing YAML ontology file c:\\users\\yoav\\anaconda3\\envs\\osp\\lib\\site-packages\\osp\\core\\ontology\\docs\\city.ontology.yml\n", + "INFO 2021-05-31 10:55:51,995 [osp.core.ontology.yml.yml_parser]: You can now use `from osp.core.namespaces import city`.\n", + "INFO 2021-05-31 10:55:51,996 [osp.core.ontology.parser]: Loaded 7396 ontology triples in total\n", + "INFO 2021-05-31 10:55:52,437 [osp.core.ontology.installation]: Installation successful\n" + ] + } + ], + "source": [ + "!pico install city" + ] + }, + { + "cell_type": "markdown", + "id": "governmental-person", + "metadata": {}, + "source": [ + "Next we create a few CUDS objects:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, "id": "considered-leonard", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -80,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "monthly-anxiety", "metadata": {}, "outputs": [], @@ -100,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "outstanding-wound", "metadata": {}, "outputs": [ @@ -113,22 +143,22 @@ "@prefix rdf: .\n", "@prefix xsd: .\n", "\n", - "cuba:_serialization rdf:first \"d886f8ce-1326-40f5-a98b-c4c893b8c085\" .\n", + "cuba:_serialization rdf:first \"47398674-720b-4765-9047-b5351ed175c0\" .\n", "\n", - " a city:Citizen ;\n", - " city:INVERSE_OF_hasInhabitant ;\n", + " a city:Citizen ;\n", + " city:INVERSE_OF_hasInhabitant ;\n", " city:age 25 ;\n", - " city:name \"Anne\" .\n", + " city:name \"Peter\" .\n", "\n", - " a city:Citizen ;\n", - " city:INVERSE_OF_hasInhabitant ;\n", + " a city:Citizen ;\n", + " city:INVERSE_OF_hasInhabitant ;\n", " city:age 25 ;\n", - " city:name \"Peter\" .\n", + " city:name \"Anne\" .\n", "\n", - " a city:City ;\n", + " a city:City ;\n", " city:coordinates \"[47, 7]\"^^ ;\n", - " city:hasInhabitant ,\n", - " ;\n", + " city:hasInhabitant ,\n", + " ;\n", " city:name \"Freiburg\" .\n", "\n" ] @@ -161,7 +191,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "stable-session", "metadata": {}, "outputs": [], @@ -192,7 +222,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "suspended-albert", "metadata": {}, "outputs": [ @@ -201,7 +231,7 @@ "output_type": "stream", "text": [ "- Cuds object:\n", - " uid: 064d9794-a12d-4331-9821-44f0538ed48a\n", + " uid: 03015cb9-f88c-4ab1-9df9-bb52743b99de\n", " type: city.CityWrapper\n", " superclasses: city.CityWrapper, cuba.Entity, cuba.Wrapper\n", " description: \n", @@ -219,6 +249,16 @@ " . uid: 27d1e83b-4ee9-4f4f-adb5-0b01a3cc2c1b\n", " . age: 25\n", " - city.City cuds object named :\n", + " . uid: 47398674-720b-4765-9047-b5351ed175c0\n", + " . coordinates: [47 7]\n", + " . |_Relationship city.hasInhabitant:\n", + " . - city.Citizen cuds object named :\n", + " . . uid: 98f8ac8c-713d-4406-bc36-e0152f9e2ea3\n", + " . . age: 25\n", + " . - city.Citizen cuds object named :\n", + " . uid: 8a90e2b3-7cca-4103-9eba-aab55e5903b1\n", + " . age: 25\n", + " - city.City cuds object named :\n", " uid: d886f8ce-1326-40f5-a98b-c4c893b8c085\n", " coordinates: [47 7]\n", " |_Relationship city.hasInhabitant:\n", @@ -279,4 +319,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} From ab91873d2ac2d16e0a11a2d4219fb239857b27eb Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 11:10:08 +0200 Subject: [PATCH 15/17] Click links --- docs/source/jupyter/import_export.ipynb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index f9c826e..bb1c6ac 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -15,7 +15,7 @@ "source": [ "
\n", " \n", - "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/simphony/docs/master?filepath=docs%2Fsource%2Fjupyter%2Fimport_export.ipynb \\\"Click to run the tutorial yourself!\\\")\n", + "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/simphony/docs/master?filepath=docs%2Fsource%2Fjupyter%2Fimport_export.ipynb \"Click to run the tutorial yourself!\")\n", " \n", "
\n", "\n", @@ -29,8 +29,10 @@ "source": [ "
\n", "
Tip
\n", + " \n", "The full API specifictions of the import and export functions can be found in the\n", - "[utilities API reference page](../api_ref.md).\n", + "[utilities API reference page](../api_ref.html#osp.core.utils.export_cuds).\n", + " \n", "
\n", "\n" ] @@ -40,13 +42,13 @@ "id": "driving-injury", "metadata": {}, "source": [ - "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.html#osp.core.utils.export_cuds). First, make sure the city ontology is installed. If not, run the following command:" + "For our running example, we'll be using the *city ontology* that was already introduces in the [cuds API tutorial](./cuds_api.html). First, make sure the city ontology is installed. If not, run the following command:" ] }, { "cell_type": "code", "execution_count": 1, - "id": "decent-affiliation", + "id": "dated-determination", "metadata": {}, "outputs": [ { @@ -67,7 +69,7 @@ }, { "cell_type": "markdown", - "id": "governmental-person", + "id": "convenient-century", "metadata": {}, "source": [ "Next we create a few CUDS objects:" @@ -289,8 +291,17 @@ " \n", "1. The format is automatically inferred from the file extension. To specify it explicitly, you can add the `format` parameter, like so: `import_cuds('./data.ttl', format='turtle')`.\n", "1. The `session` parameter is optional and inferred automatically from the context that created by the `with` statement (see the [tutorial on multiple wrappers](./multiple_wrappers.html) for more information). You can specify the session explicitly like so: `import_cuds('./data.ttl', session=session)`.\n", + " \n", "" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "employed-angle", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From 3ff48b8e0b47fcee3c0954433732aedd30ce0193 Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 11:14:22 +0200 Subject: [PATCH 16/17] Remove empty cell --- docs/source/jupyter/import_export.ipynb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index bb1c6ac..89adb74 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -48,7 +48,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "dated-determination", + "id": "dying-accreditation", "metadata": {}, "outputs": [ { @@ -69,7 +69,7 @@ }, { "cell_type": "markdown", - "id": "convenient-century", + "id": "lonely-listening", "metadata": {}, "source": [ "Next we create a few CUDS objects:" @@ -294,14 +294,6 @@ " \n", "" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "employed-angle", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From b9ea5125a3683832f6beeb522a8ed95c0d957e9e Mon Sep 17 00:00:00 2001 From: Yoav Nahshon Date: Mon, 31 May 2021 11:18:23 +0200 Subject: [PATCH 17/17] Remove a redundent cell --- docs/source/jupyter/import_export.ipynb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/source/jupyter/import_export.ipynb b/docs/source/jupyter/import_export.ipynb index 89adb74..f9795e7 100644 --- a/docs/source/jupyter/import_export.ipynb +++ b/docs/source/jupyter/import_export.ipynb @@ -208,12 +208,6 @@ " session.commit()" ] }, - { - "cell_type": "markdown", - "id": "unable-copyright", - "metadata": {}, - "source": [] - }, { "cell_type": "markdown", "id": "higher-short",