Skip to content

Commit

Permalink
Merge pull request #2 from NarrativeScience/renameasync
Browse files Browse the repository at this point in the history
QPT-35790 Rename library to async
  • Loading branch information
jdrake committed Jun 23, 2021
2 parents 2058aa8 + f33c5ad commit e175cb9
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ignore = E203,E501,E731,W503,W605
import-order-style = google
# Packages added in this list should be added to the setup.cfg file as well
application-import-names =
cubejsclient
cubejsclientasync
exclude =
*vendor*
.venv
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cubejsclient
# cubejsclientasync

[![](https://img.shields.io/pypi/v/cubejsclient.svg)](https://pypi.org/pypi/cubejsclient/) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![](https://img.shields.io/pypi/v/cubejsclientasync.svg)](https://pypi.org/pypi/cubejsclientasync/) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)

Async Python Cube.js client

Expand All @@ -16,15 +16,15 @@ Table of Contents:

## Installation

cubejsclient requires Python 3.6 or above.
cubejsclientasync requires Python 3.6 or above.

```bash
pip install cubejsclient
pip install cubejsclientasync
```

## Development

To develop cubejsclient, install dependencies and enable the pre-commit hook:
To develop cubejsclientasync, install dependencies and enable the pre-commit hook:

```bash
pip install pre-commit poetry
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 8 additions & 6 deletions cubejsclient/filters.py → cubejsclientasync/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def __init__(
"""Initializer
Args:
start_date: Start date for the absolute range
end_date: End date for the absolute range
start_date: Start date for the absolute range. Format `YYYY-MM-DD`
or `YYYY-MM-DDTHH:mm:ss.SSS`.
end_date: End date for the absolute range. Format `YYYY-MM-DD`
or `YYYY-MM-DDTHH:mm:ss.SSS`.
relative: Relative date range, e.g. "this month"
"""
Expand Down Expand Up @@ -134,12 +136,12 @@ def serialize(self) -> Dict[str, Any]:
}


class BooleanOperator:
class BooleanExpression:
"""Represents a boolean operator in a filter"""

operator: str

def __init__(self, *operands: Union["BooleanOperator", Filter]) -> None:
def __init__(self, *operands: Union["BooleanExpression", Filter]) -> None:
"""Initializer
Args:
Expand All @@ -158,13 +160,13 @@ def serialize(self) -> Dict[str, List[Any]]:
return {self.operator: [o.serialize() for o in self.operands]}


class Or(BooleanOperator):
class Or(BooleanExpression):
"""Boolean operator for `or`"""

operator = "or"


class And(BooleanOperator):
class And(BooleanExpression):
"""Boolean operator for `and`"""

operator = "and"
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "cubejsclient"
name = "cubejsclientasync"
version = "0.1.0"
description = "Async Python Cube.js client"
authors = ["Jonathan Drake <jdrake@narrativescience.com>"]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ force_sort_within_sections=true
include_trailing_comma=true
known_standard_library=typing
known_first_party=
cubejsclient
cubejsclientasync
line_length=88
multi_line_output=3
no_lines_before=LOCALFOLDER
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
import unittest

from cubejsclient import (
from cubejsclientasync import (
Cube,
CubeClient,
DateRange,
Expand Down
27 changes: 25 additions & 2 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

import unittest

from cubejsclient import Cube, DateRange, Order, Query, TimeDimension, TimeGranularity
from cubejsclientasync import (
Cube,
DateRange,
Order,
Query,
TimeDimension,
TimeGranularity,
)
from cubejsclientasync.enums import FilterOperator
from cubejsclientasync.filters import And, Filter


class QueryTests(unittest.TestCase):
Expand All @@ -21,19 +30,33 @@ def test_basic(self):
granularity=TimeGranularity.month,
)
],
filters=[
And(Filter(cube.dimension("state"), FilterOperator.equals, ["WA"]))
],
order=[(cube.dimension("bar"), Order.asc)],
)
self.assertEqual(
q.serialize(),
{
"measures": ["c__app-123__us_accidents.foo"],
"time_dimensions": [
"timeDimensions": [
{
"dimension": "c__app-123__us_accidents.time",
"dateRange": "last year",
"granularity": "month",
}
],
"filters": [
{
"and": [
{
"member": "c__app-123__us_accidents.state",
"operator": "equals",
"values": ["WA"],
}
]
}
],
"limit": 10000,
"offset": 0,
"timezone": "UTC",
Expand Down

0 comments on commit e175cb9

Please sign in to comment.