Skip to content

Commit bf3c5d0

Browse files
Merge pull request #29 from praekeltfoundation/use_polars_in_aaqv2
Use Polars LazyFrames in Turn BQ and AAQV2 ingestion
2 parents 6e3a2f2 + 85fd98b commit bf3c5d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1255
-513
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Install dependencies
1717
id: install-deps
1818
run: |
19-
uv sync --only-group dev
19+
uv sync --group dev --extra polars
2020
- name: run linters
2121
run: |
2222
chmod +x .ci/lint.sh

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Install dependencies
1717
id: install-deps
1818
run: |
19-
uv sync --dev
19+
uv sync --dev --extra polars
2020
- name: test with pytest
2121
run: |
2222
uv run pytest -v

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<img src="https://github.com/praekeltfoundation/rdw-ingestion-tools/workflows/lint/badge.svg" width="120" />
88
<img src="https://github.com/praekeltfoundation/rdw-ingestion-tools/workflows/release/badge.svg" width="145" />
99
<img src="https://github.com/praekeltfoundation/rdw-ingestion-tools/workflows/test/badge.svg" width="120" />
10-
<img src="https://img.shields.io/badge/version-2.0.2.dev0-orange" width="145" />
10+
<img src="https://img.shields.io/badge/version-2.0.2-orange" width="145" />
1111
<img src="https://img.shields.io/badge/license-MIT-blue" width="100" />
1212
</p>
1313
</div>
@@ -116,9 +116,9 @@ pyS3.s3.get_filenames(bucket=bucket, prefix=prefix)
116116
```
117117

118118
### Running an example locally
119-
1. `uv sync`
119+
1. `uv sync` or `uv sync --extra polars` for Turn BQ and AAQV2 examples
120120
2. `uv run --env-file .env examples/{path}` e.g. `uv run --env-file .env examples/turn_bq/cards.py`
121121

122122
#### Running tests
123-
1. `uv sync --dev`
123+
1. `uv sync --dev --extra polars`
124124
2. `uv run pytest -vv --cov`

examples/aaqv2/contents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
contents = pyAAQV2().contents.get_contents()
44

5-
print(contents.head(5))
5+
print(contents.collect().head(5))

examples/aaqv2/queries.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
queries = pyAAQV2().queries.get_queries(start_date=start_date, end_date=end_date)
77

8-
print(queries.head(5))
8+
9+
print(queries.collect().head(5))

examples/aaqv2/urgency_queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
start_date=start_date, end_date=end_date
88
)
99

10-
print(urgency_queries.head(5))
10+
print(urgency_queries.collect().head(5))

examples/aaqv2/urgency_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
urgency_rules = pyAAQV2().urgency_rules.get_urgency_rules()
44

5-
print(urgency_rules.head(5))
5+
print(urgency_rules.collect().head(5))

examples/turn_bq/cards.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
cards = pyTurnBQ().cards.get_cards()
44

5-
print(cards.head(5))
5+
print(cards.collect().head(5))
66

77
cards_by_id = pyTurnBQ().cards.get_cards_by_id(card_id=817938)
88

9-
print(cards_by_id)
9+
print(cards_by_id.collect())

examples/turn_bq/chats.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
chats = pyTurnBQ().chats.get_chats_by_id(chat_id=1531207597)
44

5-
print(chats.head(5))
5+
print(chats.collect().head(5))
66

77
chats = pyTurnBQ().chats.get_chats_by_updated_at(
8-
from_timestamp="2023-10-01T00:00:00", to_timestamp="2023-10-10T00:00:00"
8+
from_timestamp="2023-10-01T00:00:00", to_timestamp="2023-10-01T00:50:00"
99
)
1010

11-
print(chats.head(5))
11+
print(chats.collect().head(5))

examples/turn_bq/contacts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
contacts = pyTurnBQ().contacts.get_contacts_by_id(contact_id=2350649091)
44

5-
print(contacts.head(5))
5+
print(contacts.collect().head(5))
66

77
contacts = pyTurnBQ().contacts.get_contacts_by_updated_at(
8-
from_timestamp="2023-10-01T00:00:00", to_timestamp="2023-10-10T00:00:00"
8+
from_timestamp="2023-10-01T00:00:00", to_timestamp="2023-10-01T00:00:30"
99
)
1010

11-
print(contacts.head(5))
11+
print(contacts.collect().head(5))

0 commit comments

Comments
 (0)