Skip to content

feat: track every child run in a registry - #1270

Open
vdusek wants to merge 3 commits into
masterfrom
feat/child-run-registry
Open

vdusek wants to merge 3 commits into
masterfrom
feat/child-run-registry

Conversation

@vdusek

@vdusek vdusek commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of 6 that implement the final specification of Actor composability: "Tracking child runs", section 3, and "Named child runs". It changes the named child runs released in 4.2.0, which are experimental.

Registry

  • Every run started by Actor.start, Actor.call, Actor.start_task, and Actor.call_task is recorded, with or without a run_name.
  • The registry is {"runs": {"<kind>:<value>": record}} under APIFY_ACTOR_CHILD_RUNS in the default key-value store. A run without a name has the key run:<run ID>, and a named run has name:<run name>. A record has runId, status, and abortWithParent, and a named run also has checksum. The JS SDK uses the same format.
  • Record kinds, record fields, and top-level members that the SDK does not know are kept when it writes the registry, for example after a metamorph from an Actor with a newer SDK.
  • A registry under the former key __ACTOR_CHILD_RUNS is not read.
  • Actor.call without a run_name starts the run and waits for it in the SDK, so the run is recorded while it runs.

Tracker

  • New option Actor(child_run_tracker=...). 'default' keeps the registry in the default key-value store. A custom ChildRunTracker with list_runs() and store_run(key, record) can keep it elsewhere, for example encrypted. None turns tracking off, and the SDK then neither reads nor writes the registry.
  • With tracking off, Actor.child_runs raises a RuntimeError, and run_name and abort_with_parent raise a ValueError.
  • Once the registry holds more than 50 records, the SDK logs one warning per process. Actor(disable_excessive_child_run_warning=True) mutes it.

Named runs

  • A recorded run is returned in whatever status it is in. Only a run that the API no longer knows (404 for about 3 seconds) gets a new run under the same name, with a warning.
  • The checksum is the SHA-256 of {id, type, input, options} as canonical JSON (RFC 8785). options has only build, forcePermissionLevel, and webhooks, so a call with another memory, timeout, or charge limit returns the recorded run.
  • A run_name used again with a different Actor, task, input, or one of these options raises a ValueError.
  • An input that is not sent as JSON is left out of the checksum, and a warning says that it was not checked.

Actor.child_runs

A list with one entry per record, in recording order, including the records of earlier processes:

for key, record, client in Actor.child_runs:
    run = await client.wait_for_finish()

Notes for the release

  • Actor.child_runs was a dict of run clients by run name.
  • abort_with_parent still needs a run_name in this PR. feat: abort marked child runs on parent abort or failure #1250 lifts that.
  • Log messages name a run by its registry key, for example Reattaching to child run "name:scrape-eu". Resurrecting child run "%s" is gone, and Child run "%s" no longer exists, starting a new run in its place is new (warning).
  • The experimental warning starts with Child run features.
  • The title has no !, because the feature is experimental.

Closes: #1129

✍️ Drafted by Claude Code

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 20, 2026
@vdusek
vdusek added this pull request to stack #1274 November 20, 2026 16:35
@vdusek vdusek changed the title feat/child run registry fix: return a recorded child run in any status Nov 20, 2026
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.75519% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.00%. Comparing base (06a4e2c) to head (e3a8982).

Files with missing lines Patch % Lines
src/apify/_child_runs.py 98.49% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1270      +/-   ##
==========================================
+ Coverage   93.90%   94.00%   +0.09%     
==========================================
  Files          54       54              
  Lines        3906     4020     +114     
==========================================
+ Hits         3668     3779     +111     
- Misses        238      241       +3     
Flag Coverage Δ
e2e 31.14% <31.95%> (+0.08%) ⬆️
integration 50.39% <37.75%> (-0.22%) ⬇️
unit 91.34% <98.75%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek added the adhoc Ad-hoc unplanned task added during the sprint. label Nov 20, 2026
@vdusek vdusek self-assigned this Nov 20, 2026
@vdusek
vdusek force-pushed the feat/child-run-registry branch from b7b6745 to 253a205 Compare November 20, 2026 17:52
@vdusek
vdusek marked this pull request as ready for review November 20, 2026 17:58
@vdusek
vdusek requested review from Pijukatel and barjin November 20, 2026 17:58
Comment thread src/apify/_actor.py Resolved
Comment thread src/apify/_child_runs.py Resolved
Comment thread src/apify/_child_runs.py Resolved
vdusek added a commit that referenced this pull request Nov 27, 2026
`Actor.call_task` gets the `logger` argument that `Actor.call` already
has. By default it redirects the log and the status messages of the task
run to the log of the parent Actor. `logger=None` turns it off, and a
custom logger receives the redirected lines.

- The API client's `TaskClient.call` cannot redirect the log, so
`Actor.call_task` starts the task with `TaskClient.start` and waits for
the run through the run client. The start request keeps
`timeout='no_timeout'`, as in `TaskClient.call`.
- A named task call streams the log of a new run from the start, and
only the new lines of a reattached run, the same as a named
`Actor.call`.
- If the redirect cannot be set up, the call logs a warning and waits
for the run without its log. The run is already started at that point.
- Concurrent named calls that share one run redirect its log once. This
also holds for a named `Actor.call`.

Changes for existing Actors:

- The default is `'default'`, the same as for `Actor.call`. So an Actor
that calls a task gets the log lines of the task run in its own log.
- With a logger, `Actor.call_task` returns about 6 seconds after the run
finishes or `wait` runs out, because the status message redirect of the
API client waits that long for the last message. `Actor.call` has the
same delay. Pass `logger=None` to avoid it.

The JS SDK does not redirect the log of a task run. A `logger` argument
on `TaskClient.call` in both API clients would be the better place for
this, and the SDK would then only pass it on.

The PR is independent of the child runs stack (#1270 and the PRs on top
of it). Both change `Actor.call_task`, so the one that merges second
needs a rebase.

*✍️ Drafted by Claude Code*
@vdusek
vdusek force-pushed the feat/child-run-registry branch from 2d30204 to 48e6d35 Compare November 27, 2026 14:12
@vdusek
vdusek removed this pull request from stack #1274 November 27, 2026 14:16
@vdusek
vdusek added this pull request to stack #1286 November 27, 2026 14:16
@vdusek vdusek changed the title fix: return a recorded child run in any status feat: track every child run in a registry Nov 27, 2026
@vdusek
vdusek requested a review from Pijukatel November 27, 2026 14:27
@vdusek vdusek removed the adhoc Ad-hoc unplanned task added during the sprint. label Nov 28, 2026

This branch has not been deployed

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

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose tracked child runs as a readable API

2 participants