Keep the TimeManagers under control¶
A project starts with one TimeManager. A year later a data domain may have a clock, a soft clone per process, a copy someone made to test something, and managers left behind by processes that were removed. Each of them decides which business date a process computes at, so a manager nobody understands any more is a process computing at a date nobody chose.
This page explains what the managers of a data domain are, how to list them, and how to bring them back onto the domain clock. It assumes you know what a TimeManager is (TimeManager & roll_out) and what the domain clock is (Managing time with the domain clock).
Two things a TimeManager holds¶
A TimeManager is two objects, and keeping them apart is the key to everything below:
DB.BUSINESS_DATE_HIDDEN the calendar: one row per business date
+---------+---------------+ (TIME_ID 1, 2, 3 ... and the date)
| TIME_ID | BUSINESS_DATE |
| 1 | 2023-01-31 |
| 2 | 2023-02-28 | <-- the cursor: the view exposes ONE row
| 3 | 2023-03-31 |
+---------+---------------+
^
DB.BUSINESS_DATE the view: SEL BUSINESS_DATE ... WHERE TIME_ID = 2
- The calendar (the hidden table) says which dates exist.
- The cursor (the view) says which date is current. A process view reads the view, so
run(pid)computes at the cursor's date, androll_outmoves the cursor step by step.
Two managers can share a calendar and still point at different dates. Two managers can also show the same date today and have different calendars. The words below follow from that.
The roles¶
| Role | Calendar | Cursor | Typical origin |
|---|---|---|---|
| clock | the domain's | the domain's | set_domain_time_manager(tm, data_domain=...) |
| clone of clock | the clock's (same table) | its own | made automatically when a process is registered on the clock (soft_clone), or by split_time_manager |
| soft clone | another manager's table | its own | clone_timer(..., clone_mode='soft') of a manager that is not a clock |
| hard copy | its own table, the same dates as another | its own | clone_timer(..., clone_mode='hard'), or loading the same dates twice |
| own calendar | its own table, its own dates | its own | a manager made for a process on another schedule (weekly, fiscal months...) |
A clone of the clock is the healthy case: same dates, and a cursor of its own so that running
one process moves no other. roll_out(data_domain=...) moves every clone with the clock.
A hard copy looks harmless today and drifts tomorrow: a date added to one table is not in the other, and its processes are not moved with the clock.
List them: the TimeManager report¶
inventory = tdfs4ds.time_manager_inventory() # data_domains=['MY_DOMAIN'] to scope
print(inventory['kpis'])
tdfs4ds.write_time_manager_report('time_managers.html') # .md for Markdown, .csv for the findings
In the app: Run & monitor → Time managers, with a data-domain filter and the same exports.
The report reads only. It shows, per data domain, the clock and its current date, the managers by role, the processes on a manager or in real time, and the datasets that follow a manager. Per manager: its role, its calendar (number of dates, first and last), its cursor (date and step), the processes reading it, the datasets following it and when it was registered. A chart shows the managers registered per month, which is how you see a domain's managers grow.
Each finding names the call that fixes it:
| Finding | What it means | Fix |
|---|---|---|
| Table of dates missing | reading the view fails (Error 3807) | reload the dates, or remove the manager |
| Holds a literal date | an interrupted run(..., at=) left the view on a date |
TimeManager(...).restore_cursor() |
| Followed by nothing | no process reads it, no dataset follows it | remove it once you checked nothing outside tdfs4ds reads it |
| Copy of another calendar | the same dates in another table | align_domain_time_managers(..., calendars=True) |
| Clone not at the clock's date | normal after running one process | roll_out(data_domain=...), or cursors=True below |
| Process does not read what it declares | the catalog says one manager, the view reads another | link_time_managers(...) |
| Processes not on the domain clock | they read a manager with other dates | align_domain_time_managers(..., calendars=True) |
| Several managers, no domain clock | nothing synchronises the processes | set_domain_time_manager(...) |
Will one roll-out cover the domain?¶
The report (and sanity_check, check order) answers it per data domain, in the column
roll_out(data_domain=...), with the rule roll_out itself applies:
| Verdict | When | Severity |
|---|---|---|
| covers every manager | with a clock: every manager read is the clock or a soft clone of it; without a clock: one table of dates | - |
| refuses: a manager on other dates | with a clock, a process reads a manager on other dates: roll_out(data_domain=...) stops before its first date, nothing of the domain is computed |
error |
| no single roll-out | no clock, and the processes read several tables of dates: each group needs its own call | warning |
| not verified | a process view is not in the lineage graph | warning |
Across data domains:
- A manager read by several data domains (warning). A roll-out or a run of any of them moves
it for all: one domain's schedule decides the dates the others compute at next. Give each
domain's processes their own soft clone (
align_domain_time_managers), or roll the domains out together. - Two clocks on one table of dates (info). The domains compute at the same dates, but each
roll_out(data_domain=...)moves only its own clock and clones: they are in step only when every domain is rolled out to the same date.
Bring them onto the clock: align_domain_time_managers¶
One call, one data domain, a dry run first:
plan = tdfs4ds.align_domain_time_managers('MY_DOMAIN', cursors=True, calendars=True, dry_run=True)
plan[['VIEW_NAME', 'ACTION', 'DETAIL', 'REPLAY']]
Each row is a process (or, for RESTORE, a manager). Read ACTION:
| ACTION | Situation | What applying does | History |
|---|---|---|---|
CLONE |
the process reads the clock itself | gives it its own soft clone of the clock | unchanged |
OK |
it reads a clone of the clock | nothing | unchanged |
ALIGN (cursors=True) |
it reads a clone whose cursor is not at the clock's step | moves the clone's cursor to the clock's | unchanged; run(pid) then computes at the clock's date |
REPOINT (calendars=True) |
it reads a manager holding exactly the clock's dates | a soft clone of the clock, at the same date, replaces that manager in the process view | unchanged: same dates, same valid times |
REPOINT_REPLAY |
the manager holds some of the clock's dates | the same, and REPLAY is the roll_out that computes the dates it never had |
to complete with REPLAY, which you run |
KEEP_OWN_CALENDAR |
the manager holds dates the clock does not have | nothing | unchanged |
RESTORE |
a manager holds a literal date | restores its cursor first | unchanged |
NOT_DIRECT |
the process reads the manager through another view | nothing; rewrite that view or re-register | unchanged |
EXCLUDED |
named in exclude= |
nothing | unchanged |
Then apply, and run each REPLAY it lists:
plan = tdfs4ds.align_domain_time_managers('MY_DOMAIN', cursors=True, calendars=True, dry_run=False)
for call in plan.loc[plan['REPLAY'] != '', 'REPLAY']:
print(call) # run each one yourself: it recomputes stored values
Why a process on other dates is never moved¶
The valid time of a stored value is the business date it was computed at. A process on a
fiscal-month calendar stores values at fiscal month ends. Moving it onto a calendar-month clock
would make its next runs stamp other dates, next to a history stamped with the old ones. That
is a modelling decision, not a cleanup, so the plan says KEEP_OWN_CALENDAR and names the two
ways forward:
- Keep it on its own calendar. A process may follow another schedule; the report lists it as "own calendar" and that is fine.
- Put it on the clock deliberately: re-register it with
time_manager=the clock, then rebuild its history from the first date withroll_out([pid], time_id_start=1, force_compute=True)(a history is built forward only).
Cursors kept apart on purpose¶
split_time_manager gives a process a cursor of its own so it can read its upstream at another
date. cursors=True cannot tell such a clone from one that is simply behind, so name it:
What it never does¶
- It never drops a manager. A copy left with no reader shows in the report as "followed by nothing"; removing it is your call.
- It never recomputes.
REPLAYis printed, not run. - It never moves a process onto other dates.
A routine that keeps a domain tidy¶
- After registering processes, or once a month:
write_time_manager_report(...). - Fix the errors first (missing table, literal date), then the warnings.
- For copies and processes off the clock: the alignment plan,
dry_run=True, read it, apply. - Remove the managers the report shows as followed by nothing.
- Run
roll_out(data_domain=...)as usual: every clone moves with the clock.