Skip to content

Add blob-based add_elements / add_edges for symmetric dimension blob support#1423

Open
skido-cw wants to merge 1 commit into
cubewise-code:masterfrom
skido-cw:feature/blob-add-elements-edges
Open

Add blob-based add_elements / add_edges for symmetric dimension blob support#1423
skido-cw wants to merge 1 commit into
cubewise-code:masterfrom
skido-cw:feature/blob-add-elements-edges

Conversation

@skido-cw

Copy link
Copy Markdown
Contributor

Summary

Blob loading (CSV upload + unbound TI process) was previously only available for deleting edges (delete_edges_use_blob), while adding elements and edges was REST-only. This PR makes the support symmetric and scales bulk dimension builds — which is where blob actually pays off (lots of elements + multiple consolidations).

Changes

ElementService

  • Cleanup / DRY: extracted the shared blob plumbing into _build_blob_datasource_process (the ASCII-datasource Process skeleton, incl. v11 .blb handling + UTF-8 prolog) and _run_blob_process (CSV serialize → upload → execute → cleanup). Refactored delete_edges_use_blob / _build_unwind_hierarchy_edges_from_blob_process onto them.
  • New: add_elements_use_blob (TI HierarchyElementInsert) and add_edges_use_blob (TI HierarchyElementComponentAdd), dispatched from a new use_blob / remove_blob kwarg on add_elements / add_edges. Both gated by @require_data_admin / @require_ops_admin, matching the existing delete path.

HierarchyService

  • update_or_create_hierarchy_from_dataframe now adds elements and edges via blob for admins (use_blob=self.is_admin), mirroring the edge-delete calls already there — so a large hierarchy build is blob-based end to end.

Behavior / compatibility

  • Fully backward compatible: use_blob defaults to False, so the default path is the unchanged REST behavior (still returns the Response). With use_blob=True the methods return None, consistent with delete_edges_use_blob.
  • Recommended usage for building consolidations: add elements first (incl. the C elements), then add the edges.

Testing

  • Offline unit tests (no server): the generated TI processes (variables/types, the exact HierarchyElementInsert / HierarchyElementComponentAdd / ...ComponentDelete statements, UTF-8 prolog, v11 .blb suffixing) and the use_blob dispatch wiring.
  • Live integration tests: new add_elements_use_blob / add_edges_use_blob tests (incl. consolidations) and a bulk update_or_create_hierarchy_from_dataframe build with many consolidations.
  • Live-tested end to end against TM1 v11 (11.8) and v12 (PA Engine), including the v11 .blb path. The full from_dataframe suite (30 tests) passes on v12.
  • black --check . and ruff check . pass.

🤖 Generated with Claude Code

…b support

Previously blob (CSV upload + unbound TI process) was only available for
deleting edges, while adding elements and edges was REST-only. This makes
the support symmetric and scales bulk dimension builds.

- ElementService: extract shared blob plumbing (_build_blob_datasource_process,
  _run_blob_process) and refactor delete_edges_use_blob onto it.
- ElementService: add add_elements_use_blob (HierarchyElementInsert) and
  add_edges_use_blob (HierarchyElementComponentAdd), dispatched from a new
  use_blob/remove_blob kwarg on add_elements/add_edges. Both admin-gated.
- HierarchyService.update_or_create_hierarchy_from_dataframe now adds elements
  and edges via blob for admins (use_blob=self.is_admin), matching the existing
  edge-delete path, so the whole bulk build is blob-based for large sets.
- Tests: offline process-builder/dispatch unit tests, plus live tests for the
  new methods and a bulk hierarchy build with many consolidations.

Live-tested end to end against TM1 v11 (11.8) and v12 (PA Engine).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant