Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit f308067

Browse files
committed
update docs; make release
1 parent 9b4a959 commit f308067

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

CHANGES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1.5 (unreleased)
2-
----------------
1+
1.5
2+
---
33

44
- :meth:`atomx.Atomx.report` takes ``name`` parameter to name reports
55
- remove ``network`` scope in :meth:`atomx.Atomx.report` and add

atomx/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
151151
An expression list is in the form of ``[column, op, value]``:
152152
153153
- ``column`` can be any of the ``groups`` or ``metrics`` parameter columns.
154-
- ``op`` can be any of ``==``, ``!=``, ``<=``, ``>=``,
155-
``<``, ``>``, ``in`` or ``not in`` as a string.
154+
- ``op`` can be any of ``==``, ``!=``, ``in`` or ``not in`` as a string.
156155
- ``value`` is either a number or in case of ``in``
157156
and ``not in`` a list of numbers.
158157
@@ -201,13 +200,11 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
201200
if where:
202201
report_json['where'] = where
203202

204-
if when and interval:
205-
is_scheduled_report = True
203+
if when and interval: # scheduled report
206204
report_json['when'] = when
207205
report_json['interval'] = interval
208-
else:
209-
is_scheduled_report = False
210206

207+
else: # normal report
211208
if from_ is None:
212209
from_ = datetime.now() - timedelta(days=7)
213210
if isinstance(from_, datetime):

atomx/exceptions.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class ModelNotFoundError(Exception):
2020
"""Raised when trying to (re-)load a model that is not in the api."""
2121
pass
2222

23-
class ReportNotReadyError(Exception):
24-
"""Raised when requesting ``report.content`` but the report is not ready yet."""
25-
pass
26-
2723
class NoPandasInstalledError(Exception):
2824
"""Raised when trying to access ``report.pandas`` without :mod:`pandas` installed."""
2925
pass

atomx/models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import csv
43
import pprint
54
from decimal import Decimal
65
from datetime import datetime, date
@@ -13,7 +12,6 @@
1312
NoSessionError,
1413
ModelNotFoundError,
1514
APIError,
16-
ReportNotReadyError,
1715
NoPandasInstalledError,
1816
)
1917

atomx/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VERSION = '1.5b'
1+
VERSION = '1.5'
22
API_VERSION = 'v3'

docs/usage.rst

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ E.g.
7070
# is equivalent to atomx.get('advertiser/42/profiles')
7171
7272
73+
You can also use a class or instance of :mod:`atomx.models` in a get requests.
74+
E.g. all of those api calls request the same resource:
75+
76+
.. code-block:: python
77+
78+
from atomx.models import Advertiser
79+
80+
atomx.get('advertiser/42') # all in 1 string
81+
atomx.get('advertiser', 42) # model, id split up
82+
atomx.get(Advertiser, 42) # using :class:`atomx.models.Advertiser`
83+
atomx.get(Advertiser(42)) # using instance of :class:`atomx.models.Advertiser`
84+
85+
7386
Or get all domains where the hostname contains `atom`:
7487

7588
.. code-block:: python
@@ -183,16 +196,22 @@ to create a report.
183196

184197
.. code-block:: python
185198
186-
# reporting example
199+
from datetime import datetime, timedelta
200+
201+
now = datetime.utcnow()
202+
last_week = now - timedelta(days=7)
203+
187204
# get a report for a specific publisher
188-
report = atomx.report(scope='publisher', groups=['hour'], metrics=['impressions', 'clicks'], where=[['publisher_id', '==', 42]], from_='2015-02-08 00:00:00', to='2015-02-09 00:00:00', timezone='America/Los_Angeles')
189-
# check if report is ready
190-
print(report.is_ready)
205+
report = atomx.report(scope='publisher', groups=['hour'], metrics=['impressions', 'clicks'], where=[['publisher_id', '==', 42]], from_=last_week, to=now, timezone='America/Los_Angeles')
206+
207+
report.length # get the number of rows returned
208+
report.totals # get the total values
209+
191210
# if pandas is installed you can get the pandas dataframe with `report.pandas`
192211
# you can also get the report csv in `report.content` without pandas
193212
df = report.pandas # A datetime index is automatically set when group by a hour/day/month.
194213
# calculate mean, median, std per hour
195-
means = df.resample('H', how=['mean', 'median', 'std'])
214+
means = df.resample('H').apply(['mean', 'median', 'std'])
196215
# and plot impression and clicks per day
197216
means['impressions'].plot()
198217
means['clicks'].plot()

0 commit comments

Comments
 (0)