Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion openadapt/quickstart/everyday.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,15 @@ def _probe_baseline(
f"local_state verifier unavailable in installed openadapt-flow: {exc}",
)

cfg = VerifyConfig.model_validate(verify_doc)
from pydantic import ValidationError

try:
cfg = VerifyConfig.model_validate(verify_doc)
except ValidationError as exc:
return (
None,
f"local_state probe unsupported by installed openadapt-flow: {exc}",
)
sources = list(cfg.verifier.local_state or [])
if verifier_factory is not None:
verifier = verifier_factory(sources, platform=platform)
Expand Down
33 changes: 26 additions & 7 deletions tests/test_everyday_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,34 @@
)

try:
from openadapt_flow.runtime.effects.local_state import LocalStateVerifier
from openadapt_flow.runtime.effects.local_state import (
LocalStateVerifier,
MacOSCalendarEventSource,
MacOSNightShiftSource,
WindowsNightLightSource,
)
from openadapt_flow.verify_run import VerifyConfig
except ImportError: # launcher CI installs released openadapt-flow without local_state

_HAS_EVERYDAY_PROBES = all(
cls is not None
for cls in (
LocalStateVerifier,
MacOSCalendarEventSource,
MacOSNightShiftSource,
WindowsNightLightSource,
VerifyConfig,
)
)
except (
ImportError
): # launcher CI installs released openadapt-flow without everyday probes
LocalStateVerifier = None # type: ignore[assignment]
VerifyConfig = None # type: ignore[assignment]
_HAS_EVERYDAY_PROBES = False

_REQUIRES_LOCAL_STATE = pytest.mark.skipif(
LocalStateVerifier is None,
reason="openadapt_flow.runtime.effects.local_state not in installed openadapt-flow",
not _HAS_EVERYDAY_PROBES,
reason="everyday local_state probes not in installed openadapt-flow",
)


Expand All @@ -41,7 +60,7 @@ def test_build_night_shift_contracts_macos_and_windows_with_revert() -> None:
assert rev_mac["effects"][0]["value"] == "false"
assert params_mac["target_enabled"] == "true"
assert params_mac["restore_enabled"] == "false"
if LocalStateVerifier is not None and VerifyConfig is not None:
if _HAS_EVERYDAY_PROBES:
VerifyConfig.model_validate(fwd_mac)
VerifyConfig.model_validate(rev_mac)

Expand All @@ -52,7 +71,7 @@ def test_build_night_shift_contracts_macos_and_windows_with_revert() -> None:
assert fwd_win["effects"][0]["value"] == "false"
assert rev_win is None
assert params_win["revert"] is False
if LocalStateVerifier is not None and VerifyConfig is not None:
if _HAS_EVERYDAY_PROBES:
VerifyConfig.model_validate(fwd_win)

# Unreadable baseline (None) must NOT invent a revert baseline
Expand Down Expand Up @@ -88,7 +107,7 @@ def test_build_calendar_block_contracts_parameterized_and_revert() -> None:
assert params["end_iso"] == "2026-11-24T14:45:00"
assert params["duration_minutes"] == 45
assert params["recurrence"] == "weekly"
if LocalStateVerifier is not None and VerifyConfig is not None:
if _HAS_EVERYDAY_PROBES:
VerifyConfig.model_validate(fwd)
VerifyConfig.model_validate(rev)

Expand Down
Loading