unaiverse.clock
What this module does 🟡
Provides a network-synchronized logical clock that maps wall-clock time to discrete cycles, supporting slowed-down execution and server time offset correction.
clock
¶
█████ █████ ██████ █████ █████ █████ █████ ██████████ ███████████ █████████ ██████████ ░░███ ░░███ ░░██████ ░░███ ░░███ ░░███ ░░███ ░░███░░░░░█░░███░░░░░███ ███░░░░░███░░███░░░░░█ ░███ ░███ ░███░███ ░███ ██████ ░███ ░███ ░███ ░███ █ ░ ░███ ░███ ░███ ░░░ ░███ █ ░ ░███ ░███ ░███░░███░███ ░░░░░███ ░███ ░███ ░███ ░██████ ░██████████ ░░█████████ ░██████ ░███ ░███ ░███ ░░██████ ███████ ░███ ░░███ ███ ░███░░█ ░███░░░░░███ ░░░░░░░░███ ░███░░█ ░███ ░███ ░███ ░░█████ ███░░███ ░███ ░░░█████░ ░███ ░ █ ░███ ░███ ███ ░███ ░███ ░ █ ░░████████ █████ ░░█████░░████████ █████ ░░███ ██████████ █████ █████░░█████████ ██████████ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░░░░░░ A Collectionless AI Project (https://collectionless.ai) Registration/Login: https://unaiverse.io Code Repositories: https://github.com/collectionlessai/ Main Developers: Stefano Melacci (Project Leader), Christian Di Maio, Tommaso Guidi
Clock
¶
A lazy-initializing singleton wrapper around _Clock.
Clock acts as a transparent proxy: attribute accesses on a Clock instance are
forwarded to the underlying _Clock instance. If no _Clock has been configured
yet, one is created automatically on the first attribute access using the current UTC
time as the synchronization reference, so callers do not need to call create
explicitly.
The module-level clock object is the single shared instance of this class. The
rest of the framework imports and uses clock directly rather than instantiating
_Clock itself. Providing a single shared clock ensures that all components agree
on cycle boundaries and synchronized timestamps.
Initialize the Clock wrapper with no underlying _Clock instance.
The internal __instance slot is set to None. The first attribute access
after construction will trigger lazy initialization via __getattr__, creating
a _Clock with the current UTC time as the reference unless create or
set is called first.
Source code in unaiverse/clock.py
set
¶
Attach an already-constructed _Clock instance to this wrapper.
Replaces whatever _Clock (if any) is currently held by this wrapper. All
subsequent attribute accesses will be forwarded to existing_clock. This is
useful when a _Clock has been created externally (for example, with a
specific synchronization timestamp) and needs to be shared via the module-level
clock singleton.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
existing_clock
|
A |
required |
Source code in unaiverse/clock.py
create
¶
Create and attach a new _Clock instance, replacing any existing one.
All positional and keyword arguments are forwarded verbatim to the _Clock
constructor. After this call, the new instance becomes the target of all
subsequent attribute accesses via __getattr__. See _Clock.__init__ for
the full parameter documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments forwarded to |
()
|
|
**kwargs
|
Keyword arguments forwarded to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Propagated from |