callables 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {callables-0.2.0 → callables-0.3.0}/PKG-INFO +3 -3
- {callables-0.2.0 → callables-0.3.0}/README.md +2 -2
- {callables-0.2.0 → callables-0.3.0}/callables/__init__.py +1 -1
- {callables-0.2.0 → callables-0.3.0}/callables/cli.py +1 -1
- {callables-0.2.0 → callables-0.3.0}/callables/decorator.py +2 -2
- {callables-0.2.0 → callables-0.3.0}/callables/files.py +2 -2
- {callables-0.2.0 → callables-0.3.0}/callables/init.py +4 -13
- {callables-0.2.0 → callables-0.3.0}/callables/manifest.py +3 -3
- {callables-0.2.0 → callables-0.3.0}/callables/project.py +2 -2
- {callables-0.2.0 → callables-0.3.0}/callables/runtime.py +5 -5
- {callables-0.2.0 → callables-0.3.0}/callables.egg-info/PKG-INFO +3 -3
- {callables-0.2.0 → callables-0.3.0}/callables.egg-info/SOURCES.txt +0 -2
- {callables-0.2.0 → callables-0.3.0}/callables.egg-info/entry_points.txt +0 -1
- {callables-0.2.0 → callables-0.3.0}/callables.egg-info/top_level.txt +0 -1
- {callables-0.2.0 → callables-0.3.0}/pyproject.toml +1 -2
- {callables-0.2.0 → callables-0.3.0}/tests/test_agent_tools.py +1 -15
- {callables-0.2.0 → callables-0.3.0}/tests/test_files.py +5 -5
- {callables-0.2.0 → callables-0.3.0}/tests/test_project.py +5 -7
- {callables-0.2.0 → callables-0.3.0}/tests/test_sdk.py +3 -13
- callables-0.2.0/shipfn/__init__.py +0 -10
- callables-0.2.0/shipfn/__main__.py +0 -5
- {callables-0.2.0 → callables-0.3.0}/LICENSE +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables/GUIDE.md +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables/__main__.py +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables/checks.py +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables/commands.py +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables/py.typed +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables/schema.py +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables.egg-info/dependency_links.txt +0 -0
- {callables-0.2.0 → callables-0.3.0}/callables.egg-info/requires.txt +0 -0
- {callables-0.2.0 → callables-0.3.0}/setup.cfg +0 -0
- {callables-0.2.0 → callables-0.3.0}/tests/test_command.py +0 -0
- {callables-0.2.0 → callables-0.3.0}/tests/test_groups.py +0 -0
- {callables-0.2.0 → callables-0.3.0}/tests/test_next.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: callables
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Decorate Python functions and push them to Callables: forms, schedules and run history for your team.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://callables.app
|
|
@@ -26,7 +26,7 @@ pip install callables
|
|
|
26
26
|
|
|
27
27
|
Docs: [callables.app/docs](https://callables.app/docs).
|
|
28
28
|
|
|
29
|
-
This installs the `call` command.
|
|
29
|
+
This installs the `call` command.
|
|
30
30
|
|
|
31
31
|
```python
|
|
32
32
|
from typing import Literal
|
|
@@ -88,7 +88,7 @@ python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
|
88
88
|
.venv/bin/pytest
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
The platform (
|
|
91
|
+
The platform (callables-api) depends on this package and copies the installed version into every build, so a release only reaches deployed functions once the API is updated to it. See [RELEASING.md](RELEASING.md).
|
|
92
92
|
|
|
93
93
|
## License
|
|
94
94
|
|
|
@@ -8,7 +8,7 @@ pip install callables
|
|
|
8
8
|
|
|
9
9
|
Docs: [callables.app/docs](https://callables.app/docs).
|
|
10
10
|
|
|
11
|
-
This installs the `call` command.
|
|
11
|
+
This installs the `call` command.
|
|
12
12
|
|
|
13
13
|
```python
|
|
14
14
|
from typing import Literal
|
|
@@ -70,7 +70,7 @@ python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
|
70
70
|
.venv/bin/pytest
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
The platform (
|
|
73
|
+
The platform (callables-api) depends on this package and copies the installed version into every build, so a release only reaches deployed functions once the API is updated to it. See [RELEASING.md](RELEASING.md).
|
|
74
74
|
|
|
75
75
|
## License
|
|
76
76
|
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
from callables.decorator import DeployedFunction, Group, Next, command, deploy, registry
|
|
3
3
|
from callables.files import File, accept, save_file
|
|
4
4
|
|
|
5
|
-
__version__ = "0.
|
|
5
|
+
__version__ = "0.3.0"
|
|
6
6
|
__all__ = ["deploy", "command", "Group", "Next", "DeployedFunction", "registry", "File", "accept", "save_file", "__version__"]
|
|
@@ -40,7 +40,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
40
40
|
p_init.add_argument("--no-example", action="store_true", help="Only write the agent instructions")
|
|
41
41
|
p_init.add_argument("--no-agents", action="store_true", help="Skip the agent instructions")
|
|
42
42
|
|
|
43
|
-
p_run = sub.add_parser("run", help="(Used by the platform) run one function with inputs from $
|
|
43
|
+
p_run = sub.add_parser("run", help="(Used by the platform) run one function with inputs from $CALLABLES_INPUTS")
|
|
44
44
|
p_run.add_argument("entrypoint", help="module:function")
|
|
45
45
|
p_run.add_argument("--root", default=".")
|
|
46
46
|
|
|
@@ -70,7 +70,7 @@ class Next:
|
|
|
70
70
|
|
|
71
71
|
def resolve(self, source: "DeployedFunction") -> dict[str, Any]:
|
|
72
72
|
"""Needs the whole registry, so it runs when the manifest is built, not at decoration time."""
|
|
73
|
-
target = getattr(self.action, "
|
|
73
|
+
target = getattr(self.action, "__callables__", None)
|
|
74
74
|
if target is None:
|
|
75
75
|
names = [self.action, f"{source.group.name}.{self.action}" if source.group else None]
|
|
76
76
|
target = next((registry[n] for n in names if n in registry), None)
|
|
@@ -227,7 +227,7 @@ def deploy(
|
|
|
227
227
|
def wrapper(*args, **kwargs):
|
|
228
228
|
return f(*args, **kwargs)
|
|
229
229
|
|
|
230
|
-
wrapper.
|
|
230
|
+
wrapper.__callables__ = deployed
|
|
231
231
|
return wrapper
|
|
232
232
|
|
|
233
233
|
return wrap(func) if func is not None else wrap
|
|
@@ -9,9 +9,9 @@ from typing import Any
|
|
|
9
9
|
from pydantic import Field, GetCoreSchemaHandler, GetJsonSchemaHandler
|
|
10
10
|
from pydantic_core import core_schema
|
|
11
11
|
|
|
12
|
-
OUTPUT_DIR_ENV = "
|
|
12
|
+
OUTPUT_DIR_ENV = "CALLABLES_OUTPUT_DIR"
|
|
13
13
|
LOCAL_OUTPUT_DIR = "callables-output" # where `call local` puts files
|
|
14
|
-
FILE_FORMAT = "
|
|
14
|
+
FILE_FORMAT = "callables-file"
|
|
15
15
|
|
|
16
16
|
_saved: list["File"] = []
|
|
17
17
|
_returned: set[Path] = set() # saved copies of files the function returned, not ones it saved alongside
|
|
@@ -10,7 +10,6 @@ from callables.manifest import discover_modules
|
|
|
10
10
|
|
|
11
11
|
SECTION_START = "<!-- callables:start -->"
|
|
12
12
|
SECTION_END = "<!-- callables:end -->"
|
|
13
|
-
LEGACY_SECTIONS = [("<!-- shipfn:start -->", "<!-- shipfn:end -->")] # replaced with the current section
|
|
14
13
|
|
|
15
14
|
SKILL_FRONTMATTER = """---
|
|
16
15
|
name: callables
|
|
@@ -50,16 +49,14 @@ def guide() -> str:
|
|
|
50
49
|
|
|
51
50
|
|
|
52
51
|
def _upsert_section(path: Path) -> str:
|
|
53
|
-
"""Add or refresh the callables section
|
|
52
|
+
"""Add or refresh the callables section, leaving the rest of the file alone."""
|
|
54
53
|
if not path.exists():
|
|
55
54
|
path.write_text(AGENTS_SECTION, encoding="utf-8")
|
|
56
55
|
return "created"
|
|
57
56
|
text = path.read_text(encoding="utf-8")
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
updated = text[:start] + AGENTS_SECTION.rstrip("\n") + text[end + len(end_marker):]
|
|
62
|
-
break
|
|
57
|
+
start, end = text.find(SECTION_START), text.find(SECTION_END)
|
|
58
|
+
if start != -1 and end > start:
|
|
59
|
+
updated = text[:start] + AGENTS_SECTION.rstrip("\n") + text[end + len(SECTION_END):]
|
|
63
60
|
else:
|
|
64
61
|
updated = text.rstrip("\n") + ("\n\n" if text.strip() else "") + AGENTS_SECTION
|
|
65
62
|
if updated == text:
|
|
@@ -100,12 +97,6 @@ def init_project(root: Path, example: bool = True, agents: bool = True) -> list[
|
|
|
100
97
|
|
|
101
98
|
if agents:
|
|
102
99
|
skill = root / ".claude" / "skills" / "callables" / "SKILL.md"
|
|
103
|
-
old_skill = root / ".claude" / "skills" / "shipfn" / "SKILL.md"
|
|
104
|
-
if old_skill.exists(): # written by an older version under the old name; the new one replaces it
|
|
105
|
-
old_skill.unlink()
|
|
106
|
-
if not any(old_skill.parent.iterdir()):
|
|
107
|
-
old_skill.parent.rmdir()
|
|
108
|
-
done.append((str(old_skill.relative_to(root)), "removed (renamed to callables)"))
|
|
109
100
|
content = SKILL_FRONTMATTER + guide()
|
|
110
101
|
existed = skill.exists()
|
|
111
102
|
if existed and skill.read_text(encoding="utf-8") == content:
|
|
@@ -6,12 +6,12 @@ from typing import Any
|
|
|
6
6
|
|
|
7
7
|
from callables.decorator import registry
|
|
8
8
|
|
|
9
|
-
SKIP_DIRS = {".git", ".venv", "venv", "env", "node_modules", "__pycache__", "tests", "test", ".
|
|
9
|
+
SKIP_DIRS = {".git", ".venv", "venv", "env", "node_modules", "__pycache__", "tests", "test", ".callables_sdk", "build", "dist"}
|
|
10
10
|
MANIFEST_VERSION = 1
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def discover_modules(root: Path) -> list[str]:
|
|
14
|
-
"""Dotted names of every module under root that mentions callables
|
|
14
|
+
"""Dotted names of every module under root that mentions callables, so they can be imported."""
|
|
15
15
|
modules = []
|
|
16
16
|
for dirpath, dirnames, filenames in os.walk(root):
|
|
17
17
|
dirnames[:] = sorted(d for d in dirnames if d not in SKIP_DIRS and not d.startswith("."))
|
|
@@ -23,7 +23,7 @@ def discover_modules(root: Path) -> list[str]:
|
|
|
23
23
|
text = path.read_text(encoding="utf-8", errors="ignore")
|
|
24
24
|
except OSError:
|
|
25
25
|
continue
|
|
26
|
-
if
|
|
26
|
+
if "callables" not in text or ("deploy" not in text and "command" not in text):
|
|
27
27
|
continue
|
|
28
28
|
rel = path.relative_to(root).with_suffix("")
|
|
29
29
|
parts = list(rel.parts)
|
|
@@ -3,8 +3,8 @@ and then only that folder is built: its requirements.txt / pyproject.toml, apt.t
|
|
|
3
3
|
import tomllib
|
|
4
4
|
from pathlib import Path, PurePosixPath
|
|
5
5
|
|
|
6
|
-
CONFIG_FILES = ("callables.toml",
|
|
7
|
-
TOOL_KEYS = ("callables",
|
|
6
|
+
CONFIG_FILES = ("callables.toml",)
|
|
7
|
+
TOOL_KEYS = ("callables",)
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ConfigError(ValueError):
|
|
@@ -11,9 +11,9 @@ from pydantic import BaseModel, TypeAdapter
|
|
|
11
11
|
|
|
12
12
|
from callables.files import File, keep_returned, saved_files
|
|
13
13
|
|
|
14
|
-
RESULT_MARKER = "
|
|
14
|
+
RESULT_MARKER = "__CALLABLES_RESULT__"
|
|
15
15
|
# Lines the platform shows only to the function's builders (end users never see stack traces)
|
|
16
|
-
BUILDER_MARKER = "
|
|
16
|
+
BUILDER_MARKER = "__CALLABLES_BUILDER__"
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def to_jsonable(value: Any) -> Any:
|
|
@@ -36,7 +36,7 @@ def resolve(entrypoint: str):
|
|
|
36
36
|
obj: Any = importlib.import_module(module_name)
|
|
37
37
|
for attr in qualname.split("."):
|
|
38
38
|
obj = getattr(obj, attr)
|
|
39
|
-
deployed = getattr(obj, "
|
|
39
|
+
deployed = getattr(obj, "__callables__", None)
|
|
40
40
|
if deployed is None:
|
|
41
41
|
raise RuntimeError(f"{entrypoint} is not decorated with @deploy")
|
|
42
42
|
return deployed
|
|
@@ -51,13 +51,13 @@ def emit(payload: dict[str, Any]) -> None:
|
|
|
51
51
|
def run(entrypoint: str, root: Path) -> int:
|
|
52
52
|
if str(root) not in sys.path:
|
|
53
53
|
sys.path.insert(0, str(root))
|
|
54
|
-
inputs = json.loads(os.environ.pop("
|
|
54
|
+
inputs = json.loads(os.environ.pop("CALLABLES_INPUTS", "{}") or "{}")
|
|
55
55
|
try:
|
|
56
56
|
result = finish(resolve(entrypoint).call(inputs))
|
|
57
57
|
except Exception as exc:
|
|
58
58
|
sys.stdout.flush()
|
|
59
59
|
# On the platform, tag the traceback so only builders see it; locally, print it as-is
|
|
60
|
-
prefix = BUILDER_MARKER if os.environ.get("
|
|
60
|
+
prefix = BUILDER_MARKER if os.environ.get("CALLABLES_RUN_ID") else ""
|
|
61
61
|
for line in traceback.format_exc().rstrip().splitlines():
|
|
62
62
|
print(prefix + line, file=sys.stderr, flush=True)
|
|
63
63
|
emit({"ok": False, "error": f"{type(exc).__name__}: {exc}", "files": saved_files()})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: callables
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Decorate Python functions and push them to Callables: forms, schedules and run history for your team.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://callables.app
|
|
@@ -26,7 +26,7 @@ pip install callables
|
|
|
26
26
|
|
|
27
27
|
Docs: [callables.app/docs](https://callables.app/docs).
|
|
28
28
|
|
|
29
|
-
This installs the `call` command.
|
|
29
|
+
This installs the `call` command.
|
|
30
30
|
|
|
31
31
|
```python
|
|
32
32
|
from typing import Literal
|
|
@@ -88,7 +88,7 @@ python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
|
88
88
|
.venv/bin/pytest
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
The platform (
|
|
91
|
+
The platform (callables-api) depends on this package and copies the installed version into every build, so a release only reaches deployed functions once the API is updated to it. See [RELEASING.md](RELEASING.md).
|
|
92
92
|
|
|
93
93
|
## License
|
|
94
94
|
|
|
@@ -21,8 +21,6 @@ callables.egg-info/dependency_links.txt
|
|
|
21
21
|
callables.egg-info/entry_points.txt
|
|
22
22
|
callables.egg-info/requires.txt
|
|
23
23
|
callables.egg-info/top_level.txt
|
|
24
|
-
shipfn/__init__.py
|
|
25
|
-
shipfn/__main__.py
|
|
26
24
|
tests/test_agent_tools.py
|
|
27
25
|
tests/test_command.py
|
|
28
26
|
tests/test_files.py
|
|
@@ -27,10 +27,9 @@ Source = "https://github.com/callables-app/callables-python"
|
|
|
27
27
|
[project.scripts]
|
|
28
28
|
call = "callables.cli:main"
|
|
29
29
|
callables = "callables.cli:main"
|
|
30
|
-
shipfn = "callables.cli:main" # the old name, kept for existing scripts
|
|
31
30
|
|
|
32
31
|
[tool.setuptools.packages.find]
|
|
33
|
-
include = ["callables*"
|
|
32
|
+
include = ["callables*"]
|
|
34
33
|
|
|
35
34
|
[tool.setuptools.package-data]
|
|
36
35
|
callables = ["py.typed", "GUIDE.md"]
|
|
@@ -14,7 +14,7 @@ from callables.schema import input_model
|
|
|
14
14
|
def isolated(tmp_path, monkeypatch):
|
|
15
15
|
registry.clear()
|
|
16
16
|
files_mod._saved.clear()
|
|
17
|
-
monkeypatch.setenv("
|
|
17
|
+
monkeypatch.setenv("CALLABLES_OUTPUT_DIR", str(tmp_path / "out"))
|
|
18
18
|
yield
|
|
19
19
|
registry.clear()
|
|
20
20
|
files_mod._saved.clear()
|
|
@@ -143,17 +143,3 @@ def test_init_sets_up_a_repo_and_is_safe_to_rerun(tmp_path):
|
|
|
143
143
|
# An outdated section is refreshed in place
|
|
144
144
|
(tmp_path / "AGENTS.md").write_text(f"top\n{SECTION_START}\nold\n{SECTION_END}\nbottom\n")
|
|
145
145
|
assert dict(init_project(tmp_path, example=False))["AGENTS.md"] == "updated"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def test_init_replaces_what_the_shipfn_version_wrote(tmp_path):
|
|
149
|
-
(tmp_path / "AGENTS.md").write_text("top\n<!-- shipfn:start -->\nold\n<!-- shipfn:end -->\nbottom\n")
|
|
150
|
-
old_skill = tmp_path / ".claude/skills/shipfn/SKILL.md"
|
|
151
|
-
old_skill.parent.mkdir(parents=True)
|
|
152
|
-
old_skill.write_text("old guide")
|
|
153
|
-
done = dict(init_project(tmp_path, example=False))
|
|
154
|
-
assert done[".claude/skills/shipfn/SKILL.md"].startswith("removed") and not old_skill.parent.exists()
|
|
155
|
-
agents = (tmp_path / "AGENTS.md").read_text()
|
|
156
|
-
assert "shipfn:start" not in agents and agents.count(SECTION_START) == 1
|
|
157
|
-
assert agents.startswith("top\n" + SECTION_START) and agents.endswith(SECTION_END + "\nbottom\n")
|
|
158
|
-
refreshed = (tmp_path / "AGENTS.md").read_text()
|
|
159
|
-
assert refreshed.startswith("top\n") and refreshed.endswith("bottom\n") and "old" not in refreshed
|
|
@@ -14,7 +14,7 @@ from callables.schema import input_schema, output_kind
|
|
|
14
14
|
def isolated(tmp_path, monkeypatch):
|
|
15
15
|
registry.clear()
|
|
16
16
|
files_mod._saved.clear()
|
|
17
|
-
monkeypatch.setenv("
|
|
17
|
+
monkeypatch.setenv("CALLABLES_OUTPUT_DIR", str(tmp_path / "out"))
|
|
18
18
|
yield
|
|
19
19
|
registry.clear()
|
|
20
20
|
files_mod._saved.clear()
|
|
@@ -26,8 +26,8 @@ def test_file_parameters_become_upload_fields():
|
|
|
26
26
|
...
|
|
27
27
|
|
|
28
28
|
props = input_schema(clean)["properties"]
|
|
29
|
-
assert props["sheet"] == {"type": "string", "format": "
|
|
30
|
-
assert {"type": "string", "format": "
|
|
29
|
+
assert props["sheet"] == {"type": "string", "format": "callables-file", "title": "Sheet", "x-accept": ".csv,.xlsx"}
|
|
30
|
+
assert {"type": "string", "format": "callables-file"} in props["notes"]["anyOf"]
|
|
31
31
|
assert input_schema(clean)["required"] == ["sheet"]
|
|
32
32
|
assert output_kind(clean) == "file"
|
|
33
33
|
|
|
@@ -50,7 +50,7 @@ def test_runtime_hands_uploads_in_and_files_out(tmp_path, capsys, monkeypatch):
|
|
|
50
50
|
" out.write_text(sheet.read_text() * 2)\n"
|
|
51
51
|
" return File(out, name=f'doubled-{sheet.name}')\n"
|
|
52
52
|
)
|
|
53
|
-
monkeypatch.setenv("
|
|
53
|
+
monkeypatch.setenv("CALLABLES_INPUTS", json.dumps({"sheet": {"path": str(upload), "name": "Sales Q3.csv"}}))
|
|
54
54
|
assert run("fx_double:double", tmp_path) == 0
|
|
55
55
|
payload = json.loads(capsys.readouterr().out.splitlines()[-1].removeprefix(RESULT_MARKER))
|
|
56
56
|
assert payload["ok"] and payload["value"] is None
|
|
@@ -63,7 +63,7 @@ def test_runtime_hands_uploads_in_and_files_out(tmp_path, capsys, monkeypatch):
|
|
|
63
63
|
|
|
64
64
|
def test_missing_upload_is_a_validation_error(tmp_path, capsys, monkeypatch):
|
|
65
65
|
(tmp_path / "fx_missing.py").write_text("from callables import deploy, File\n@deploy\ndef f(sheet: File) -> str:\n return 'x'\n")
|
|
66
|
-
monkeypatch.setenv("
|
|
66
|
+
monkeypatch.setenv("CALLABLES_INPUTS", json.dumps({"sheet": {"path": str(tmp_path / "nope.csv")}}))
|
|
67
67
|
assert run("fx_missing:f", tmp_path) == 1
|
|
68
68
|
payload = json.loads(capsys.readouterr().out.splitlines()[-1].removeprefix(RESULT_MARKER))
|
|
69
69
|
assert "File not found" in payload["error"]
|
|
@@ -17,11 +17,9 @@ def isolated():
|
|
|
17
17
|
def test_whole_repo_unless_a_root_is_set(tmp_path):
|
|
18
18
|
assert build_root(tmp_path) == (tmp_path.resolve(), None)
|
|
19
19
|
(tmp_path / "automations").mkdir()
|
|
20
|
-
(tmp_path / "pyproject.toml").write_text('[tool.
|
|
21
|
-
assert build_root(tmp_path) == ((tmp_path / "automations").resolve(), "pyproject.toml [tool.
|
|
22
|
-
(tmp_path / "
|
|
23
|
-
assert build_root(tmp_path) == ((tmp_path / "automations").resolve(), "shipfn.toml")
|
|
24
|
-
(tmp_path / "callables.toml").write_text('root = "automations"\n') # and the current name over the old one
|
|
20
|
+
(tmp_path / "pyproject.toml").write_text('[tool.callables]\nroot = "automations/"\n')
|
|
21
|
+
assert build_root(tmp_path) == ((tmp_path / "automations").resolve(), "pyproject.toml [tool.callables]")
|
|
22
|
+
(tmp_path / "callables.toml").write_text('root = "./automations"\n') # a config file wins over pyproject.toml
|
|
25
23
|
assert build_root(tmp_path) == ((tmp_path / "automations").resolve(), "callables.toml")
|
|
26
24
|
|
|
27
25
|
|
|
@@ -42,13 +40,13 @@ def test_root_must_be_a_folder_in_the_repo(tmp_path, value, message):
|
|
|
42
40
|
repo = tmp_path / "repo"
|
|
43
41
|
repo.mkdir()
|
|
44
42
|
(repo / "escape").symlink_to(tmp_path)
|
|
45
|
-
(repo / "
|
|
43
|
+
(repo / "callables.toml").write_text(f"root = {value}\n")
|
|
46
44
|
with pytest.raises(ConfigError, match=message):
|
|
47
45
|
build_root(repo)
|
|
48
46
|
|
|
49
47
|
|
|
50
48
|
def test_commands_use_the_same_folder_the_platform_builds(tmp_path, monkeypatch, capsys):
|
|
51
|
-
(tmp_path / "
|
|
49
|
+
(tmp_path / "callables.toml").write_text('root = "autos"\n')
|
|
52
50
|
(tmp_path / "autos").mkdir()
|
|
53
51
|
(tmp_path / "autos" / "proj_root_jobs.py").write_text(
|
|
54
52
|
"from callables import deploy\n\n@deploy()\ndef proj_root_fn() -> str:\n return 'hi'\n")
|
|
@@ -95,16 +95,16 @@ def test_runtime_emits_result_and_errors(tmp_path, capsys, monkeypatch):
|
|
|
95
95
|
pkg.mkdir()
|
|
96
96
|
(pkg / "__init__.py").write_text("")
|
|
97
97
|
(pkg / "m.py").write_text(
|
|
98
|
-
"from datetime import date\nfrom
|
|
98
|
+
"from datetime import date\nfrom callables import deploy\n"
|
|
99
99
|
"@deploy\ndef rt_ok(n: int = 2) -> list[dict]:\n print('working')\n return [{'n': n, 'd': date(2026, 1, 1)}]\n"
|
|
100
100
|
"@deploy\ndef rt_bad() -> None:\n raise ValueError('nope')\n"
|
|
101
101
|
)
|
|
102
|
-
monkeypatch.setenv("
|
|
102
|
+
monkeypatch.setenv("CALLABLES_INPUTS", json.dumps({"n": 5}))
|
|
103
103
|
assert run("autos.m:rt_ok", tmp_path) == 0
|
|
104
104
|
out = capsys.readouterr().out.strip().splitlines()
|
|
105
105
|
assert out[0] == "working"
|
|
106
106
|
assert json.loads(out[-1].removeprefix(RESULT_MARKER)) == {"ok": True, "value": [{"n": 5, "d": "2026-01-01"}], "files": []}
|
|
107
|
-
assert "
|
|
107
|
+
assert "CALLABLES_INPUTS" not in os.environ # inputs are consumed, not left for user code
|
|
108
108
|
|
|
109
109
|
assert run("autos.m:rt_bad", tmp_path) == 1
|
|
110
110
|
last = capsys.readouterr().out.strip().splitlines()[-1]
|
|
@@ -130,13 +130,3 @@ def test_manifest_reports_import_errors(tmp_path):
|
|
|
130
130
|
manifest = build_manifest(tmp_path)
|
|
131
131
|
assert manifest["errors"][0]["module"] == "broken"
|
|
132
132
|
assert "not_a_real_module_xyz" in manifest["errors"][0]["error"]
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def test_shipfn_is_the_old_name_for_callables():
|
|
136
|
-
import shipfn
|
|
137
|
-
import shipfn.files
|
|
138
|
-
|
|
139
|
-
import callables
|
|
140
|
-
import callables.files
|
|
141
|
-
|
|
142
|
-
assert shipfn.deploy is callables.deploy and shipfn.files is callables.files and shipfn.__version__ == callables.__version__
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"""The old name of the callables package. `from shipfn import deploy` and `import shipfn.files` keep working, so
|
|
2
|
-
repos written before the rename still deploy. New code imports callables."""
|
|
3
|
-
import importlib
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
from callables import * # noqa: F401,F403
|
|
7
|
-
from callables import __all__, __version__ # noqa: F401
|
|
8
|
-
|
|
9
|
-
for _name in ("checks", "cli", "commands", "decorator", "files", "init", "manifest", "project", "runtime", "schema"):
|
|
10
|
-
sys.modules[f"{__name__}.{_name}"] = globals()[_name] = importlib.import_module(f"callables.{_name}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|