feat(apify): .actor/ scaffold (.actor/src/main.py + Dockerfile entrypoint swap + make actor-build)
The Apify platform expects the actor entry at .actor/src/main.py. Until
now Pry used `python -m apify_actor` via Dockerfile.apify, which works
but doesn't match the documented convention used by every other actor
on the platform.
- Add .actor/src/main.py as a thin asyncio wrapper around apify_actor.main()
- Swap Dockerfile.apify ENTRYPOINT to the new path
- Add `make actor-build` Makefile target that regenerates
.actor/input_schema.json from the ApifySchemaBuilder fluent API
(urls, max_pages, timeout, output_format, crawl)
Conflicts: none — .actor/actor.json (full version:3.0.0 schema with
input/output blocks inline) already existed from earlier work; this
commit adds the conventional entry path and a build hook that emits
the schema as a sibling file. Apify Console accepts either form.
This commit is contained in:
parent
cf376ab3a8
commit
372ce228f4
4 changed files with 90 additions and 12 deletions
48
.actor/input_schema.json
Normal file
48
.actor/input_schema.json
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"title": "Pry Scraper",
|
||||
"type": "object",
|
||||
"schemaVersion": 1,
|
||||
"properties": {
|
||||
"urls": {
|
||||
"title": "URLs to scrape",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^https?://"
|
||||
}
|
||||
},
|
||||
"max_pages": {
|
||||
"title": "Max pages",
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"minimum": 1,
|
||||
"maximum": 1000
|
||||
},
|
||||
"timeout": {
|
||||
"title": "Timeout (seconds)",
|
||||
"type": "integer",
|
||||
"default": 30,
|
||||
"minimum": 5,
|
||||
"maximum": 120
|
||||
},
|
||||
"output_format": {
|
||||
"title": "Output format",
|
||||
"type": "string",
|
||||
"default": "markdown",
|
||||
"enum": [
|
||||
"markdown",
|
||||
"html",
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"crawl": {
|
||||
"title": "Crawl linked pages",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"description": "Scrape any website with Pry's 12-tier fallback chain.",
|
||||
"required": [
|
||||
"urls"
|
||||
]
|
||||
}
|
||||
23
.actor/src/main.py
Normal file
23
.actor/src/main.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""Pry — Apify Actor entry point.
|
||||
|
||||
Thin wrapper around the SDK-aware entry in apify_actor.py. The Apify
|
||||
platform invokes this file via Dockerfile.apify as
|
||||
``python /usr/src/app/.actor/src/main.py``; we re-export ``main()``
|
||||
so both the legacy ``python -m apify_actor`` invocation and the
|
||||
standard .actor/src/main.py convention work.
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2026 Rug Munch Media LLC
|
||||
#
|
||||
# Part of Pry — https://git.rugmunch.io/RugMunchMedia/pryscraper
|
||||
# Licensed under MIT. See LICENSE.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from apify_actor import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
@ -22,4 +22,4 @@ RUN pip install --no-cache-dir "apify~=1.7.0" \
|
|||
ENV PRY_ACTOR=true
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
ENTRYPOINT ["python3", "-m", "apify_actor"]
|
||||
ENTRYPOINT ["python3", "/usr/src/app/.actor/src/main.py"]
|
||||
|
|
|
|||
29
Makefile
29
Makefile
|
|
@ -1,21 +1,22 @@
|
|||
SHELL := /bin/bash
|
||||
PYTHON := python3
|
||||
|
||||
.PHONY: help install dev lint format typecheck test security check clean precommit ci
|
||||
.PHONY: help install dev lint format typecheck test security check clean precommit ci actor-build
|
||||
|
||||
help:
|
||||
@echo "Pry Makefile"
|
||||
@echo ""
|
||||
@echo " install Install dependencies"
|
||||
@echo " dev Start dev server"
|
||||
@echo " lint Run ruff check"
|
||||
@echo " format Run ruff format"
|
||||
@echo " typecheck Run mypy"
|
||||
@echo " test Run pytest"
|
||||
@echo " security Run bandit + safety"
|
||||
@echo " check Full audit (lint + typecheck + test)"
|
||||
@echo " clean Remove build artifacts"
|
||||
@echo " precommit Run ruff + mypy + bandit"
|
||||
@echo " install Install dependencies"
|
||||
@echo " dev Start dev server"
|
||||
@echo " lint Run ruff check"
|
||||
@echo " format Run ruff format"
|
||||
@echo " typecheck Run mypy"
|
||||
@echo " test Run pytest"
|
||||
@echo " security Run bandit + safety"
|
||||
@echo " check Full audit (lint + typecheck + test)"
|
||||
@echo " clean Remove build artifacts"
|
||||
@echo " precommit Run ruff + mypy + bandit"
|
||||
@echo " actor-build Regenerate .actor/input_schema.json from apify_schema.py"
|
||||
|
||||
install:
|
||||
pip install -e ".[dev]"
|
||||
|
|
@ -46,3 +47,9 @@ clean:
|
|||
precommit: lint format typecheck security
|
||||
|
||||
ci: precommit test
|
||||
|
||||
# Regenerate .actor/input_schema.json from the ApifySchemaBuilder fluent API.
|
||||
# Pin schema version + title so Apify Console recognises the file.
|
||||
actor-build:
|
||||
$(PYTHON) -c "from apify_schema import ApifySchemaBuilder, StringField, IntegerField, BooleanField, EnumField; b = ApifySchemaBuilder('Pry Scraper', 'Scrape any website with Pry\\'s 12-tier fallback chain.'); b.add_array('urls', 'URLs to scrape', {'type': 'string', 'pattern': '^https?://'}, required=True).add_integer('max_pages', 'Max pages', default=10, minimum=1, maximum=1000).add_integer('timeout', 'Timeout (seconds)', default=30, minimum=5, maximum=120).add_enum('output_format', 'Output format', ['markdown','html','text'], default='markdown').add_boolean('crawl', 'Crawl linked pages', default=False); import json, pathlib; pathlib.Path('.actor').mkdir(exist_ok=True); pathlib.Path('.actor/input_schema.json').write_text(json.dumps(b.build_input_schema(), indent=2))"
|
||||
@echo "wrote .actor/input_schema.json"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue