Skip to content

Commit b827bb5

Browse files
committed
More documentation
1 parent 9d125fb commit b827bb5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/apify/_charging.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pydantic import TypeAdapter
1010

1111
from apify._models import ActorRun, PricingModel
12+
from apify._utils import docs_group
1213
from apify.log import logger
1314
from apify.storages import Dataset
1415

@@ -21,6 +22,7 @@
2122
run_validator: TypeAdapter[ActorRun | None] = TypeAdapter(Union[ActorRun, None])
2223

2324

25+
@docs_group('Classes')
2426
class ChargingManager:
2527
LOCAL_CHARGING_LOG_DATASET_NAME = 'charging_log'
2628

@@ -185,7 +187,7 @@ def calculate_chargeable() -> dict[str, int | None]:
185187
)
186188

187189
def calculate_total_charged_amount(self) -> Decimal:
188-
"""Calculate the total amount of money charged for pay-per-event events."""
190+
"""Calculate the total amount of money charged for pay-per-event events so far."""
189191
if self._charging_state is None:
190192
raise RuntimeError('Charging manager is not initialized')
191193

@@ -215,7 +217,10 @@ def calculate_max_event_charge_count_within_limit(self, event_name: str) -> int
215217
return math.floor(result) if result.is_finite() else None
216218

217219
def get_pricing_info(self) -> ActorPricingInfo:
218-
"""Retrieve detailed infor about the effective pricing of the current Actor run."""
220+
"""Retrieve detailed information about the effective pricing of the current Actor run.
221+
222+
This can be used for instance when your code needs to support multiple pricing models in transition periods.
223+
"""
219224
if self._charging_state is None:
220225
raise RuntimeError('Charging manager is not initialized')
221226

@@ -231,11 +236,17 @@ def get_pricing_info(self) -> ActorPricingInfo:
231236
)
232237

233238

239+
@docs_group('Data structures')
234240
@dataclass(frozen=True)
235241
class ChargeResult:
236242
event_charge_limit_reached: bool
243+
"""If true, no more events of this type can be charged within the limit"""
244+
237245
charged_count: int
246+
"""Total amount of charged events - may be lower than the requested amount"""
247+
238248
chargeable_within_limit: dict[str, int | None]
249+
"""How many events of each known type can still be charged within the limit"""
239250

240251

241252
@dataclass

0 commit comments

Comments
 (0)