|
1 |
| -"""WPSClient Class. |
| 1 | +# noqa: D205, D400 |
| 2 | +""" |
| 3 | +WPSClient Class |
| 4 | +=============== |
2 | 5 |
|
3 |
| -The :class:`WPSClient` class aims to make working with WPS servers easy, |
4 |
| -even without any prior knowledge of WPS. |
| 6 | +The :class:`WPSClient` class aims to make working with WPS servers easy, even without any prior knowledge of WPS. |
5 | 7 |
|
6 |
| -Calling the :class:`WPSClient` class creates an instance whose methods call |
7 |
| -WPS processes. These methods are generated at runtime based on the |
8 |
| -process description provided by the WPS server. Calling a function sends |
9 |
| -an `execute` request to the server. The server response is parsed and |
10 |
| -returned as a :class:`WPSExecution` instance, which includes information |
11 |
| -about the job status, the progress percentage, the starting time, etc. The |
12 |
| -actual output from the process are obtained by calling the `get` method. |
| 8 | +Calling the :class:`WPSClient` class creates an instance whose methods call WPS processes. |
| 9 | +These methods are generated at runtime based on the process description provided by the WPS server. |
| 10 | +Calling a function sends an `execute` request to the server. The server response is parsed and |
| 11 | +returned as a :class:`WPSExecution` instance, which includes information about the job status, the progress percentage, |
| 12 | +the starting time, etc. The actual output from the process are obtained by calling the `get` method. |
13 | 13 |
|
14 | 14 | The output is parsed to convert the outputs in native Python whenever possible.
|
15 |
| -`LiteralOutput` objects (string, float, integer, boolean) are automatically |
16 |
| -converted to their native format. For `ComplexOutput`, the module can either |
17 |
| -return a link to the output files stored on the server, or try to |
18 |
| -convert the outputs to a Python object based on their mime type. This conversion |
19 |
| -will occur with `get(asobj=True)`. So for example, if the mime type is |
20 |
| -'application/json', the output would be a `dict`. |
21 |
| -
|
22 |
| -Inputs to processes can be native Python types (string, float, int, date, datetime), |
23 |
| -http links or local files. Local files can be transferred to a remote server by |
24 |
| -including their content into the WPS request. Simply set the input to a valid path |
25 |
| -or file object and the client will take care of reading and converting the file. |
| 15 | +`LiteralOutput` objects (string, float, integer, boolean) are automatically converted to their native format. |
| 16 | +For `ComplexOutput`, the module can either return a link to the output files stored on the server, |
| 17 | +or try to convert the outputs to a Python object based on their mime type. This conversion will occur with |
| 18 | +`get(asobj=True)`. So for example, if the mime type is 'application/json', the output would be a `dict`. |
26 | 19 |
|
| 20 | +Inputs to processes can be native Python types (string, float, int, date, datetime), http links or local files. |
| 21 | +Local files can be transferred to a remote server by including their content into the WPS request. |
| 22 | +Simply set the input to a valid path or file object and the client will take care of reading and converting the file. |
27 | 23 |
|
28 | 24 | Example
|
29 | 25 | -------
|
|
55 | 51 |
|
56 | 52 | Authentication
|
57 | 53 | --------------
|
58 |
| -If you want to connect to a server that requires authentication, the |
59 |
| -:class:`WPSClient` class accepts an `auth` argument that |
60 |
| -behaves exactly like in the popular `requests` module |
61 |
| -(see `requests Authentication`_) |
| 54 | +If you want to connect to a server that requires authentication, the :class:`WPSClient` class accepts |
| 55 | +an `auth` argument that behaves exactly like in the popular `requests` module (see `requests Authentication`_) |
62 | 56 |
|
63 | 57 | The simplest form of authentication is HTTP Basic Auth. Although
|
64 | 58 | wps processes are not commonly protected by this authentication method,
|
|
69 | 63 | >>> auth = HTTPBasicAuth('user', 'pass')
|
70 | 64 | >>> wps = WPSClient('http://www.example.com/wps', auth=auth)
|
71 | 65 |
|
72 |
| -Because any `requests`-compatible class is accepted, custom |
73 |
| -authentication methods are implemented the same way as in `requests`. |
| 66 | +Because any `requests`-compatible class is accepted, custom authentication methods are implemented |
| 67 | +the same way as in `requests`. |
74 | 68 |
|
75 |
| -For example, to connect to a magpie_ protected wps, you can use the |
76 |
| -requests-magpie_ module:: |
| 69 | +For example, to connect to a magpie_ protected wps, you can use the requests-magpie_ module:: |
77 | 70 |
|
78 | 71 | >>> from birdy import WPSClient
|
79 | 72 | >>> from requests_magpie import MagpieAuth
|
|
83 | 76 | Output format
|
84 | 77 | -------------
|
85 | 78 |
|
86 |
| -Birdy automatically manages process output to reflect it's default values or |
87 |
| -Birdy's own defaults. |
| 79 | +Birdy automatically manages process output to reflect its default values or Birdy's own defaults. |
88 | 80 |
|
89 | 81 | However, it's possible to customize the output of a process. Each process has an input
|
90 |
| -named ``output_formats`, that takes a dictionary as a parameter:: |
| 82 | +named ``output_formats``, that takes a dictionary as a parameter:: |
91 | 83 |
|
92 | 84 | # example format = {
|
93 | 85 | # 'output_identifier': {
|
|
122 | 114 | .. _requests Authentication: https://2.python-requests.org/en/master/user/authentication/
|
123 | 115 | .. _magpie: https://github.com/ouranosinc/magpie
|
124 | 116 | .. _requests-magpie: https://github.com/ouranosinc/requests-magpie
|
125 |
| -
|
126 | 117 | """
|
127 | 118 |
|
128 | 119 | from birdy.client.notebook import gui # noqa: F401
|
|
0 commit comments