Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/e2e/project_template/test_static_crawlers_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ async def test_static_crawler_actor_at_apify(
try:
assert build_process.returncode == 0

# Stagehand needs the model API key in `os.environ` at run time; register it as a secret env var
# on the deployed actor version so the platform injects it into the run.
# Stagehand needs the model API key in `os.environ` at run time. Env vars are baked into the
# build at build creation time, so registering the env var on the version after `apify push`
# is not enough — we must trigger a fresh build for the env var to be included.
build_number: str | None = None
if crawler_type == 'stagehand':
env_vars = actor.version('0.0').env_vars()
await env_vars.create(name='OPENAI_API_KEY', value=os.environ['OPENAI_API_KEY'], is_secret=True)
rebuild = await actor.build(version_number='0.0', wait_for_finish=600)
build_number = rebuild['buildNumber']

started_run_data = await actor.start(memory_mbytes=8192)
started_run_data = await actor.start(memory_mbytes=8192, build=build_number)
actor_run = client.run(started_run_data['id'])

finished_run_data = await actor_run.wait_for_finish()
Expand Down
Loading