Skip to content

Commit d594653

Browse files
author
Ricardo Garcia Silva
authored
Put plugin integration in a more prominent place in docs (geopython#1208)
1 parent f92ca98 commit d594653

File tree

1 file changed

+58
-40
lines changed

1 file changed

+58
-40
lines changed

docs/source/plugins.rst

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The pygeoapi architecture supports the following subsystems:
1818
* data providers
1919
* output formats
2020
* processes
21+
* process manager
2122

2223
The core pygeoapi plugin registry can be found in ``pygeoapi.plugin.PLUGINS``.
2324

@@ -26,6 +27,7 @@ Each plugin type implements its relevant base class as the API contract:
2627
* data providers: ``pygeoapi.provider.base``
2728
* output formats: ``pygeoapi.formatter.base``
2829
* processes: ``pygeoapi.process.base``
30+
* process_manager: ``pygeoapi.process.manager.base``
2931

3032
.. todo:: link PLUGINS to API doc
3133

@@ -38,6 +40,62 @@ pygeoapi for easier maintenance of software updates.
3840
updates and package management
3941

4042

43+
Connecting plugins to pygeoapi
44+
------------------------------
45+
46+
The following methods are options to connect a plugin to pygeoapi:
47+
48+
**Option 1**: implement outside of pygeoapi and add to configuration (recommended)
49+
50+
* Create a Python package with the plugin code (see `Cookiecutter`_ as an example)
51+
* Install this Python package onto your system (``python3 setup.py install``). At this point your new package
52+
should be in the ``PYTHONPATH`` of your pygeoapi installation
53+
* Specify the main plugin class as the ``name`` of the relevant type in the
54+
pygeoapi configuration. For example, for a new vector data provider:
55+
56+
.. code-block:: yaml
57+
58+
providers:
59+
- type: feature
60+
# name may refer to an external Python class, that is loaded by pygeoapi at runtime
61+
name: mycooldatapackage.mycoolvectordata.MyCoolVectorDataProvider
62+
data: /path/to/file
63+
id_field: stn_id
64+
65+
66+
.. note:: The United States Geological Survey has created a Cookiecutter project for creating pygeoapi plugins. See the `pygeoapi-plugin-cookiecutter`_ project to get started.
67+
68+
**Option 2**: Update in core pygeoapi:
69+
70+
* Copy your plugin code into the pygeoapi source code directory - for example, if it is a provider plugin, copy it
71+
to ``pygeoapi/provider``
72+
* Update the plugin registry in ``pygeoapi/plugin.py:PLUGINS['provider']`` with the plugin's
73+
shortname (say ``MyCoolVectorData``) and dotted path to the class (i.e. ``pygeoapi.provider.mycoolvectordata.MyCoolVectorDataProvider``)
74+
* Specify in your dataset provider configuration as follows:
75+
76+
.. code-block:: yaml
77+
78+
providers:
79+
- type: feature
80+
# name may also refer to a known core pygeopai plugin
81+
name: MyCoolVectorData
82+
data: /path/to/file
83+
id_field: stn_id
84+
85+
86+
Customizing pygeoapi process manager
87+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88+
89+
The pygeoapi process manager may also be customized. Similarly to the provider plugins, you may use the pygeoapi
90+
configuration's ``server.manager.name`` to indicate either the dotted path to the python package and the relevant
91+
manager class (*i.e.* similar to option 1 above) or the name of a known core pygeoapi plugin (*i.e.*, similar to
92+
option 2 above).
93+
94+
95+
96+
97+
98+
4199
Example: custom pygeoapi vector data provider
42100
---------------------------------------------
43101

@@ -109,46 +167,6 @@ Each base class documents the functions, arguments and return types required for
109167
.. note:: You can add language support to your plugin using :ref:`these guides<language>`.
110168

111169

112-
Connecting to pygeoapi
113-
^^^^^^^^^^^^^^^^^^^^^^
114-
115-
The following methods are options to connect the plugin to pygeoapi:
116-
117-
**Option 1**: Update in core pygeoapi:
118-
119-
* copy ``mycoolvectordata.py`` into ``pygeoapi/provider``
120-
* update the plugin registry in ``pygeoapi/plugin.py:PLUGINS['provider']`` with the plugin's
121-
shortname (say ``MyCoolVectorData``) and dotted path to the class (i.e. ``pygeoapi.provider.mycoolvectordata.MyCoolVectorDataProvider``)
122-
* specify in your dataset provider configuration as follows:
123-
124-
.. code-block:: yaml
125-
126-
providers:
127-
- type: feature
128-
name: MyCoolVectorData
129-
data: /path/to/file
130-
id_field: stn_id
131-
132-
133-
**Option 2**: implement outside of pygeoapi and add to configuration (recommended)
134-
135-
* create a Python package of the ``mycoolvectordata.py`` module (see `Cookiecutter`_ as an example)
136-
* install your Python package onto your system (``python3 setup.py install``). At this point your new package
137-
should be in the ``PYTHONPATH`` of your pygeoapi installation
138-
* specify in your dataset provider configuration as follows:
139-
140-
.. code-block:: yaml
141-
142-
providers:
143-
- type: feature
144-
name: mycooldatapackage.mycoolvectordata.MyCoolVectorDataProvider
145-
data: /path/to/file
146-
id_field: stn_id
147-
148-
149-
.. note:: The United States Geological Survey has created a Cookiecutter project for creating pygeoapi plugins. See the `pygeoapi-plugin-cookiecutter`_ project to get started.
150-
151-
152170
Example: custom pygeoapi raster data provider
153171
---------------------------------------------
154172

0 commit comments

Comments
 (0)