diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 438e344..aa887ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 2f49a6f..9c1e015 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Link the virtual environment to a IPython kernel: Use the `here-search-notebooks` script with your HERE API Key: ``` - API_KEY="your API key" here-search-notebooks + API_KEY="your API key" python -m jupyterlab src/here_search/demo/notebooks ``` (Additional [notes][2]) diff --git a/docs/developers.md b/docs/developers.md index 6d7b7fe..015cd15 100644 --- a/docs/developers.md +++ b/docs/developers.md @@ -45,6 +45,12 @@ To update the package version, use `bumpver`. For instance: (...) ``` +Push your change through a branch PR. +Then on your local main branch, after a rebase from origin, do a `bumpver update --patch`. +Finally, "Draft a new release" and choose the new tag you just created with `bumpver`. +The creation of a new release should trigger the release to pypi workflow. + + ### Test on MacOS / python3.7 1. Build Python 3.7.9 for `pyenv` @@ -109,7 +115,7 @@ To test the JupyterLite page locally, run in a virtualenv : tar xpfz $(find . -name "*.tar.gz") - $(find . -name "lite-run.sh") + $(find src -name "lite-run.sh") ``` #### Clear your browser cache diff --git a/pyproject.toml b/pyproject.toml index 36a7944..303286f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,14 @@ +# Copyright (C) 2019-2024 HERE Global B.V. and its affiliate(s). +# All rights reserved. +# +# This software and other materials contain proprietary information +# controlled by HERE and are protected by applicable copyright legislation. +# Any use and utilization of this software and other materials and +# disclosure to any third parties is conditional upon having a separate +# agreement with HERE for the access, use, utilization or disclosure of this +# software. In the absence of such agreement, the use of the software is not +# allowed. + [build-system] requires = [ "setuptools>=42", @@ -5,6 +16,52 @@ requires = [ ] build-backend = "setuptools.build_meta" +[project] +name = "here-search-demo" +version = "0.9.1" +description = "HERE Geocoding and Search demo and widgets" +readme = "README.md" +authors = [ {name = "HERE Global B.V. and its affiliate(s)", email = "590094+decitre@users.noreply.github.com"} ] +license = {text = "The MIT License"} +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Scientific/Engineering :: GIS", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dynamic = ["dependencies"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements/build.txt"]} + +[project.urls] +homepage = "https://here.com" +repository = "ssh://git@github.com:heremaps/here-search-demo.git" + +[project.optional-dependencies] +lab = [ + "aiohttp", + "xyzservices" +] + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src"] + [tool.bumpver] current_version = "0.9.1" version_pattern = "MAJOR.MINOR.PATCH" @@ -15,11 +72,9 @@ push = true [tool.bumpver.file_patterns] "pyproject.toml" = [ + 'version = "{version}"', 'current_version = "{version}"', ] -"src/here_search/demo/__init__.py" = [ - '^__version__ = "{version}"$' -] "src/here_search/demo/notebooks/*.ipynb" = [ 'here_search_demo-{version}-py3-none-any.whl' ] diff --git a/requirements/build.txt b/requirements/build.txt index 56b6adc..038d7c9 100644 --- a/requirements/build.txt +++ b/requirements/build.txt @@ -1,9 +1,10 @@ -jupyterlab>=3.5.2,<4 -jupyterlab_widgets>=1.1.1 -jupyterlab-filesystem-access>=0.5.3 -jupyterlite~=0.1.2 -ipywidgets>=8,<9 -ipyleaflet==0.17.3 -jupyterlite-core==0.1.2 -jupyterlite-pyodide-kernel==0.1.1 +ipyleaflet==0.19.1 +ipywidgets==8.1.3 +jupyterlab +jupyterlab_widgets +jupyterlab-filesystem-access +jupyterlite~=0.3.0 +jupyterlite-core +jupyterlite-pyodide-kernel +jupyterlite-javascript-kernel libarchive-c diff --git a/requirements/util.txt b/requirements/util.txt index ec39c26..49541cc 100644 --- a/requirements/util.txt +++ b/requirements/util.txt @@ -1,4 +1,2 @@ -wheel -build bumpver -twine \ No newline at end of file +pur \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2b4fe89..0000000 --- a/setup.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[metadata] -name = here-search-demo -version = attr: here_search.demo.__version__ -author = HERE Europe B.V. -author_email = emmanuel.decitre@here.com -url = https://here.com -home_page = https://github.com/heremaps/here-search-demo -description = HERE Geocoding and Search demo and widgets -long_description = file: README.md -long_description_content_type = text/markdown -license = The MIT License -license_files = - LICENSE -keywords = HERE, Search, Ipywidgets, GS7 -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - License :: OSI Approved :: MIT License -project_urls = - Bug Tracker = https://github.com/heremaps/here-search-demo/issues - Source = https://github.com/heremaps/here-search-demo - -[options] -zip_safe = False -python_requires = >=3.8 -package_dir = - = src -scripts = - src/here_search/demo/scripts/here-search-notebooks - src/here_search/demo/scripts/lite-run.sh -install_requires = file: requirements/build.txt - -[options.packages.find] -where = src - -[options.package_data] -here_search.demo.notebooks = - *.ipynb -* = - requirements/*.txt; setup.py; setup.cfg; pyproject.toml - -[options.extras_require] -lab = aiohttp; xyzservices \ No newline at end of file diff --git a/src/here_search/demo/notebooks/demo.ipynb b/src/here_search/demo/notebooks/demo.ipynb index aa63ea6..055a78f 100644 --- a/src/here_search/demo/notebooks/demo.ipynb +++ b/src/here_search/demo/notebooks/demo.ipynb @@ -1,116 +1,144 @@ { - "metadata": { - "celltoolbar": "Slideshow", - "toc-autonumbering": false, - "toc-showcode": false, - "toc-showmarkdowntxt": false, - "kernelspec": { - "name": "python", - "display_name": "Python (Pyodide)", - "language": "python" - }, - "language_info": { - "codemirror_mode": { - "name": "python", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8" - } + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "717d9c13-684f-4ef9-8045-09624217caeb", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"\"" + ] }, - "nbformat_minor": 5, - "nbformat": 4, - "cells": [ - { - "cell_type": "code", - "source": "try:\n import piplite\n await piplite.install([\"ipywidgets==8.1.0\", \"ipyleaflet==0.17.3\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n api_key = \"\"\nexcept ImportError:\n api_key = None", - "metadata": { - "tags": [], - "trusted": true - }, - "execution_count": 1, - "outputs": [], - "id": "717d9c13-684f-4ef9-8045-09624217caeb" - }, - { - "cell_type": "markdown", - "source": "# OneBoxMap\n\n`OneBoxMap` is a demo application showing how [HERE Geocoding and Search](https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html) following endpoints are meant to be used: `/autosuggest`, `/discover`, `/browse`, `/lookup`.", - "metadata": { - "slideshow": { - "slide_type": "slide" - }, - "tags": [] - }, - "id": "712c9ba7-62a7-4795-9a5e-7cdfb320bb1c" - }, - { - "cell_type": "code", - "source": "from here_search.demo.widgets.app import OneBoxMap\napp = OneBoxMap(api_key=api_key)\napp.run()", - "metadata": { - "slideshow": { - "slide_type": "-" - }, - "tags": [], - "trusted": true - }, - "execution_count": 2, - "outputs": [ - { - "output_type": "display_data", - "data": { - "text/plain": "HTML(value='')", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "22bd278b42354b4aa1bcec94c4562995" - } - }, - "metadata": {} - }, - { - "execution_count": 2, - "output_type": "execute_result", - "data": { - "text/plain": "OneBoxMap(children=(HBox(children=(ResponseMap(center=[52.51604, 13.37691], controls=(AttributionControl(optio…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "3f7dcd63cc594d079f01bba55c697c45" - } - }, - "metadata": {} - } - ], - "id": "54d57978-5cc6-40f1-aeda-04f49656b719" - }, - { - "cell_type": "code", - "source": "if False: # change to True to deleted the app resources\n app.__del__()", - "metadata": { - "tags": [], - "trusted": true - }, - "execution_count": 3, - "outputs": [], - "id": "691e81e5-064c-44ee-b3df-8e5f18f8f31f" + { + "cell_type": "code", + "execution_count": null, + "id": "aa427bf6-ac98-4553-9c6c-20df3f044a63", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import piplite\n", + " await piplite.install([\"ipywidgets==8.1.3\", \"ipyleaflet==0.19.1\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", + "except ImportError:\n", + " pass" + ] + }, + { + "cell_type": "markdown", + "id": "712c9ba7-62a7-4795-9a5e-7cdfb320bb1c", + "metadata": { + "slideshow": { + "slide_type": "slide" }, - { - "cell_type": "markdown", - "source": "Features:\n\n- The app \n - proposes a single text form to formulate queries\n - displays three buttons with predicted last token text completions\n - displays all API calls in a separate window\n - displays search results on a map and a list\n - supports location-aware language preferences\n
\n- `/autosuggest` endpoint is called for each key-stroke.\n - Follow-up query suggestions are displayed in the list only\n - Location suggestions are displayed in the list and on the map\n - Query term suggestions are displayed in three buttons\n - Selected locations lead to a call to `/lookup` using the location record `id`.\n - Selected query suggestions lead to call to a http GET using the response `href` value\n
\n- `/discover` endpoint is called when a query submission is validated.\n - Validation happens when the [return] key or the button are hit\n - Location results are displayed in the list and on the map\n - Selected results lead to a call to `/lookup` using the location record `id`.\n- `/browse` endpoint is called when a place taxonomy button is selected.\n - Location results are displayed in the list and on the map\n - Selected results lead to a call to `/lookup` using the location record `id`.\n
\n- `/autosuggest`, `/discover` and `/browse` requests are sent using the map center as search center\n- Search requests are cached during the lifetime of the application\n\n\n", - "metadata": {}, - "id": "9924f7b8-e3e2-44ac-9ce2-dfca00211104" + "tags": [] + }, + "source": [ + "# OneBoxMap\n", + "\n", + "`OneBoxMap` is a demo application showing how [HERE Geocoding and Search](https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html) following endpoints are meant to be used: `/autosuggest`, `/discover`, `/browse`, `/lookup`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "54d57978-5cc6-40f1-aeda-04f49656b719", + "metadata": { + "slideshow": { + "slide_type": "-" }, - { - "cell_type": "code", - "source": "", - "metadata": {}, - "execution_count": null, - "outputs": [], - "id": "f36fb223-235c-4aaa-8fc1-066423a0fc72" - } - ] -} \ No newline at end of file + "tags": [] + }, + "outputs": [], + "source": [ + "from here_search.demo.widgets.app import OneBoxMap\n", + "app = OneBoxMap(api_key=api_key)\n", + "app.run()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "691e81e5-064c-44ee-b3df-8e5f18f8f31f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "if False: # change to True to delete the app resources\n", + " app.__del__()" + ] + }, + { + "cell_type": "markdown", + "id": "9924f7b8-e3e2-44ac-9ce2-dfca00211104", + "metadata": {}, + "source": [ + "Features:\n", + "\n", + "- The app \n", + " - proposes a single text form to formulate queries\n", + " - displays three buttons with predicted last token text completions\n", + " - displays all API calls in a separate window\n", + " - displays search results on a map and a list\n", + " - supports location-aware language preferences\n", + "
\n", + "- `/autosuggest` endpoint is called for each key-stroke.\n", + " - Follow-up query suggestions are displayed in the list only\n", + " - Location suggestions are displayed in the list and on the map\n", + " - Query term suggestions are displayed in three buttons\n", + " - Selected locations lead to a call to `/lookup` using the location record `id`.\n", + " - Selected query suggestions lead to call to a http GET using the response `href` value\n", + "
\n", + "- `/discover` endpoint is called when a query submission is validated.\n", + " - Validation happens when the [return] key or the button are hit\n", + " - Location results are displayed in the list and on the map\n", + " - Selected results lead to a call to `/lookup` using the location record `id`.\n", + "- `/browse` endpoint is called when a place taxonomy button is selected.\n", + " - Location results are displayed in the list and on the map\n", + " - Selected results lead to a call to `/lookup` using the location record `id`.\n", + "
\n", + "- `/autosuggest`, `/discover` and `/browse` requests are sent using the map center as search center\n", + "- Search requests are cached during the lifetime of the application\n", + "\n", + "\n", + "" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f36fb223-235c-4aaa-8fc1-066423a0fc72", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "celltoolbar": "Slideshow", + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.11.7" + }, + "toc-autonumbering": false, + "toc-showcode": false, + "toc-showmarkdowntxt": false + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/here_search/demo/notebooks/obm_1_api.ipynb b/src/here_search/demo/notebooks/obm_1_api.ipynb index 6e70291..20410d7 100644 --- a/src/here_search/demo/notebooks/obm_1_api.ipynb +++ b/src/here_search/demo/notebooks/obm_1_api.ipynb @@ -2,17 +2,26 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, + "id": "2dc1e80e-8ebd-4392-bbdc-36fb61511bfb", + "metadata": {}, + "outputs": [], + "source": [ + "api_key = \"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "e5c95683-6b47-40aa-8dba-1c815e1549c3", "metadata": {}, "outputs": [], "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"ipywidgets==8.1.0\", \"ipyleaflet==0.17.3\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", - " api_key = \"\"\n", + " await piplite.install([\"ipywidgets==8.1.3\", \"ipyleaflet==0.19.1\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", "except ImportError:\n", - " api_key = None" + " pass" ] }, { @@ -36,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "a59dacb1-da0a-40ba-a8d0-736738c62333", "metadata": { "pycharm": { @@ -65,21 +74,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "da673fdb-baf9-41e0-9f32-b8e18436a579", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://discover.search.hereapi.com/v1/discover?q=berlin&at=52%2C13&apiKey=...'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp = await api.discover(q=\"berlin\", latitude=52, longitude=13, session=session)\n", "resp.req.full" @@ -87,61 +85,20 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "7ece78d9-5061-4493-a0ad-904f3c7d8aa6", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'items': [{'title': 'Berlin, Deutschland',\n", - " 'id': 'here:cm:namedplace:20187403',\n", - " 'language': 'de',\n", - " 'resultType': 'locality',\n", - " 'localityType': 'city',\n", - " 'address': {'label': 'Berlin, Deutschland',\n", - " 'countryCode': 'DEU',\n", - " 'countryName': 'Deutschland',\n", - " 'stateCode': 'BE',\n", - " 'state': 'Berlin',\n", - " 'countyCode': 'B',\n", - " 'county': 'Berlin',\n", - " 'city': 'Berlin',\n", - " 'postalCode': '10117'},\n", - " 'position': {'lat': 52.51604, 'lng': 13.37691},\n", - " 'distance': 62854,\n", - " 'mapView': {'west': 13.08835,\n", - " 'south': 52.33812,\n", - " 'east': 13.761,\n", - " 'north': 52.6755}}]}" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp.data" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "f7d46007-3a25-4f10-90fe-e3fd0f6c4cc6", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://autosuggest.search.hereapi.com/v1/autosuggest?q=restaura&at=52%2C13&limit=2&termsLimit=3&apiKey=...'" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp = await api.autosuggest(q=\"restaura\", latitude=52, longitude=13, limit=2, termsLimit=3, session=session)\n", "resp.req.full" @@ -149,88 +106,30 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "7ebe5c74-9469-4593-99db-f8ded06d25ac", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'items': [{'title': 'Restaurant',\n", - " 'id': 'here:cm:ontology:restaurant',\n", - " 'resultType': 'categoryQuery',\n", - " 'href': 'https://autosuggest.search.hereapi.com/v1/discover?limit=2&at=52%2C13&q=Restaurant&_ontology=restaurant',\n", - " 'highlights': {'title': [{'start': 0, 'end': 8}]}},\n", - " {'title': 'Das Kleine Café',\n", - " 'id': 'here:pds:place:276u31pz-3708ef13d164429e8861b8480c28a8a2',\n", - " 'ontologyId': 'here:cm:ontology:restaurant',\n", - " 'resultType': 'place',\n", - " 'address': {'label': 'Das Kleine Café, Treuenbrietzener Straße 18, 14913 Niedergörsdorf, Deutschland'},\n", - " 'position': {'lat': 52.01537, 'lng': 12.99675},\n", - " 'access': [{'lat': 52.0155, 'lng': 12.99691}],\n", - " 'distance': 1723,\n", - " 'categories': [{'id': '100-1000-0000',\n", - " 'name': 'Restaurant',\n", - " 'primary': True},\n", - " {'id': '100-1100-0000', 'name': 'Kaffee/Tee'},\n", - " {'id': '100-1100-0010', 'name': 'Kaffeehaus'}],\n", - " 'highlights': {'title': [], 'address': {'label': []}}}],\n", - " 'queryTerms': [{'term': 'Restaurant',\n", - " 'replaces': 'restaura',\n", - " 'start': 0,\n", - " 'end': 8}]}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp.data" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "9fa03844-4584-4b2a-ae93-9742450ae76e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['Restaurant']" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp.terms" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "a5772d87-0cba-4c84-8aa4-acf7e726a40a", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'type': 'FeatureCollection',\n", - " 'features': [{'type': 'Feature',\n", - " 'geometry': {'type': 'Point', 'coordinates': [12.99675, 52.01537]},\n", - " 'properties': {'title': 'Das Kleine Café', 'categories': 'Restaurant'}}]}" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp.geojson()" ] @@ -253,54 +152,10 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "5db1262c-1815-44a2-a9be-c67377ca58f8", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# query resultType id title \n", - "\n", - "1 'r' administrativeArea here:cm:namedplace:20181414 Regensburg (Landkreis) (R), Bavaria, Germany\n", - "\n", - "2 're' locality here:cm:namedplace:20180814 Regensburg, Bavaria, Germany\n", - "\n", - "3 'res' place here:pds:place:276u31cx-e4c2ca2261114bf6a060240e539aeb76 Königstein Fortress (Restauration Festung)\n", - "\n", - "4 'rest' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "5 'resta' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "6 'restau' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "7 'restaur' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "8 'restaura' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "9 'restauran' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "10 'restaurant' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "11 'restaurant ' categoryQuery here:cm:ontology:restaurant Restaurant \n", - "\n", - "12 'restaurant h' place here:pds:place:276u33db-cc50ca74bc7e4e19a646a85abd9ca9ee Adlon Kempinski Berlin (Hotel Adlon Kempinski)\n", - "\n", - "13 'restaurant ha' place here:pds:place:276u30vw-9aa75f80605e4281ae9bb7b985e5c633 Gasthof Hammermuhle (Restaurant Hammermühle)\n", - "\n", - "14 'restaurant ham' place here:pds:place:276u30vw-9aa75f80605e4281ae9bb7b985e5c633 Gasthof Hammermuhle (Restaurant Hammermühle)\n", - "\n", - "15 'restaurant hamb' categoryQuery here:cm:ontology:restaurant-here:cm:namedplace:20151516 Restaurant near Hamburg, Germany\n", - "\n", - "16 'restaurant hambu' categoryQuery here:cm:ontology:restaurant-here:cm:namedplace:20151516 Restaurant near Hamburg, Germany\n", - "\n", - "17 'restaurant hambur' categoryQuery here:cm:ontology:restaurant-here:cm:namedplace:20151516 Restaurant near Hamburg, Germany\n", - "\n", - "18 'restaurant hamburg' categoryQuery here:cm:ontology:restaurant-here:cm:namedplace:20151516 Restaurant near Hamburg, Germany\n" - ] - } - ], + "outputs": [], "source": [ "q = \"restaurant hamburg\"\n", "\n", @@ -326,54 +181,10 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "b8a9bc0d-6725-4edb-9de3-9ada83312246", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# query terms title \n", - "\n", - "1 'r' Regensburg (Landkreis) (R), Bavaria, Germany\n", - "\n", - "2 're' Regensburg Regensburg, Bavaria, Germany\n", - "\n", - "3 'res' Restauration,Restaurant,Resort Königstein Fortress (Restauration Festung)\n", - "\n", - "4 'rest' Restaurant Restaurant \n", - "\n", - "5 'resta' Restaurant Restaurant \n", - "\n", - "6 'restau' Restaurant Restaurant \n", - "\n", - "7 'restaur' Restaurant Restaurant \n", - "\n", - "8 'restaura' Restaurant Restaurant \n", - "\n", - "9 'restauran' Restaurant Restaurant \n", - "\n", - "10 'restaurant' Restaurant \n", - "\n", - "11 'restaurant ' Restaurant \n", - "\n", - "12 'restaurant h' Hotel ,Hanover,Hopfingerbräu Adlon Kempinski Berlin (Hotel Adlon Kempinski)\n", - "\n", - "13 'restaurant ha' Hammermühle,Havelgarten,Hafthorn Gasthof Hammermuhle (Restaurant Hammermühle)\n", - "\n", - "14 'restaurant ham' Hammermühle,Hamburg,Hammers Gasthof Hammermuhle (Restaurant Hammermühle)\n", - "\n", - "15 'restaurant hamb' Hamburg,Hamburger ,Hambacher Restaurant near Hamburg, Germany\n", - "\n", - "16 'restaurant hambu' Hamburg,Hamburger ,Hamburger Restaurant near Hamburg, Germany\n", - "\n", - "17 'restaurant hambur' Hamburg,Hamburger ,Hamburger Restaurant near Hamburg, Germany\n", - "\n", - "18 'restaurant hamburg' Restaurant near Hamburg, Germany\n" - ] - } - ], + "outputs": [], "source": [ "template = \"{:<2} {:<25} {:<38} {:<14}\"\n", "print(template.format(\"#\", \"query\", \"terms\", \"title\"))\n", @@ -394,34 +205,10 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "aa5203d6-686a-4e16-9126-78ddc6f32cd6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# query terms title \n", - "\n", - "1 'r' Regensburg (Landkreis) (R), Bavaria, Germany\n", - "\n", - "2 're' Regensburg Regensburg, Bavaria, Germany\n", - "\n", - "3 'res' Restauration,Restaurant,Resort Königstein Fortress (Restauration Festung)\n", - "\n", - "4 'restaurant' Restaurant \n", - "\n", - "5 'restaurant ' Restaurant \n", - "\n", - "6 'restaurant h' Hotel ,Hanover,Hopfingerbräu Adlon Kempinski Berlin (Hotel Adlon Kempinski)\n", - "\n", - "7 'restaurant ha' Hammermühle,Havelgarten,Hafthorn Gasthof Hammermuhle (Restaurant Hammermühle)\n", - "\n", - "8 'restaurant hamburg' Restaurant near Hamburg, Germany\n" - ] - } - ], + "outputs": [], "source": [ "template = \"{:<2} {:<25} {:<38} {:<14}\"\n", "print(template.format(\"#\", \"query\", \"terms\", \"title\"))\n", @@ -445,9 +232,9 @@ "metadata": { "celltoolbar": "Slideshow", "kernelspec": { - "display_name": "search demo", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "search_demo" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -459,7 +246,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/src/here_search/demo/notebooks/obm_2_api.ipynb b/src/here_search/demo/notebooks/obm_2_api.ipynb index 40a8e3a..4d1bb83 100644 --- a/src/here_search/demo/notebooks/obm_2_api.ipynb +++ b/src/here_search/demo/notebooks/obm_2_api.ipynb @@ -2,17 +2,26 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, + "id": "64bf56e2-271d-4717-ae11-28e7405981ba", + "metadata": {}, + "outputs": [], + "source": [ + "api_key = \"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "77ac7de0-8ebc-4686-87bf-a9e720cc79e4", "metadata": {}, "outputs": [], "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"ipywidgets==8.1.0\", \"ipyleaflet==0.17.3\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", - " api_key = \"\"\n", + " await piplite.install([\"ipywidgets==8.1.3\", \"ipyleaflet==0.19.1\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", "except ImportError:\n", - " api_key = None" + " pass" ] }, { @@ -37,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "a59dacb1-da0a-40ba-a8d0-736738c62333", "metadata": { "pycharm": { @@ -48,18 +57,7 @@ }, "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://browse.search.hereapi.com/v1/browse?at=52%2C13&categories=700-7600-0000%2C700-7600-0116%2C700-7600-0444&limit=4&apiKey=...'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from here_search.demo.api import API, HTTPSession\n", "\n", @@ -72,21 +70,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "da673fdb-baf9-41e0-9f32-b8e18436a579", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['ARAL', 'TOTAL', 'Raiffeisen', 'Shell']" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp.titles" ] @@ -101,148 +88,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "5db1262c-1815-44a2-a9be-c67377ca58f8", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
class PlaceTaxonomyExample:\n",
-       "    items, icons = zip(\n",
-       "        *[\n",
-       "            #                --------------------------------------------------------------------\n",
-       "            #                | item name | categories     | food types | chains  | icon         |\n",
-       "            #                --------------------------------------------------------------------\n",
-       "            (PlaceTaxonomyItem("gas", ["700-7600-0000", "700-7600-0116", "700-7600-0444"], None, None), "fa-gas-pump"),\n",
-       "            (PlaceTaxonomyItem("eat", ["100"], None, None), "fa-utensils"),\n",
-       "            (PlaceTaxonomyItem("sleep", ["500-5000"], None, None), "fa-bed"),\n",
-       "            (PlaceTaxonomyItem("park", ["400-4300", "800-8500"], None, None), "fa-parking"),\n",
-       "            (PlaceTaxonomyItem("ATM", ["700-7010-0108"], None, None), "fa-euro-sign"),\n",
-       "            (PlaceTaxonomyItem("pizza", None, ["800-057"], None), "fa-pizza-slice"),\n",
-       "            (PlaceTaxonomyItem("fastfood", None, None, ["1566", "1498"]), "fa-hamburger"),\n",
-       "        ]\n",
-       "    )\n",
-       "    taxonomy = PlaceTaxonomy("example", items)\n",
-       "
\n" - ], - "text/latex": [ - "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\\PY{k}{class} \\PY{n}{PlaceTaxonomyExample:}\n", - " \\PY{n}{items}, \\PY{n}{icons} = \\PY{n+nb}{zip}(\n", - " *[\n", - " \\PY{c+c1}{\\PYZsh{} \\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}}\n", - " \\PY{c+c1}{\\PYZsh{} | item name | categories | food types | chains | icon |}\n", - " \\PY{c+c1}{\\PYZsh{} \\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}\\PYZhy{}}\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}gas\\PYZdq{}}, [\\PY{l+s}{\\PYZdq{}700\\PYZhy{}7600\\PYZhy{}0000\\PYZdq{}}, \\PY{l+s}{\\PYZdq{}700\\PYZhy{}7600\\PYZhy{}0116\\PYZdq{}}, \\PY{l+s}{\\PYZdq{}700\\PYZhy{}7600\\PYZhy{}0444\\PYZdq{}}], \\PY{n}{None}, \\PY{n}{None}), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}gas\\PYZhy{}pump\\PYZdq{}}),\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}eat\\PYZdq{}}, [\\PY{l+s}{\\PYZdq{}100\\PYZdq{}}], \\PY{n}{None}, \\PY{n}{None}), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}utensils\\PYZdq{}}),\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}sleep\\PYZdq{}}, [\\PY{l+s}{\\PYZdq{}500\\PYZhy{}5000\\PYZdq{}}], \\PY{n}{None}, \\PY{n}{None}), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}bed\\PYZdq{}}),\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}park\\PYZdq{}}, [\\PY{l+s}{\\PYZdq{}400\\PYZhy{}4300\\PYZdq{}}, \\PY{l+s}{\\PYZdq{}800\\PYZhy{}8500\\PYZdq{}}], \\PY{n}{None}, \\PY{n}{None}), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}parking\\PYZdq{}}),\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}ATM\\PYZdq{}}, [\\PY{l+s}{\\PYZdq{}700\\PYZhy{}7010\\PYZhy{}0108\\PYZdq{}}], \\PY{n}{None}, \\PY{n}{None}), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}euro\\PYZhy{}sign\\PYZdq{}}),\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}pizza\\PYZdq{}}, \\PY{n}{None}, [\\PY{l+s}{\\PYZdq{}800\\PYZhy{}057\\PYZdq{}}], \\PY{n}{None}), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}pizza\\PYZhy{}slice\\PYZdq{}}),\n", - " (\\PY{n}{PlaceTaxonomyItem}(\\PY{l+s}{\\PYZdq{}fastfood\\PYZdq{}}, \\PY{n}{None}, \\PY{n}{None}, [\\PY{l+s}{\\PYZdq{}1566\\PYZdq{}}, \\PY{l+s}{\\PYZdq{}1498\\PYZdq{}}]), \\PY{l+s}{\\PYZdq{}fa\\PYZhy{}hamburger\\PYZdq{}}),\n", - " ]\n", - " )\n", - " \\PY{n}{taxonomy} = \\PY{n}{PlaceTaxonomy}(\\PY{l+s}{\\PYZdq{}example\\PYZdq{}}, \\PY{n}{items})\n", - "\\end{Verbatim}\n" - ], - "text/plain": [ - "class PlaceTaxonomyExample:\n", - " items, icons = zip(\n", - " *[\n", - " # --------------------------------------------------------------------\n", - " # | item name | categories | food types | chains | icon |\n", - " # --------------------------------------------------------------------\n", - " (PlaceTaxonomyItem(\"gas\", [\"700-7600-0000\", \"700-7600-0116\", \"700-7600-0444\"], None, None), \"fa-gas-pump\"),\n", - " (PlaceTaxonomyItem(\"eat\", [\"100\"], None, None), \"fa-utensils\"),\n", - " (PlaceTaxonomyItem(\"sleep\", [\"500-5000\"], None, None), \"fa-bed\"),\n", - " (PlaceTaxonomyItem(\"park\", [\"400-4300\", \"800-8500\"], None, None), \"fa-parking\"),\n", - " (PlaceTaxonomyItem(\"ATM\", [\"700-7010-0108\"], None, None), \"fa-euro-sign\"),\n", - " (PlaceTaxonomyItem(\"pizza\", None, [\"800-057\"], None), \"fa-pizza-slice\"),\n", - " (PlaceTaxonomyItem(\"fastfood\", None, None, [\"1566\", \"1498\"]), \"fa-hamburger\"),\n", - " ]\n", - " )\n", - " taxonomy = PlaceTaxonomy(\"example\", items)" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from here_search.demo.entity.place import PlaceTaxonomyExample\n", "from inspect import getsource\n", @@ -253,30 +102,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "58c87605-eb8f-49eb-b9b8-b8e839610290", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://browse.search.hereapi.com/v1/browse?at=52%2C13&foodTypes=800-057&limit=4&apiKey=...'" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "['Super Pizza', 'Il-Mulino-Due', 'Wasserpfeifchen', 'First Grill']" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "resp = await api.browse(latitude=52, longitude=13, limit=4, **PlaceTaxonomyExample.taxonomy.pizza.mapping, session=session)\n", "display(resp.req.full)\n", @@ -295,21 +124,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "b8a9bc0d-6725-4edb-9de3-9ada83312246", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Response(req=Request(endpoint=, url='https://revgeocode.search.hereapi.com/v1/revgeocode', params={'at': '52,13', 'limit': 1, 'apiKey': '...'}, x_headers=None), data={'items': [{'title': 'Niedergörsdorfer Allee, 14913 Niedergörsdorf, Deutschland', 'id': 'here:af:streetsection:.GSuwaNujk32oWouTtr19D', 'resultType': 'street', 'address': {'label': 'Niedergörsdorfer Allee, 14913 Niedergörsdorf, Deutschland', 'countryCode': 'DEU', 'countryName': 'Deutschland', 'stateCode': 'BB', 'state': 'Brandenburg', 'countyCode': 'TF', 'county': 'Teltow-Fläming', 'city': 'Niedergörsdorf', 'street': 'Niedergörsdorfer Allee', 'postalCode': '14913'}, 'position': {'lat': 52.00028, 'lng': 13.00166}, 'distance': 118, 'mapView': {'west': 13.00058, 'south': 51.98972, 'east': 13.00786, 'north': 52.00263}}]}, x_headers={'X-Request-Id': 'REQ-67940aeb-1198-4114-b574-32db7da10df1', 'X-Correlation-ID': '0e5596dd-c381-4f46-9e8c-d5c3d2578106'})" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from here_search.demo.entity.request import Endpoint, Request, Response\n", "from here_search.demo.api import base_url\n", @@ -330,9 +148,9 @@ "metadata": { "celltoolbar": "Slideshow", "kernelspec": { - "display_name": "search demo", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "search_demo" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -344,7 +162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/src/here_search/demo/notebooks/obm_3_widget.ipynb b/src/here_search/demo/notebooks/obm_3_widget.ipynb index f424896..806acad 100644 --- a/src/here_search/demo/notebooks/obm_3_widget.ipynb +++ b/src/here_search/demo/notebooks/obm_3_widget.ipynb @@ -2,26 +2,28 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, + "id": "5ba4b386-72d5-402b-8dde-d1fdc41c93d6", + "metadata": {}, + "outputs": [], + "source": [ + "api_key = \"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "f4878c23-f9ec-4756-b085-bdccf7d726d8", "metadata": { - "execution": { - "iopub.execute_input": "2023-08-27T12:29:46.153090Z", - "iopub.status.busy": "2023-08-27T12:29:46.152762Z", - "iopub.status.idle": "2023-08-27T12:29:46.161516Z", - "shell.execute_reply": "2023-08-27T12:29:46.160588Z", - "shell.execute_reply.started": "2023-08-27T12:29:46.153058Z" - }, "tags": [] }, "outputs": [], "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"ipywidgets==8.1.0\", \"ipyleaflet==0.17.3\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", - " api_key = \"\"\n", + " await piplite.install([\"ipywidgets==8.1.3\", \"ipyleaflet==0.19.1\", \"emfs:here_search_demo-0.9.1-py3-none-any.whl\"], keep_going=True)\n", "except ImportError:\n", - " api_key = None" + " pass" ] }, { @@ -274,9 +276,9 @@ "metadata": { "celltoolbar": "Slideshow", "kernelspec": { - "display_name": "search demo", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "search_demo" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -288,7 +290,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/src/here_search/demo/scripts/here-search-notebooks b/src/here_search/demo/scripts/here-search-notebooks deleted file mode 100755 index aa6d5ad..0000000 --- a/src/here_search/demo/scripts/here-search-notebooks +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# -# Copyright (c) 2023 HERE Europe B.V. -# -# SPDX-License-Identifier: MIT -# License-Filename: LICENSE -# -############################################################################### - -(cd $(cat << eof | python - -import here_search.demo as hd, pathlib, os.path -print(pathlib.Path(os.path.dirname(hd.__file__), 'notebooks')) -eof -); jupyter lab) \ No newline at end of file