Skip to content

Conversation

@Mantisus
Copy link
Collaborator

closes: #614

@Mantisus Mantisus requested a review from janbuchar October 23, 2025 01:45
@Mantisus Mantisus self-assigned this Oct 23, 2025
Comment on lines +341 to +355
charged_counts = json.loads(self._configuration.charged_event_counts)

# Validate pricing info with proper discriminator support
pricing_info_adapter: TypeAdapter[
FreeActorPricingInfo
| FlatPricePerMonthActorPricingInfo
| PricePerDatasetItemActorPricingInfo
| PayPerEventActorPricingInfo
] = TypeAdapter(
FreeActorPricingInfo
| FlatPricePerMonthActorPricingInfo
| PricePerDatasetItemActorPricingInfo
| PayPerEventActorPricingInfo
)
pricing_info = pricing_info_adapter.validate_json(self._configuration.actor_pricing_info)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this to the Configuration class itself so that self._configuration.actor_pricing_info is already parsed and validated

class Configuration
  ...
  actor_pricing_info: Annotated[FreeActorPricingInfo | ..., Field(...), BeforeValidator(json.loads)]

def get_max_total_charge_usd(self) -> Decimal:
return self._max_total_charge_usd

async def _fetch_pricing_info(self) -> dict[str, Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please return a better type here


# Set up charging log dataset for local development
if not self._is_at_home and self._pricing_model == 'PAY_PER_EVENT':
# We are not running on the Apify platform, but PPE is enabled for testing - open a dataset that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with that comment? ☹️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load Actor pricing and charged events from env vars

2 participants