lumera 0.54.1__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.
Files changed (90) hide show
  1. {lumera-0.54.1 → lumera-0.55.0.dev3011}/PKG-INFO +1 -1
  2. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/automations.py +78 -1
  3. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera.egg-info/PKG-INFO +1 -1
  4. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera.egg-info/SOURCES.txt +1 -0
  5. {lumera-0.54.1 → lumera-0.55.0.dev3011}/pyproject.toml +1 -1
  6. lumera-0.55.0.dev3011/tests/test_background_automations.py +77 -0
  7. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/__init__.py +0 -0
  8. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/_live.py +0 -0
  9. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/_utils.py +0 -0
  10. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/agents.py +0 -0
  11. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/documents.py +0 -0
  12. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/email.py +0 -0
  13. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/exceptions.py +0 -0
  14. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/files.py +0 -0
  15. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/flags.py +0 -0
  16. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/function_resources.py +0 -0
  17. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/__init__.py +0 -0
  18. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/__main__.py +0 -0
  19. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_artifacts.py +0 -0
  20. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_config.py +0 -0
  21. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_context.py +0 -0
  22. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_contract.py +0 -0
  23. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_dependencies.py +0 -0
  24. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_errors.py +0 -0
  25. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_execution.py +0 -0
  26. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_jsonschema.py +0 -0
  27. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_registry.py +0 -0
  28. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_remote.py +0 -0
  29. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_runner.py +0 -0
  30. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/_runtime.py +0 -0
  31. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/functions/testing.py +0 -0
  32. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/google.py +0 -0
  33. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/__init__.py +0 -0
  34. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/bill.py +0 -0
  35. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/client.py +0 -0
  36. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/finch.py +0 -0
  37. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/google.py +0 -0
  38. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/kafka.py +0 -0
  39. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/netsuite.py +0 -0
  40. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/personal.py +0 -0
  41. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/salesforce.py +0 -0
  42. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/slack.py +0 -0
  43. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/integrations/snowflake.py +0 -0
  44. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/llm.py +0 -0
  45. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/pb.py +0 -0
  46. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/__init__.py +0 -0
  47. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/__main__.py +0 -0
  48. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_api_child.py +0 -0
  49. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_archive.py +0 -0
  50. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_automation_event.py +0 -0
  51. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_builder.py +0 -0
  52. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_config.py +0 -0
  53. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_contracts.py +0 -0
  54. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_errors.py +0 -0
  55. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_projection.py +0 -0
  56. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_rpc_diagnostics.py +0 -0
  57. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_rpc_event.py +0 -0
  58. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_rpc_process.py +0 -0
  59. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_runtime.py +0 -0
  60. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_runtime_child.py +0 -0
  61. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_schemas.py +0 -0
  62. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_target.py +0 -0
  63. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/releases/_timing.py +0 -0
  64. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/sdk.py +0 -0
  65. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/storage.py +0 -0
  66. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/transactions.py +0 -0
  67. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera/webhooks.py +0 -0
  68. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera.egg-info/dependency_links.txt +0 -0
  69. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera.egg-info/requires.txt +0 -0
  70. {lumera-0.54.1 → lumera-0.55.0.dev3011}/lumera.egg-info/top_level.txt +0 -0
  71. {lumera-0.54.1 → lumera-0.55.0.dev3011}/setup.cfg +0 -0
  72. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_agents_live.py +0 -0
  73. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_automations.py +0 -0
  74. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_documents.py +0 -0
  75. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_flags.py +0 -0
  76. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_function_resources.py +0 -0
  77. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integration_client.py +0 -0
  78. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_bill.py +0 -0
  79. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_finch.py +0 -0
  80. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_google.py +0 -0
  81. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_kafka.py +0 -0
  82. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_netsuite.py +0 -0
  83. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_personal.py +0 -0
  84. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_salesforce.py +0 -0
  85. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_slack.py +0 -0
  86. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_integrations_snowflake.py +0 -0
  87. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_lazy_imports.py +0 -0
  88. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_sdk.py +0 -0
  89. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_transactions.py +0 -0
  90. {lumera-0.54.1 → lumera-0.55.0.dev3011}/tests/test_webhooks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lumera
3
- Version: 0.54.1
3
+ Version: 0.55.0.dev3011
4
4
  Summary: SDK for building on Lumera platform
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: requests>=2.33.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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lumera
3
- Version: 0.54.1
3
+ Version: 0.55.0.dev3011
4
4
  Summary: SDK for building on Lumera platform
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: requests>=2.33.0
@@ -68,6 +68,7 @@ lumera/releases/_target.py
68
68
  lumera/releases/_timing.py
69
69
  tests/test_agents_live.py
70
70
  tests/test_automations.py
71
+ tests/test_background_automations.py
71
72
  tests/test_documents.py
72
73
  tests/test_flags.py
73
74
  tests/test_function_resources.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lumera"
3
- version = "0.54.1"
3
+ version = "0.55.0.dev3011"
4
4
  description = "SDK for building on Lumera platform"
5
5
  requires-python = ">=3.11"
6
6
  dependencies = [
@@ -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="")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes