Skip to content

Add early session release for multi-instance workflows#136

Merged
nicolasbisurgi merged 3 commits intomasterfrom
135-early-session-release-close-tm1-sessions-when-instance-has-no-remaining-tasks
Apr 2, 2026
Merged

Add early session release for multi-instance workflows#136
nicolasbisurgi merged 3 commits intomasterfrom
135-early-session-release-close-tm1-sessions-when-instance-has-no-remaining-tasks

Conversation

@nicolasbisurgi
Copy link
Copy Markdown
Collaborator

Summary

Changes

  • dag.py: Added get_remaining_tasks_by_instance() to query pending/running task counts per TM1 instance
  • execution.py: Added _logout_instance() helper and early release logic in the DAG execution loop after each task completion
  • cli.py: Passes preserve_connections and exclusive_mode through to the execution engine
  • docs/features/exclusive-mode.md: New "Early Session Release" section with example and explanation
  • tests/unit/test_early_session_release.py: 18 new tests covering DAG method, logout helper, and end-to-end early release scenarios

Behavior

Mode Preserved connections Early release?
Normal No Yes
Normal Yes (connection_file) Skipped (kept for reuse)
Exclusive No Yes
Exclusive Yes (connection_file) Yes (forced — must release lock)

Test plan

  • All 607 unit tests pass (including 18 new)
  • CI unit tests pass on Python 3.9 and 3.13
  • Integration tests pass with TM1 instances
  • Verify early release log messages appear in multi-instance workflow runs

Closes #135

🤖 Generated with Claude Code

When a workflow spans multiple TM1 instances, sessions are now released
as soon as an instance has no pending or running tasks, rather than
waiting for the entire workflow to complete. This significantly reduces
exclusive mode blocking time for multi-instance workflows.

Closes #135

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nicolasbisurgi and others added 2 commits April 2, 2026 15:14
Early release was deleting entries from tm1_services, which broke
integration tests that share the dict across test methods via setUpClass.
Now tracks released instances in a local set instead.

Also splits CI TM1 config into variable (connection details) + secret
(password only) for better visibility and debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… connections

Early release must only fire when tm1_preserve_connections is explicitly
passed (i.e. from CLI). Integration tests share TM1Service objects across
test methods via setUpClass — logging out a shared service corrupted the
HTTP session state ("multiple cookies with name TM1SessionId").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nicolasbisurgi nicolasbisurgi self-assigned this Apr 2, 2026
@nicolasbisurgi nicolasbisurgi added enhancement New feature or request release:minor Triggers major version bump (e.g.: 1.4.1 → 1.5.0) labels Apr 2, 2026
@nicolasbisurgi nicolasbisurgi merged commit 8c9bf96 into master Apr 2, 2026
9 checks passed
@nicolasbisurgi nicolasbisurgi deleted the 135-early-session-release-close-tm1-sessions-when-instance-has-no-remaining-tasks branch April 2, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request release:minor Triggers major version bump (e.g.: 1.4.1 → 1.5.0)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Early session release: close TM1 sessions when instance has no remaining tasks

1 participant