SandboxService
from skipcheck_tm1.services import SandboxServiceSandboxes: private copies of the data a user writes to before publishing. They belong to the user the session is for.
Reading and writing in a sandbox go through a session view:
Tm1Session.with_sandbox or Tm1Client.with_sandbox, which add TM1's
!sandbox option to every request. This service manages the sandboxes
themselves.
Create a sandbox, write to it, and publish the changes to base data:
# Write to a new sandbox, leaving base data alone until the changes are published
cell = {"Version": "Budget", "Region": "North", "Month": "Jan", "Measure": "Revenue"}
tm1.sandboxes.create(SandboxPatch.builder().name("What If").build())
tm1.with_sandbox("What If").cells.update("Sales", cell, 1500)
tm1.sandboxes.publish("What If")
Read a cell in base data and in a sandbox:
# The same cell read in base data and in a sandbox: the same query, through a
# client for each
mdx = (
"SELECT {[Month].[Month].[Jan]} ON 0, {[Region].[Region].[North]} ON 1 FROM [Sales] WHERE ([Version].[Version].[Budget], [Measure].[Measure].[Revenue])"
)
values = ODataQuery.none().select(CellsetCell.VALUE)
def first(cellset, cells):
return next(cells).value
base = tm1.cellsets.stream(mdx, values, 1, first)
what_if = tm1.with_sandbox("What If").cellsets.stream(mdx, values, 1, first)
return f"base {base}, what-if {what_if}"
The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncSandboxService.
Members
list | The session user's sandboxes. |
get | The sandbox, or a Tm1NotFoundError if there's none. |
create | Creates an empty sandbox; it needs a name. |
update | Changes the properties the patch sets, such as IncludeInSandboxDimension. |
delete | DELETE Sandboxes('name'), with its unpublished changes. |
load | Loads the sandbox into memory. |
unload | Frees the sandbox's memory, keeping its changes. |
discard_changes | Throws away the sandbox's changes, keeping the sandbox. |
publish | Writes the sandbox's changes to base data. |
merge | Copies the sandbox's changes into sandbox target. |
list
list(query: ODataQuery | None = None, **options: Any) -> list[Sandbox]GET Sandboxes: the session user's sandboxes.
TM1 REST EntitySet Sandboxes
get
get(name: str, query: ODataQuery | None = None, **options: Any) -> SandboxGET Sandboxes('name'): the sandbox, or a Tm1NotFoundError if there's none.
TM1 REST EntitySet Sandboxes
create
create(sandbox: Any) -> SandboxPOST Sandboxes: creates an empty sandbox; it needs a name.
TM1 REST EntitySet Sandboxes
update
update(name: str, patch: Any) -> NonePATCH Sandboxes('name'): changes the properties the patch sets, such as IncludeInSandboxDimension.
TM1 REST EntitySet Sandboxes
delete
delete(name: str) -> NoneDELETE Sandboxes('name'), with its unpublished changes.
TM1 REST EntitySet Sandboxes
load
load(name: str) -> Nonetm1.Load: loads the sandbox into memory.
TM1 REST Action Sandbox/Load
unload
unload(name: str) -> Nonetm1.Unload: frees the sandbox's memory, keeping its changes.
TM1 REST Action Sandbox/Unload
discard_changes
discard_changes(name: str) -> Nonetm1.DiscardChanges: throws away the sandbox's changes, keeping the sandbox.
TM1 REST Action Sandbox/DiscardChanges
publish
publish(name: str, conflicts: ConflictResolution | None = None, allow_queueing: bool = False, clean_after: bool = False) -> Nonetm1.Publish: writes the sandbox's changes to base data. With conflicts, the options are sent too: what to do with cells changed in base data since the sandbox's changes, whether to wait for a lock rather than fail (allow_queueing), and whether to empty the sandbox once published (clean_after).
TM1 REST Action Sandbox/Publish
merge
merge(name: str, target: str, conflicts: ConflictResolution | None = None, allow_queueing: bool = False, clean_after: bool = False) -> Nonetm1.Merge: copies the sandbox's changes into sandbox target. With conflicts, the options are sent too: what to do with cells the target changed too, whether to wait for a lock rather than fail, and whether to empty this sandbox once merged.
TM1 REST Action Sandbox/Merge