ChangeSetService
from skipcheck_tm1.services import ChangeSetServiceChange sets: groups of cell writes that can be undone together.
A write joins a change set through TM1's !ChangeSet query option, which a
session view from Tm1Session.with_change_set adds to every request
($metadata doesn't say how; TM1 11.8 does it this way). within does it
all: begins a change set, gives the work a session that records into it, and ends it
however the work finishes.
Make some writes in a change set, keeping its ID:
# Record some writes in a change set, and keep its ID to undo them later
cell = {"Version": "Forecast", "Region": "North", "Month": "Jan", "Measure": "Revenue"}
with tm1.change_sets.recording() as session:
Tm1Client.of(session).cells.update("Sales", cell, 1500)
return session.change_set
Undo them later:
# Revert every write recorded in the change set; writes outside it stay
tm1.change_sets.undo(change_set)
The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncChangeSetService.
Members
begin | Starts a change set, and returns its ID, for session.with_change_set. |
end | Stops recording into a change set; it can still be undone. |
undo | Reverts every write recorded in a change set. |
within | Runs work in a new change set. |
recording | within as a context manager. |
begin
begin() -> strBeginChangeSet: starts a change set, and returns its ID, for session.with_change_set. Needs schema 10.2.2.6.
TM1 REST ActionImport BeginChangeSet
end
end(id: str) -> intEndChangeSet: stops recording into a change set; it can still be undone. Returns TM1's return code. Needs schema 10.2.2.6.
TM1 REST ActionImport EndChangeSet
undo
undo(id: str) -> NoneUndoChangeSet: reverts every write recorded in a change set. Needs schema 10.2.2.6.
TM1 REST ActionImport UndoChangeSet
within
within(work: Callable[[Tm1Session], Awaitable[Any]]) -> AnyRuns work in a new change set: begins it, gives the work a view of the session that records into it (session.change_set has the ID, for a later undo), and ends it when the work completes or fails. Returns what the work gives.
# Record some writes in a change set, and keep its ID to undo them later
cell = {"Version": "Forecast", "Region": "North", "Month": "Jan", "Measure": "Revenue"}
with tm1.change_sets.recording() as session:
Tm1Client.of(session).cells.update("Sales", cell, 1500)
return session.change_setTM1 REST ActionImport BeginChangeSet ActionImport EndChangeSet
recording
recording() -> Iterator[Tm1Session]within as a context manager: begins a change set, gives the block a view of the session that records into it, and ends it however the block finishes.
TM1 REST ActionImport BeginChangeSet ActionImport EndChangeSet