cuery.actors.scaffold.flex#
Scaffold a new Apify actor from a FlexTool subclass.
This script inspects a given subclass of cuery.tools.flex.FlexTool and creates a new
actor directory in actors/ with the common structure and files used in this repo:
- actors/
- <actor_dir>/
- .actor/
actor.json input_schema.json dataset_schema.json example_input.json README.md Dockerfile
- src/
__main__.py
storage/
It also creates a new module stub in src/cuery/actors/<module_name>.py that wires the
FlexTool into the standard runner using run_flex_tool.
Usage (from project root):
python -m cuery.actors.scaffold cuery.tools.flex.classify.Classifier –actor-name classifier
You can override names and descriptions with CLI options. By default, names are derived from the tool class name.
Classes#
Functions#
|
|
|
|
|
|
|
Load a class given a full import path |
Return the repository root based on this file location. |
|
|
|
|
|
|
|
|
|
|
Return (actor_dir_name, module_name, title). |
|
|
|
Convert a Pydantic model JSON schema into Apify actor input_schema.json. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Create a new actor directory and module for a given FlexTool subclass. |
Module Contents#
- cuery.actors.scaffold.flex.snake_case(name)#
- Parameters:
name (str)
- Return type:
str
- cuery.actors.scaffold.flex.kebab_case(name)#
- Parameters:
name (str)
- Return type:
str
- cuery.actors.scaffold.flex.title_case(name)#
- Parameters:
name (str)
- Return type:
str
- cuery.actors.scaffold.flex.load_class(path)#
Load a class given a full import path
module.submodule:Classormodule.Class.- Parameters:
path (str)
- cuery.actors.scaffold.flex.repo_root_from_here()#
Return the repository root based on this file location.
This file lives at: <root>/src/cuery/actors/scaffold/make.py → parents[4] is the repo root.
- Return type:
pathlib.Path
- cuery.actors.scaffold.flex.read_project_version(root)#
- Parameters:
root (pathlib.Path)
- Return type:
str
- cuery.actors.scaffold.flex.ensure_dir(path)#
- Parameters:
path (pathlib.Path)
- Return type:
None
- cuery.actors.scaffold.flex.write_json(path, data)#
- Parameters:
path (pathlib.Path)
data (dict[str, Any])
- Return type:
None
- cuery.actors.scaffold.flex.write_text(path, data)#
- Parameters:
path (pathlib.Path)
data (str)
- Return type:
None
- cuery.actors.scaffold.flex.derive_actor_names(tool_class_name, actor_name, module_name, title)#
Return (actor_dir_name, module_name, title).
- Parameters:
tool_class_name (str)
actor_name (str | None)
module_name (str | None)
title (str | None)
- Return type:
tuple[str, str, str]
- cuery.actors.scaffold.flex._apify_editor_for_field(name, schema)#
- Parameters:
name (str)
schema (dict[str, Any])
- Return type:
str | None
- cuery.actors.scaffold.flex.build_input_schema(tool_cls, title, description)#
Convert a Pydantic model JSON schema into Apify actor input_schema.json.
Adds dataset_id
Drops ‘records’
Attempts to set Apify UI editors heuristically
- Parameters:
title (str)
description (str | None)
- Return type:
dict[str, Any]
- cuery.actors.scaffold.flex.default_dataset_schema(title, description)#
- Parameters:
title (str)
description (str | None)
- Return type:
dict[str, Any]
- cuery.actors.scaffold.flex.make_actor_json(name, title, description, module_name)#
- Parameters:
name (str)
title (str)
description (str | None)
module_name (str)
- Return type:
dict[str, Any]
- cuery.actors.scaffold.flex.make_dockerfile(cuery_version, module_name)#
- Parameters:
cuery_version (str | None)
module_name (str)
- Return type:
str
- cuery.actors.scaffold.flex.make_readme(title, description)#
- Parameters:
title (str)
description (str | None)
- Return type:
str
- cuery.actors.scaffold.flex.make_actor_main(module_name)#
- Parameters:
module_name (str)
- Return type:
str
- cuery.actors.scaffold.flex.make_module_stub(tool_path)#
- Parameters:
tool_path (str)
- Return type:
str
- class cuery.actors.scaffold.flex.ScaffoldSpec#
- tool_class_path: str#
- actor_dir_name: str#
- module_name: str#
- title: str#
- description: str | None#
- overwrite: bool = False#
- cuery.actors.scaffold.flex.scaffold(spec)#
- Parameters:
spec (ScaffoldSpec)
- Return type:
pathlib.Path
- cuery.actors.scaffold.flex.make_scaffold(tool, actor_name=None, module_name=None, title=None, description=None, force=False)#
Create a new actor directory and module for a given FlexTool subclass.
- Parameters:
tool (str)
actor_name (str | None)
module_name (str | None)
title (str | None)
description (str | None)
force (bool)
- Return type:
None