lumera 0.54.0__tar.gz → 0.55.0.dev3011__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.
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/PKG-INFO +1 -1
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/automations.py +78 -1
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/function_resources.py +3 -1
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/__main__.py +22 -13
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_api_child.py +1 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_builder.py +3 -1
- lumera-0.55.0.dev3011/lumera/releases/_timing.py +33 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera.egg-info/PKG-INFO +1 -1
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera.egg-info/SOURCES.txt +2 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/pyproject.toml +1 -1
- lumera-0.55.0.dev3011/tests/test_background_automations.py +77 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_function_resources.py +12 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/__init__.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/_live.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/_utils.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/agents.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/documents.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/email.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/exceptions.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/files.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/flags.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/__init__.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/__main__.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_artifacts.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_config.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_context.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_contract.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_dependencies.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_errors.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_execution.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_jsonschema.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_registry.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_remote.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_runner.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/_runtime.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/functions/testing.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/google.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/__init__.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/bill.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/client.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/finch.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/google.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/kafka.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/netsuite.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/personal.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/salesforce.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/slack.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/integrations/snowflake.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/llm.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/pb.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/__init__.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_archive.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_automation_event.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_config.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_contracts.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_errors.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_projection.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_rpc_diagnostics.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_rpc_event.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_rpc_process.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_runtime.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_runtime_child.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_schemas.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/releases/_target.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/sdk.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/storage.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/transactions.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera/webhooks.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera.egg-info/dependency_links.txt +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera.egg-info/requires.txt +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/lumera.egg-info/top_level.txt +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/setup.cfg +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_agents_live.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_automations.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_documents.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_flags.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integration_client.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_bill.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_finch.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_google.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_kafka.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_netsuite.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_personal.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_salesforce.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_slack.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_integrations_snowflake.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_lazy_imports.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_sdk.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_transactions.py +0 -0
- {lumera-0.54.0 → lumera-0.55.0.dev3011}/tests/test_webhooks.py +0 -0
|
@@ -279,7 +279,17 @@ class Run:
|
|
|
279
279
|
|
|
280
280
|
@property
|
|
281
281
|
def status(self) -> str:
|
|
282
|
-
return self._data.get("status", "")
|
|
282
|
+
return self.background_job.get("status", self._data.get("status", ""))
|
|
283
|
+
|
|
284
|
+
@property
|
|
285
|
+
def background_job(self) -> dict[str, Any]:
|
|
286
|
+
"""Durable job progress; empty for ordinary automation runs."""
|
|
287
|
+
return self._data.get("background_job") or {}
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def active_run_id(self) -> str:
|
|
291
|
+
"""Current/final attempt ID, for retrieving that attempt's logs."""
|
|
292
|
+
return self.background_job.get("active_run_id", self.id)
|
|
283
293
|
|
|
284
294
|
@property
|
|
285
295
|
def inputs(self) -> dict[str, Any]:
|
|
@@ -293,10 +303,14 @@ class Run:
|
|
|
293
303
|
|
|
294
304
|
@property
|
|
295
305
|
def result(self) -> dict[str, Any] | None:
|
|
306
|
+
if self.background_job:
|
|
307
|
+
return self.background_job.get("result")
|
|
296
308
|
return self._data.get("result")
|
|
297
309
|
|
|
298
310
|
@property
|
|
299
311
|
def error(self) -> str | None:
|
|
312
|
+
if self.background_job:
|
|
313
|
+
return self.background_job.get("error")
|
|
300
314
|
return self._data.get("error")
|
|
301
315
|
|
|
302
316
|
@property
|
|
@@ -669,6 +683,69 @@ def run(
|
|
|
669
683
|
return Run(result)
|
|
670
684
|
|
|
671
685
|
|
|
686
|
+
def run_background(
|
|
687
|
+
automation_id: str,
|
|
688
|
+
inputs: Mapping[str, Any] | None = None,
|
|
689
|
+
*,
|
|
690
|
+
external_id: str,
|
|
691
|
+
safe_to_retry: bool = False,
|
|
692
|
+
max_attempts: int = 1,
|
|
693
|
+
notify_agent: bool = True,
|
|
694
|
+
) -> Run:
|
|
695
|
+
"""Start a durable background job from an authenticated agent session.
|
|
696
|
+
|
|
697
|
+
Returns immediately. Reuse ``external_id`` if submission is retried.
|
|
698
|
+
JSON inputs only; file uploads and input changes are unsupported. Progress
|
|
699
|
+
is available through ``get_run(run.id)`` and ``run.background_job``.
|
|
700
|
+
|
|
701
|
+
Workers save their own checkpoints and return ``background_retry()`` when
|
|
702
|
+
more work remains or a transient read failed. Ordinary exceptions stop the
|
|
703
|
+
job. With ``safe_to_retry=True``, timed-out attempts may also be retried.
|
|
704
|
+
Each attempt has a separate run ID. Jobs stop after at most ten attempts or
|
|
705
|
+
one hour; code/permission changes stop further execution. The originating
|
|
706
|
+
chat receives a completion notification when ``notify_agent=True``.
|
|
707
|
+
"""
|
|
708
|
+
if not automation_id.strip() or not external_id.strip():
|
|
709
|
+
raise ValueError("automation_id and external_id are required")
|
|
710
|
+
if (
|
|
711
|
+
isinstance(max_attempts, bool)
|
|
712
|
+
or not isinstance(max_attempts, int)
|
|
713
|
+
or not 1 <= max_attempts <= 10
|
|
714
|
+
or (max_attempts > 1 and not safe_to_retry)
|
|
715
|
+
):
|
|
716
|
+
raise ValueError("max_attempts must be 1..10; retries require safe_to_retry=True")
|
|
717
|
+
data = _api_request(
|
|
718
|
+
"POST",
|
|
719
|
+
"automation-runs",
|
|
720
|
+
json_body={
|
|
721
|
+
"automation_id": automation_id.strip(),
|
|
722
|
+
"inputs": dict(inputs or {}),
|
|
723
|
+
"external_id": external_id.strip(),
|
|
724
|
+
"background": {
|
|
725
|
+
"safe_to_retry": safe_to_retry,
|
|
726
|
+
"max_attempts": max_attempts,
|
|
727
|
+
"notify_agent": notify_agent,
|
|
728
|
+
},
|
|
729
|
+
},
|
|
730
|
+
)
|
|
731
|
+
return Run(data)
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
def background_retry(*, after_seconds: int = 30) -> dict[str, Any]:
|
|
735
|
+
"""Return from a checkpointed worker to request a bounded next attempt.
|
|
736
|
+
|
|
737
|
+
Save progress before returning. Only use for safely repeatable work and
|
|
738
|
+
transient errors; authorization failures and code bugs should raise.
|
|
739
|
+
"""
|
|
740
|
+
if (
|
|
741
|
+
isinstance(after_seconds, bool)
|
|
742
|
+
or not isinstance(after_seconds, int)
|
|
743
|
+
or not 1 <= after_seconds <= 900
|
|
744
|
+
):
|
|
745
|
+
raise ValueError("after_seconds must be an integer between 1 and 900")
|
|
746
|
+
return {"_lumera_background_retry": {"after_seconds": after_seconds}}
|
|
747
|
+
|
|
748
|
+
|
|
672
749
|
def run_by_external_id(
|
|
673
750
|
external_id: str,
|
|
674
751
|
inputs: Mapping[str, Any] | None = None,
|
|
@@ -75,7 +75,7 @@ def list_function_versions(
|
|
|
75
75
|
return _mapping(payload, "Function versions")
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
def deploy_runtime(project: str, release: str) -> dict[str, Any]:
|
|
78
|
+
def deploy_runtime(project: str, release: str, *, force: bool = False) -> dict[str, Any]:
|
|
79
79
|
"""Deploy a release to the project's mutable App and pinned Function runtime."""
|
|
80
80
|
project_ref = _required_ref(project, "project")
|
|
81
81
|
release_ref = _required_ref(release, "release")
|
|
@@ -83,6 +83,8 @@ def deploy_runtime(project: str, release: str) -> dict[str, Any]:
|
|
|
83
83
|
f"projects/{quote(project_ref, safe='')}/runtime-releases/"
|
|
84
84
|
f"{quote(release_ref, safe='')}/deploy"
|
|
85
85
|
)
|
|
86
|
+
if force:
|
|
87
|
+
path += "?force=true"
|
|
86
88
|
payload = _api_request("POST", path, json_body={}, timeout=900)
|
|
87
89
|
return _mapping(payload, "runtime deployment")
|
|
88
90
|
|
|
@@ -17,6 +17,7 @@ from ._archive import inspect_archive
|
|
|
17
17
|
from ._builder import build_target_release
|
|
18
18
|
from ._errors import ReleaseError
|
|
19
19
|
from ._runtime import RuntimeMode, contract_test_release
|
|
20
|
+
from ._timing import release_stage
|
|
20
21
|
|
|
21
22
|
PROTOCOL_VERSION = 1
|
|
22
23
|
|
|
@@ -72,6 +73,9 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
72
73
|
runtime = commands.add_parser("deploy-runtime")
|
|
73
74
|
runtime.add_argument("release")
|
|
74
75
|
runtime.add_argument("--project", required=True)
|
|
76
|
+
runtime.add_argument(
|
|
77
|
+
"--force", action="store_true", help="Restart even a healthy unchanged runtime"
|
|
78
|
+
)
|
|
75
79
|
|
|
76
80
|
project = commands.add_parser("deploy-project")
|
|
77
81
|
project.add_argument("--project", required=True)
|
|
@@ -158,29 +162,34 @@ def _run(args: argparse.Namespace) -> dict[str, Any]:
|
|
|
158
162
|
],
|
|
159
163
|
)
|
|
160
164
|
if args.command == "deploy-runtime":
|
|
161
|
-
result = deploy_runtime(args.project, args.release)
|
|
165
|
+
result = deploy_runtime(args.project, args.release, force=getattr(args, "force", False))
|
|
162
166
|
return _success("deploy-runtime", deployment=result)
|
|
163
167
|
if args.command == "deploy-project":
|
|
164
168
|
with tempfile.TemporaryDirectory(prefix="lumera-project-release-") as temporary:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
with release_stage("build"):
|
|
170
|
+
built = build_target_release(project_root, Path(temporary))
|
|
171
|
+
contract_results = []
|
|
172
|
+
for mode in _declared_contract_modes(built.release_manifest):
|
|
173
|
+
with release_stage(f"contract.{mode}"):
|
|
174
|
+
contract_results.append(
|
|
175
|
+
contract_test_release(
|
|
176
|
+
built.archive_path,
|
|
177
|
+
mode=mode,
|
|
178
|
+
expected_digest=built.release_digest,
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
with release_stage("upload"):
|
|
182
|
+
uploaded = deploy_release(
|
|
183
|
+
args.project,
|
|
168
184
|
built.archive_path,
|
|
169
|
-
mode=mode,
|
|
170
185
|
expected_digest=built.release_digest,
|
|
171
186
|
)
|
|
172
|
-
for mode in _declared_contract_modes(built.release_manifest)
|
|
173
|
-
]
|
|
174
|
-
uploaded = deploy_release(
|
|
175
|
-
args.project,
|
|
176
|
-
built.archive_path,
|
|
177
|
-
expected_digest=built.release_digest,
|
|
178
|
-
)
|
|
179
187
|
release = uploaded.get("release")
|
|
180
188
|
release_id = str(release.get("id", "")) if isinstance(release, dict) else ""
|
|
181
189
|
if not release_id:
|
|
182
190
|
raise ValueError("release upload returned no release ID")
|
|
183
|
-
|
|
191
|
+
with release_stage("activate"):
|
|
192
|
+
deployment = deploy_runtime(args.project, release_id)
|
|
184
193
|
return _success(
|
|
185
194
|
"deploy-project",
|
|
186
195
|
release_digest=built.release_digest,
|
|
@@ -362,6 +362,7 @@ def _runtime_health(release_digest: str, runtime_abi: str) -> dict[str, object]:
|
|
|
362
362
|
"release_digest": release_digest,
|
|
363
363
|
"runtime_abi": runtime_abi,
|
|
364
364
|
"image_digest": os.environ.get("FUNCTIONS_RUNTIME_IMAGE_DIGEST", ""),
|
|
365
|
+
"runtime_generation": os.environ.get("LUMERA_RUNTIME_GENERATION", ""),
|
|
365
366
|
# Retain v2 for backends deployed before App-only Automation support.
|
|
366
367
|
"runtime_features": [FUNCTION_RPC_FEATURE, "automation_rpc_v2", AUTOMATION_RPC_FEATURE],
|
|
367
368
|
}
|
|
@@ -22,6 +22,7 @@ from ._contracts import (
|
|
|
22
22
|
)
|
|
23
23
|
from ._errors import ReleaseBuildError
|
|
24
24
|
from ._target import prepare_target_vendor
|
|
25
|
+
from ._timing import release_stage
|
|
25
26
|
|
|
26
27
|
_EXCLUDED_COMPONENTS: Final = frozenset(
|
|
27
28
|
{
|
|
@@ -74,7 +75,8 @@ def build_target_release(
|
|
|
74
75
|
output_root = Path(output_directory).expanduser().resolve()
|
|
75
76
|
output_root.mkdir(parents=True, exist_ok=True)
|
|
76
77
|
with tempfile.TemporaryDirectory(prefix="lumera-target-vendor-") as temporary:
|
|
77
|
-
|
|
78
|
+
with release_stage("dependencies"):
|
|
79
|
+
target = prepare_target_vendor(project_root, Path(temporary) / "vendor")
|
|
78
80
|
return build_release(
|
|
79
81
|
project_root,
|
|
80
82
|
output_root,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Content-free release stage timing on stderr; stdout stays the CLI protocol."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
from contextlib import contextmanager
|
|
9
|
+
from typing import Iterator
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@contextmanager
|
|
13
|
+
def release_stage(stage: str) -> Iterator[None]:
|
|
14
|
+
started = time.perf_counter()
|
|
15
|
+
success = False
|
|
16
|
+
try:
|
|
17
|
+
yield
|
|
18
|
+
success = True
|
|
19
|
+
finally:
|
|
20
|
+
try:
|
|
21
|
+
print(
|
|
22
|
+
json.dumps(
|
|
23
|
+
{
|
|
24
|
+
"event.name": "release.stage",
|
|
25
|
+
"stage": stage,
|
|
26
|
+
"duration_ms": round((time.perf_counter() - started) * 1000, 1),
|
|
27
|
+
"success": success,
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
file=sys.stderr,
|
|
31
|
+
)
|
|
32
|
+
except (OSError, ValueError):
|
|
33
|
+
pass # Diagnostics cannot turn a completed deploy into a failure.
|
|
@@ -65,8 +65,10 @@ lumera/releases/_runtime.py
|
|
|
65
65
|
lumera/releases/_runtime_child.py
|
|
66
66
|
lumera/releases/_schemas.py
|
|
67
67
|
lumera/releases/_target.py
|
|
68
|
+
lumera/releases/_timing.py
|
|
68
69
|
tests/test_agents_live.py
|
|
69
70
|
tests/test_automations.py
|
|
71
|
+
tests/test_background_automations.py
|
|
70
72
|
tests/test_documents.py
|
|
71
73
|
tests/test_flags.py
|
|
72
74
|
tests/test_function_resources.py
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from lumera import automations
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_background_submission_returns_without_waiting(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
9
|
+
calls = []
|
|
10
|
+
|
|
11
|
+
def api(method: str, path: str, **kwargs: object) -> dict[str, Any]:
|
|
12
|
+
calls.append((method, path, kwargs["json_body"]))
|
|
13
|
+
return {
|
|
14
|
+
"id": "root",
|
|
15
|
+
"status": "queued",
|
|
16
|
+
"background_job": {"status": "queued", "active_run_id": "root"},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
monkeypatch.setattr(automations, "_api_request", api)
|
|
20
|
+
job = automations.run_background(
|
|
21
|
+
"auto", inputs={"window": 30}, external_id="seed-v1", safe_to_retry=True, max_attempts=5
|
|
22
|
+
)
|
|
23
|
+
assert job.id == "root"
|
|
24
|
+
assert job.active_run_id == "root"
|
|
25
|
+
assert job.status == "queued"
|
|
26
|
+
assert len(calls) == 1
|
|
27
|
+
assert calls[0][2]["external_id"] == "seed-v1"
|
|
28
|
+
assert calls[0][2]["background"] == {
|
|
29
|
+
"safe_to_retry": True,
|
|
30
|
+
"max_attempts": 5,
|
|
31
|
+
"notify_agent": True,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_background_status_uses_job_not_first_attempt() -> None:
|
|
36
|
+
job = automations.Run(
|
|
37
|
+
{
|
|
38
|
+
"id": "root",
|
|
39
|
+
"status": "succeeded",
|
|
40
|
+
"result": {"_lumera_background_retry": {"after_seconds": 30}},
|
|
41
|
+
"background_job": {"status": "running", "active_run_id": "second"},
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
assert not job.is_terminal
|
|
45
|
+
assert job.result is None
|
|
46
|
+
assert job.active_run_id == "second"
|
|
47
|
+
job = automations.Run(
|
|
48
|
+
{
|
|
49
|
+
"id": "root",
|
|
50
|
+
"status": "timeout",
|
|
51
|
+
"error": "first attempt timed out",
|
|
52
|
+
"background_job": {
|
|
53
|
+
"status": "succeeded",
|
|
54
|
+
"result": {"rows": 55},
|
|
55
|
+
"active_run_id": "second",
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
assert job.is_terminal
|
|
60
|
+
assert job.result == {"rows": 55}
|
|
61
|
+
assert job.error is None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@pytest.mark.parametrize("delay", [0, -1, 901, True, 1.5])
|
|
65
|
+
def test_retry_requires_bounded_integer_delay(delay: int | float) -> None:
|
|
66
|
+
with pytest.raises(ValueError):
|
|
67
|
+
automations.background_retry(after_seconds=delay)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_retry_marker_and_submission_limits() -> None:
|
|
71
|
+
assert automations.background_retry(after_seconds=60) == {
|
|
72
|
+
"_lumera_background_retry": {"after_seconds": 60}
|
|
73
|
+
}
|
|
74
|
+
with pytest.raises(ValueError):
|
|
75
|
+
automations.run_background("auto", external_id="seed", max_attempts=2)
|
|
76
|
+
with pytest.raises(ValueError):
|
|
77
|
+
automations.run_background("auto", external_id="")
|
|
@@ -98,3 +98,15 @@ def test_remote_invoke_preserves_explicit_empty_input(
|
|
|
98
98
|
function_resources.invoke_function("finance", "context:read", {})
|
|
99
99
|
|
|
100
100
|
assert captured["json_body"] == {"input": {}}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_runtime_force_restart_is_explicit(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
104
|
+
paths = []
|
|
105
|
+
|
|
106
|
+
def request(_method: str, path: str, **_kwargs: object) -> dict:
|
|
107
|
+
paths.append(path)
|
|
108
|
+
return {}
|
|
109
|
+
|
|
110
|
+
monkeypatch.setattr(function_resources, "_api_request", request)
|
|
111
|
+
function_resources.deploy_runtime("finance", "release/1", force=True)
|
|
112
|
+
assert paths == ["projects/finance/runtime-releases/release%2F1/deploy?force=true"]
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|