wright-way Prefect Flow Tasks#
The Wright Way flows are built using the tasks below. These tasks do the bulk of the work, but still are relatively simple. They do things like initializing the database, CRUD operations on the database, pulling animal data from the website, and sending alerts when new animals are found.
wright_way.initialize_db
#
Initialize the Wright Way database, if not already initialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|
Source code in wright_way/orchestration.py
wright_way.get_wright_way_db_ids
#
Get all Wright Way Petango IDs from the local database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Sequence[int]
|
Sequence[int]: A sequence of Wright Way Petango IDs in the database. |
Source code in wright_way/orchestration.py
wright_way.get_wright_way_ids
#
Get all active Wright Way Petango IDs from the Wright Way website.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
WrightWayScraper | None
|
Wright Way Scraper client, if not provided, a new client will be created. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[int]
|
list[int]: List of active Wright Way Petango IDs. |
Source code in wright_way/orchestration.py
wright_way.get_animal
#
Get an SQLAlchemy Animal instance by Petango ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
int
|
Petango ID of the animal. |
required |
client
|
WrightWayScraper | None
|
Wright Way Scraper client, if not provided, a new client will be created. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Animal |
Animal
|
SQLAlchemy model instance of the animal. |
Source code in wright_way/orchestration.py
wright_way.add_animals_to_db
#
Add animals to the Wright Way local database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
animals
|
Collection[Animal]
|
List of animals to add to the database. |
required |
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|
Source code in wright_way/orchestration.py
wright_way.delete_animals_from_db
#
delete_animals_from_db(petango_ids: Collection[int] | None = None, engine: Engine | None = None) -> None
Delete animals from the Wright Way local database by Petango ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
petango_ids
|
Collection[int] | None
|
List of Petango IDs to delete from the database. If None, all animals will be deleted. Defaults to None. |
None
|
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|
Source code in wright_way/orchestration.py
wright_way.update_animals_in_db
#
Update animals in the Wright Way local database by Petango ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
animals
|
Collection[Animal]
|
List of animals to update in the database. |
required |
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|
Source code in wright_way/orchestration.py
wright_way.alert_new_animal
async
#
alert_new_animal(animal: int | Animal, channel_name_or_id: str, engine: Engine | None = None) -> None
Publish a slack message about a new animal at Wright Way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
animal
|
int | Animal
|
Petango ID of the animal or the Animal instance. |
required |
channel_name_or_id
|
str
|
Slack channel to publish the message to. |
required |
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|