apify-cli icon indicating copy to clipboard operation
apify-cli copied to clipboard

`actor charge` support

Open netmilk opened this issue 10 months ago • 2 comments

As discussed with @mhamas, I'd like to introduce Actor.charge() equivalent to the Apify CLI actor namespace. It should work locally (without the run id an the run API key) as well as in the production deployment on Apify. Locally it should log to stderr every charge event on apify run and output the aggregated breakdown of event charges at the end of the run.

Syntax proposal:

$ apify actor charge <EVENT_NAME> \
[--eventCount <EVENT_COUNT>] \
[--idempotency-key <IDEMPOTENCY_KEY>]
...
Pay Per Event fired: <amount>, <count> times
...


Charges Breakdown:
-----------------------------------------------
|  <event name> | <count> |  <each> | <total>  |
...    
-----------------------------------------------
| Grand total: <sum>                                            |
-----------------------------------------------
...
$ echo $?
0

netmilk avatar Feb 11 '25 20:02 netmilk

@mhamas 's Draft PR here: https://github.com/apify/apify-cli/pull/748

netmilk avatar Feb 14 '25 04:02 netmilk

Locally it should log to stderr every charge event on apify run and output the aggregated breakdown of event charges at the end of the run.

We discussed this briefly on tooling sync and none of us really had an idea (at least one that wasn't frightening) on how to go about that. The CLI is stateless, and the charge command is not something long running, it literally represents the single console log. Also apify run just runs some script (nodejs/python or anything else really), we don't have control over what is that script doing.

B4nan avatar Feb 17 '25 11:02 B4nan

I guess we can close this, given #748 was merged. Feel free to reopen if there is something missing.

B4nan avatar Apr 09 '25 11:04 B4nan