Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.galileo.ai/llms.txt

Use this file to discover all available pages before exploring further.

Module

Base classes for lifecycle and state management.

SyncState

Enumeration of possible synchronization states for business objects.

Attributes

LOCAL_ONLY: Object exists only in memory, not yet persisted remotely. SYNCED: Local and remote states match. DIRTY: Local changes exist that have not been saved. FAILED_SYNC: Last attempt to sync failed. DELETED: Object was deleted remotely, local object still exists.

StateManagementMixin

Base mixin for business objects providing lifecycle state management. This mixin provides state tracking and helper methods for objects that need to synchronize between local and remote (API) states. Subclasses may declare a _TRACKED_FIELDS frozenset to enable automatic dirty-tracking: any assignment to a tracked field on a SYNCED object will transition it to DIRTY so that callers know a save() is needed.

Attributes

_sync_state: Current synchronization state of the object. _last_error: Last error encountered during synchronization (optional). _TRACKED_FIELDS: frozenset of attribute names whose mutations trigger SYNCED → DIRTY transitions.

has_failed

def has_failed(self) -> bool
Check if the last synchronization attempt failed.

Returns

bool: True if the last sync failed, False otherwise.

is_deleted

def is_deleted(self) -> bool
Check if the object has been deleted remotely.

Returns

bool: True if the object was deleted, False otherwise.

is_dirty

def is_dirty(self) -> bool
Check if the object has unsaved local changes.

Returns

bool: True if the object has unsaved changes, False otherwise.

is_local_only

def is_local_only(self) -> bool
Check if the object exists only locally.

Returns

bool: True if the object has not been persisted, False otherwise.

is_synced

def is_synced(self) -> bool
Check if the object is synchronized with the remote state.

Returns

bool: True if the object is synced, False otherwise.

refresh

def refresh(self) -> None
Refresh the object state from the remote API. This method should:
  1. Fetch the latest state from the API
  2. Update all local attributes
  3. Set the state to SYNCED on success

Raises

NotImplementedError: If not implemented by subclass.

sync_state

def sync_state(self) -> SyncState
Get the current synchronization state.

Returns

SyncState: The current state of the object.