Repository navigation
Blob-based cube data transfer (#1515) - #1516
Open
nicolasbisurgi wants to merge 9 commits into
Open
nicolasbisurgi wants to merge 9 commits into
nicolasbisurgi wants to merge 9 commits into
Conversation
) Move the TI generation for use_blob reads and writes out of CellService into TM1py/Utils/BlobProcessBuilder.py. Legacy mode reproduces today's generated TI exactly (pinned by snapshot tests recorded before the refactor). Lean mode, opt-in via lean_ti=True, only emits the code a cube needs: string-measure handling, quote escaping for dimensions with quoted element names, top/skip counters and alias lookups. UTF-8 output and the header line are set on the first data record. lean_ti defaults to False on write, write_dataframe, execute_mdx_csv, execute_view_csv and the execute_*_dataframe* variants, so default behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wise-code#1515) RestService: GET takes stream=True and returns the unread response; a PUT/POST with an iterable body is detected automatically. Streamed requests always run in sync mode (async mode only returns a complete body) and are never compressed or retried (an iterable body can only be sent once). A 401 still reconnects the session. FileService: new get_size (from the document metadata, since v11 sends large downloads without a length), get_stream (context-managed chunked download), ti_file_name, and transfer_from, called on the target, which streams a file from another instance, drops a leading UTF-8 BOM, optionally removes the source and returns the bytes sent. create, update and update_or_create accept an iterable of bytes: on v11 as one sized upload (content_length), on v12 through multipart upload fed one part at a time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ubewise-code#1515) NativeView.from_mdx_builder describes an MdxBuilder as a native view: each set on axis 0/1 becomes a column/row anonymous subset (static for a member list, otherwise the set's MDX expression), single WHERE members become titles. It raises NotImplementedError for what a native view built in TI can't express (tuples, calculated members, more than two axes, non-hierarchy sets, a dimension used twice, alternate hierarchies), so callers can fall back to an MDX view. BlobProcessBuilder (lean mode) can build the export's data source view in the prolog as temporary objects, from a NativeView (one subset per cube dimension, default member for dimensions the view doesn't mention) or from an MDX string (ViewCreateByMDX). Long MDX is assigned in pieces. Nothing is left on the server whether the process succeeds or fails. CellService.split_mdx resolves one dimension's set on the server and returns one MdxBuilder per slice, as even as possible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ubewise-code#1515) export_to_blob writes the cells of an MdxBuilder, an MDX string or an existing public view to a file in the file store with a lean TI process and returns the file name. The view is built inside the process as a temporary object: a native view for an MdxBuilder when possible, otherwise an MDX view (written without DIMENSION PROPERTIES). The file has one column per cube dimension in cube order, WHERE and unmentioned dimensions included, so a cube-to-cube load always receives every dimension. Options: skip flags (rule-derived cells skipped by default), header line, aliases with blank-alias fallback, sandbox. Unknown alias dimensions or attributes raise ValueError before anything runs; a failed export removes its file and raises TM1pyExportFailureException. load_from_blob loads such a file into a cube with a lean generated process (increment, skip non-updateable, allow spread, sandbox, clear view, optional transaction log switch-off on v11 restored even when the load fails) or runs a developer's process with the file name in pFileName (or another parameter) plus its own parameters. Failures raise the same exceptions as write_through_blob; the file is removed after a successful load and kept after a failed one. TM1pyExportFailureException subclasses TM1pyException and RuntimeError. The existing use_blob read paths raise it instead of a plain RuntimeError, with the same message, so existing handlers still catch it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g helpers (cubewise-code#1515) - export_to_blob and load_from_blob require ops admin and v11.4, like the other unbound-TI methods - load_from_blob switches the transaction log with the existing helpers, only when it is on - transfer_from raises TM1pyFileTransferException instead of a bare RuntimeError - MDX name escaping and hierarchy unique names live in Utils, used by CellService, BlobProcessBuilder and NativeView - is_streamed_body is a public Utils function instead of a private RestService method - sandbox existence is checked once per call, outside the export builder - BlobProcessBuilder reuses Element.ELEMENT_ATTRIBUTES_PREFIX and drops pass-through helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ubewise-code#1515) - load_from_blob raises ValueError for cube-only options passed with process_name, and passes timeout and cancel_at_timeout to the developer process - load_from_blob documents that the generated load takes no header line - transfer_from runs the copy once more, with a new source stream, when the target's session expired (401) - write_async and write_dataframe_async take lean_ti - tests: no temporary subsets or processes left, attribute-cube round trip, process_name option checks, transfer retry after 401 - CONTEXT.md: glossary entries for blob data transfer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bewise-code#1515) - Run sandbox check and cube profile lookup before creating the temporary view - load_from_blob: add reactivate_transaction_log, deactivate_transaction_log no longer restores logging on its own (same as write) - transfer_from: reject same source and target file, remove incomplete target on byte mismatch - export_to_blob: raise when a dimension is on several axis positions - Escape the sandbox name in generated TI - Add numeric-only cube integration tests for the lean load
Collaborator
|
This is looking good. We can merge when Integration Tests complete |
Contributor
|
Tests completed for environment: tm1-11-cloud. Check artifacts for details. |
…e#1515) transfer_from now raises TM1pyFileTransferException while sending, as soon as the source stream ends short of or runs past its size, and removes the incomplete target on that error. Before, a short stream (e.g. a dropped source connection) left a v11 sized upload waiting for bytes that never came, which with no timeout never returned. Docs: RestService retry behaviour for streamed requests, CONTEXT.md lean TI and failure behaviour, NativeView/BlobProcessBuilder/CellService comments, missing :raises: entries, NON EMPTY note on export_to_blob, kwargs passed with process_name. Test: a non-numeric value in a numeric lean load rejects its row and keeps the existing cell, where legacy writes 0 over it; the test now asserts that instead of identical results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1515
Summary
Copy cube data between cubes or instances through the file store, without the cells passing through Python. Three single-purpose functions do the work; the caller chains them.
For large copies,
split_mdxdivides a query into even slices by one dimension, so the chain can run per slice in parallel.export_to_blobandload_from_blobrequire data admin and ops admin, like the other methods that run unbound TI. Every public function withuse_blobtakeslean_ti=False, includingwrite_asyncandwrite_dataframe_async.load_from_blobwithprocess_nameraisesValueErrorif a cube-only option is passed (increment,skip_non_updateable,allow_spread,sandbox_name,clear_view,deactivate_transaction_log,dimensions) instead of ignoring it. The generated load expects a file without a header line; a header (include_header=True) is for your own process.Server behaviour found along the way (all handled):
DIMENSION PROPERTIESinto extra variables; the generated MDX leaves them out.Evidence
Live tests run at
eaacc28against a v11 on-prem instance, a v12 SaaS instance and a v11 PAoC instance:split_mdx(CellService_blob_ti_test)FileService_stream_test)CellService_blob_transfer_test)use_blobtests (Cell, Element, PowerBi services)Cross-instance round trips (export → transfer → load, both directions) pass for all three pairs. Single-stream, cleared-target, developer-process and parallel-slice chains also pass between each pair.
After the review fixes (
a350085,99c366d), rerun on the v11 instance, with the cross-instance cases against the other two:CellService_blob_ti_test,FileService_stream_test,CellService_blob_transfer_test,NativeView_from_mdx_builder_test): 102 OK. New tests cover no temporary subsets or processes left, an attribute-cube round trip, theprocess_nameoption check, and the transfer retry after a 401.Existing
use_blobreads are unchanged: the generated TI is compared against snapshots of the previous code (Tests/fixtures/blob_ti_snapshots/).Merge Danger
Door: two-way
New functions are additive; the refactored
use_blobpaths generate the same TI as before (snapshot tests).Blast Radius: moderate
RestService.requesttreats an iterable body (not str/bytes/dict/list) as a streamed upload: sent synchronously, uncompressed, not retried.FileService.create/updateon v11 without multipart upload raiseValueErrorfor an iterable body with nocontent_length(v11 rejects chunked uploads).use_blobread paths check thatsandbox_nameexists before creating any file, and raiseValueErrorfor an unknown sandbox instead of a failed TI process.RuntimeErrorfromuse_blobstill catches the new exception.Suggested label:
release:minor.🤖 Generated with Claude Code