Skip to content

Commit

Permalink
README: rephrase
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Dec 20, 2024
1 parent 7a47241 commit 8c821a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ inverses: Stream[float] = (
```

## 5. iterate
- Iterate over a `Stream[T]` as you would over any other `Iterable[T]`.
- Source elements are ***processed on-the-fly***.
- Iterate over a `Stream[T]` just as you would over any other `Iterable[T]`.
- Elements are ***processed on-the-fly***.

### collect it
```python
Expand Down Expand Up @@ -100,6 +100,9 @@ inverses: Stream[float] = (
---

# 📒 ***Operations***

A dozen expressive operations and that’s it!

## `.map`

> Applies a transformation on elements:
Expand Down Expand Up @@ -503,17 +506,9 @@ assert state == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
---

# 📦 ***Notes Box***
## Contribute
Feel very welcome to:
- [open issues](https://github.com/ebonnal/streamable/issues)
- [open pull requests](https://github.com/ebonnal/streamable/pulls)
- check [CONTRIBUTING.md](CONTRIBUTING.md)


## Extract-Transform-Load
ETL scripts (i.e. scripts fetching -> processing -> pushing data) can benefit from the expressivity of this library.
Custom ETL scripts can benefit from the expressivity of this library. Here is a pipeline that creates a CSV file containing the 67 quadruped pokemons from the 3 first generations (kudos to [PokéAPI](https://pokeapi.co/)):

Here is an example that you can **copy-paste and try** (it only requires `requests`): it creates a CSV file containing all the 67 quadrupeds from the 1st, 2nd and 3rd generations of Pokémons (kudos to [PokéAPI](https://pokeapi.co/))
```python
import csv
from datetime import timedelta
Expand All @@ -525,7 +520,8 @@ with open("./quadruped_pokemons.csv", mode="w") as file:
fields = ["id", "name", "is_legendary", "base_happiness", "capture_rate"]
writer = csv.DictWriter(file, fields, extrasaction='ignore')
writer.writeheader()
(

pipeline: Stream = (
# Infinite Stream[int] of Pokemon ids starting from Pokémon #1: Bulbasaur
Stream(itertools.count(1))
# Limits to 16 requests per second to be friendly to our fellow PokéAPI devs
Expand Down Expand Up @@ -553,9 +549,9 @@ with open("./quadruped_pokemons.csv", mode="w") as file:
.observe("written pokemons")
# Catches exceptions and raises the 1st one at the end of the iteration
.catch(finally_raise=True)
# Actually triggers an iteration (the lines above define lazy operations)
.count()
)

pipeline()
```

## logging level
Expand Down Expand Up @@ -593,6 +589,12 @@ safe_inverse_integers: Iterator[int] = catch(inverse_integers, ZeroDivisionError
## *free-threaded* Python 3.13+
Benefits from [free-threaded](https://docs.python.org/3/using/configure.html#cmdoption-disable-gil) Python 3.13+ builds, run via `python -X gil=0`.

## Contribute
Feel very welcome to:
- [open issues](https://github.com/ebonnal/streamable/issues)
- [open pull requests](https://github.com/ebonnal/streamable/pulls)
- check [CONTRIBUTING.md](CONTRIBUTING.md)

## Thank you for the highlights 🙏
- [Tryolabs' Top Python libraries of 2024](https://tryolabs.com/blog/top-python-libraries-2024#top-10---general-use) ([LinkedIn](https://www.linkedin.com/posts/tryolabs_top-python-libraries-2024-activity-7273052840984539137-bcGs?utm_source=share&utm_medium=member_desktop), [Reddit](https://www.reddit.com/r/Python/comments/1hbs4t8/the_handpicked_selection_of_the_best_python/))
- [PyCoder’s Weekly](https://pycoders.com/issues/651) x [Real Python](https://realpython.com/)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def test_etl_example(self) -> None: # pragma: no cover
fields = ["id", "name", "is_legendary", "base_happiness", "capture_rate"]
writer = csv.DictWriter(file, fields, extrasaction='ignore')
writer.writeheader()
(
pipeline = (
# Infinite Stream[int] of Pokemon ids starting from Pokémon #1: Bulbasaur
Stream(itertools.count(1))
# Limits to 16 requests per second to be friendly to our fellow PokéAPI devs
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_etl_example(self) -> None: # pragma: no cover
.observe("written pokemons")
# Catches exceptions and raises the 1st one at the end of the iteration
.catch(finally_raise=True)
# Actually triggers an iteration (the lines above define lazy operations)
.count()
)

pipeline()
# fmt: on

0 comments on commit 8c821a5

Please sign in to comment.