Skip to content

Commit

Permalink
bump version to 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
wizpig64 committed Sep 24, 2019
1 parent 3ee20ff commit 80ce08d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ TODO
- Increment major version to track with upstream.


Unreleased
----------
1.3 (2019-09-23)
----------------

High-level changes:

Expand Down
73 changes: 37 additions & 36 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,37 @@ Requires Python 3.5 or better. Tested on Python 3.6. Depends on asks_ and pycryp
Installation
------------

Use ``pip`` to install the current release, version 1.2, from PyPI_::
Use ``pip`` to install the current release, version 1.3, from PyPI_::

pip install python-fieldclimate

.. _PyPI: https://pypi.org/project/python-fieldclimate/

To try out unreleased changes (see CHANGES.rst!), install from the git master branch::

pip install -e git://github.com/agrimgt/python-fieldclimate.git#egg=fieldclimate
Usage
-----

**The rest of this readme assumes you are using the unreleased development version!**
Things have changed a little since 1.2, so if you're using that, go read `the 1.2 readme`_.
Here's a simple example that returns the associated user's account info:

.. _the 1.2 readme: https://github.com/agrimgt/python-fieldclimate/blob/1.2/README.rst
.. code-block:: python
from asyncio import run
from fieldclimate import FieldClimateClient
Usage
-----
async def main():
async with FieldClimateClient(private_key="YOUR", public_key="KEYS") as client:
return await client.get_user()
The same FieldClimateClient class can be used to make asynchronous requests under any modern event loop.
if __name__ == "__main__":
run(main)
Event Loops
~~~~~~~~~~~

**New in version 1.3.**

The same FieldClimateClient class can be used to make asynchronous API requests under any modern event loop.
This is thanks to asks being written with anyio_, which currently supports asyncio_, curio_, and trio_.

.. _anyio: https://github.com/agronholm/anyio
Expand All @@ -50,15 +61,15 @@ HMAC credentials can be provided in several ways:

1. Via the init constructor:

>>> FieldClimateClient(public_key='YOUR', private_key='KEYS')
>>> FieldClimateClient(public_key="YOUR", private_key="KEYS")

2. Environment variables ``FIELDCLIMATE_PUBLIC_KEY`` and ``FIELDCLIMATE_PRIVATE_KEY``.

3. Subclassing FieldClimateClient:

>>> class MyClient(FieldClimateClient):
... private_key = 'YOUR'
... public_key = 'KEYS'
... private_key = "YOUR"
... public_key = "KEYS"

4. If you use Django, you can use ``fieldclimate.django.DjangoFieldClimateClient`` in place of FieldClimateClient.
This subclass will grab ``FIELDCLIMATE_PUBLIC_KEY`` and ``FIELDCLIMATE_PRIVATE_KEY`` from django's settings.
Expand All @@ -69,7 +80,7 @@ Methods

The client has methods for each of the corresponding routes listed in the api docs.
There's a lot of them, so see the full list of methods in ``fieldclimate/__init__.py`` for more details.
Every method returns a dictionary response upon being awaited.
Every method returns a JSON-like python object upon being awaited, like a dictionary or a list.

Some methods will clean up their arguments in order to make working with the API in python easier.
Here are some examples:
Expand All @@ -91,6 +102,8 @@ However, the underlying connection and cleaning utilities they use are all teste
Connection Limits
~~~~~~~~~~~~~~~~~

**New in version 1.3.**

The connection limit can be raised by setting the connections argument when calling the FieldClimateClient constructor.

From `asks' docs`_:
Expand All @@ -117,25 +130,12 @@ During my testing, I noticed the API starting to raise 502 errors when I overloa
Please be courteous with your resource consumption!


Examples
~~~~~~~~
Advanced Example
~~~~~~~~~~~~~~~~

Simple Example:

.. code-block:: python
from asyncio import run
from fieldclimate import FieldClimateClient
async def main():
client = FieldClimateClient(private_key="YOUR", public_key="KEYS")
return await client.get_user()
if __name__ == "__main__":
run(main)
Advanced Example:
This function asks for some user data and gets the list of all user stations, at the same time.
As soon as the stations come back, it counts them and sends off another request for each of the first 10 stations.
Then each of those 10 station responses is printed, sorted by server reply time.

.. code-block:: python
Expand Down Expand Up @@ -171,13 +171,14 @@ Advanced Example:
run(main())
Alternate implementations of these examples using curio and trio are the ``tests`` directory.
Alternate curio and trio implementations are the ``tests`` directory,
if you want to see how to use FieldClimateClient in those event loops (it's much of the same).


Synchronous Usage Removed
~~~~~~~~~~~~~~~~~~~~~~~~~
Synchronous Usage
~~~~~~~~~~~~~~~~~

**New in UNRELEASED master branch:**
**Removed in version 1.3.**

In version 1.2, FieldClimateClient would automatically set up an asyncio event loop when methods were
being called outside of an ``async with`` block.
Expand All @@ -189,7 +190,7 @@ So, with the switch to the ``asks`` backend, support for the old synchronous use
If you were using FieldClimateClient's older 'synchronous usage' mode, you were already using a version of Python that
allowed for async/await. The difference is that now you have to set up an event loop yourself.

If you still *really* don't want to write any coroutines, the simplest way to make your code compatible with dev version
If you still *really* don't want to write any coroutines, the simplest way to make your code compatible with version 1.3
is to just wrap each method call with ``asyncio.run()``:

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion fieldclimate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""An asynchronous client for the iMetos FieldClimate API."""

__all__ = ["FieldClimateClient"]
__version__ = "1.2"
__version__ = "1.3"
__author__ = "Agrimanagement, Inc."

from datetime import datetime
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="python-fieldclimate",
version="1.2",
version="1.3",
description="A client for the iMetos FieldClimate API.",
url="https://github.com/agrimgt/python-fieldclimate",
long_description="\n\n".join(
Expand Down

0 comments on commit 80ce08d

Please sign in to comment.