Skip to content

Commit

Permalink
Cache and Docs
Browse files Browse the repository at this point in the history
Had to roll back partial cache implementation to put out a clean release to fix a few issues.
  • Loading branch information
aabmets committed Mar 30, 2022
1 parent b10f0ea commit a8a8d71
Show file tree
Hide file tree
Showing 28 changed files with 465 additions and 489 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# Change Log

### Version 2.0.0

* Changed configuration implementation. <br />
In version 1, you could pass arguments directly into the @client.configure() decorator and the server.start() method.
In version 2, the configuration can now be accessed or changed ***only*** through the dedicated 'config' singleton, which can be imported the same way as the 'client' and 'server' objects.
Note: it is not necessary to use the 'config' object, if you wish to run YFrake with the default settings.


* Trying to import YFrake with Python version less than 3.10 will throw a RuntimeError exception. <br />
YFrake uses the new feature of defining union types as 'X | Y' (PEP 604), which is only available from Python 3.10 and upwards.


* The YFrake module itself is now directly runnable, which is used to run the server from the command line with: 'python -m yfrake args'.


* Updated the documentation to reflect the changes above.
12 changes: 6 additions & 6 deletions docs/source/client/examples/async_mode_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The following example loops at line 4 ``while`` the response has not yet arrived
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
async def main():
resp = client.get('quote_type', symbol='msft')
while resp.pending():
Expand All @@ -32,7 +32,7 @@ The following example blocks at line 4 until the response has arrived:
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
async def main():
resp = client.get('quote_type', symbol='msft')
await resp.wait()
Expand All @@ -54,7 +54,7 @@ The following example waits until all of the responses have arrived before runni
:emphasize-lines: 9
:linenos:
@client.configure()
@client.session
async def main():
queries = [
dict(endpoint='quote_type', symbol='msft'),
Expand All @@ -72,7 +72,7 @@ The following example starts yielding the responses into the ``async for`` loop
:emphasize-lines: 9
:linenos:
@client.configure()
@client.session
async def main():
queries = [
dict(endpoint='quote_type', symbol='msft'),
Expand All @@ -99,7 +99,7 @@ The following example loops while all the available data about a symbol is being
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
async def main():
results = client.get_all(symbol='msft')
while results.pending():
Expand All @@ -112,7 +112,7 @@ The following example blocks while all the available data about a symbol is bein
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
async def main():
results = client.get_all(symbol='aapl')
await results.wait()
Expand Down
46 changes: 0 additions & 46 deletions docs/source/client/examples/decorator_examples.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/client/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Examples
:maxdepth: 2
:caption: Examples

decorator_examples.rst
async_mode_examples.rst
sync_mode_examples.rst
various_examples.rst
12 changes: 6 additions & 6 deletions docs/source/client/examples/sync_mode_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The following example loops at line 4 ``while`` the response has not yet arrived
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
def main():
resp = client.get('quote_type', symbol='msft')
while resp.pending():
Expand All @@ -32,7 +32,7 @@ The following example blocks at line 4 until the response has arrived:
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
def main():
resp = client.get('quote_type', symbol='msft')
resp.wait()
Expand All @@ -54,7 +54,7 @@ The following example waits until all of the responses have arrived before runni
:emphasize-lines: 9
:linenos:
@client.configure()
@client.session
def main():
queries = [
dict(endpoint='quote_type', symbol='msft'),
Expand All @@ -72,7 +72,7 @@ The following example starts yielding the responses into the ``for`` loop as soo
:emphasize-lines: 9
:linenos:
@client.configure()
@client.session
def main():
queries = [
dict(endpoint='quote_type', symbol='msft'),
Expand All @@ -99,7 +99,7 @@ The following example loops while all the available data about a symbol is being
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
def main():
results = client.get_all(symbol='msft')
while results.pending():
Expand All @@ -112,7 +112,7 @@ The following example blocks while all the available data about a symbol is bein
:emphasize-lines: 4
:linenos:
@client.configure()
@client.session
def main():
results = client.get_all(symbol='aapl')
results.wait()
Expand Down
8 changes: 4 additions & 4 deletions docs/source/client/examples/various_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following example prints out the names of all the endpoints queried:
from yfrake import client
import asyncio
@client.configure()
@client.session
async def main():
results = client.get_all(symbol='msft')
async for resp in results.gather():
Expand All @@ -28,7 +28,7 @@ The following example prints out either the ``error`` or the ``data`` property o
from yfrake import client
import asyncio
@client.configure()
@client.session
async def main():
queries = [
dict(endpoint='quote_type', symbol='msft'),
Expand All @@ -54,7 +54,7 @@ The following example creates a batch request of 3 endpoints for 3 symbols:
from yfrake import client
@client.configure()
@client.session
def main():
all_queries = list()
for symbol in ['msft', 'aapl', 'tsla']:
Expand Down Expand Up @@ -87,7 +87,7 @@ The following example demonstrates the usage of the ``get`` method inside a non-
resp.wait()
return resp
@client.configure()
@client.session
def main():
resp = make_the_request('msft')
print(f'Data: {resp.data}')
Expand Down
2 changes: 1 addition & 1 deletion docs/source/client/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ about a single symbol from all symbol-specific endpoints at once.
Client Decorators
+++++++++++++++++

The ``client`` object has a decorator named ``configure``, which opens a session to the Yahoo Finance API servers and
The ``client`` object has a single decorator named ``session``, which opens a session to the Yahoo Finance API servers and
inspects the concurrency mode of your program to adjust its behaviour accordingly.
This enables YFrake to work in async and sync (threaded) modes out-of-the-box.

Expand Down
20 changes: 6 additions & 14 deletions docs/source/client/reference/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@ Client Reference
Public Decorators
-----------------

.. py:decorator:: configure(limit=64, timeout=2)
.. py:decorator:: session
| Manages the connection session for the YFrake client singleton.
| Needs to be active when methods of the client object are being called.
:param limit: The total number of concurrent requests to the Yahoo Finance API servers.
:type limit: int

:param timeout: The maximum time allowed for a request to fetch data from the Yahoo Finance API servers, in seconds.
:type timeout: int
| The server object uses this decorator internally to manage its session
| to the Yahoo Finance API servers.
:raises RuntimeError: if a configuration is already active.

:return: None


.. raw:: html

Expand All @@ -49,7 +43,7 @@ Public Methods
:param kwargs: Variable keyword arguments, which depend on the endpoint requirements. Values can be either *str*, *int* or *bool*.
:type kwargs: unpacked dict

:raises RuntimeError: if a configuration is not active.
:raises RuntimeError: if the session decorator is not in use.
:raises NameError: if an invalid endpoint name has been provided.
:raises KeyError: if an invalid query parameter has been provided.
:raises TypeError: if the datatype of a query parameter is invalid.
Expand All @@ -66,11 +60,10 @@ Public Methods
:param queries: Collection of query dicts.
:type queries: list

:raises RuntimeError: if a configuration is not active.
:raises RuntimeError: if the session decorator is not in use.
:raises NameError: if an invalid endpoint name has been provided.
:raises KeyError: if an invalid query parameter has been provided.
:raises TypeError: if the datatype of a query parameter is invalid.
:raises TypeError: if an element in the queries list is not a dict.

:return: List-like collection object
:rtype: AsyncResults or ThreadResults
Expand All @@ -87,11 +80,10 @@ Public Methods
:param symbol: Security identifier.
:type symbol: str

:raises RuntimeError: if a configuration is not active.
:raises RuntimeError: if the session decorator is not in use.
:raises NameError: if an invalid endpoint name has been provided.
:raises KeyError: if an invalid query parameter has been provided.
:raises TypeError: if the datatype of a query parameter is invalid.
:raises TypeError: if an element in the queries list is not a dict.

:return: List-like collection object
:rtype: AsyncResults or ThreadResults
Loading

0 comments on commit a8a8d71

Please sign in to comment.