Skip to content

feat!: shorten the session working directory name for Windows MAX_PATH - #348

Open
crowecawcaw wants to merge 2 commits into
OpenJobDescription:mainlinefrom
crowecawcaw:feature/shorten-session-working-dir-name
Open

feat!: shorten the session working directory name for Windows MAX_PATH#348
crowecawcaw wants to merge 2 commits into
OpenJobDescription:mainlinefrom
crowecawcaw:feature/shorten-session-working-dir-name

Conversation

@crowecawcaw

@crowecawcaw crowecawcaw commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What was the problem/requirement? (What/Why)

The applications a job runs on Windows -- After Effects and Cinema4D among them -- use the legacy Win32 file APIs, which cap a path at MAX_PATH (260 characters). Deadline libraries use up a lot of that limit with long path names.

What was the solution? (How)

  • Shorten the session directory path by dropping the session ID from its name. Saves 40 characters.
  • Session directories are temporary and deleted after every session by default, so no backwards compatibility concerns.
  • The worker logs capture the directory name in case someone needs it for debugging later.
  • mktempdir guarantees a new, unused directory. We don't depend on the session ID to avoid conflicts.

What is the impact of this change?

Enables users to use files with 40 more characters with DCCs without long path support.

How was this change tested?

CI

Was this change documented?

Yes

Is this a breaking change?

No. Session directories are temporary, contain a random component (not deterministic), and their format is not guaranteed.

Does this change impact security?

No. Folder uniqueness is still enforced with mktempdir as it was before.

Cross-port to openjd-rs

TODO
This package is being migrated to Rust in openjd-rs/crates/openjd-sessions.
Behavioral changes made here should be replicated there to keep the two
implementations in sync until the migration is complete.

  • This change does not affect runtime behavior (docs / tests / tooling only), or
  • A matching change has been opened in openjd-rs (link the PR here): , or
  • A tracking issue has been filed in openjd-rs to port this change (link here): , or
  • Cross-porting is not applicable for this change because:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread test/openjd/sessions_v0/test_session.py Fixed
The applications a job runs on Windows -- After Effects and Cinema4D among
them -- use the legacy Win32 file APIs, which cap a path at MAX_PATH (260
characters) regardless of the LongPathsEnabled registry value and regardless
of whether this library prefixes its own paths with \\?\. Nothing but a
shorter path helps them.

The session working directory name was the full session id used verbatim as
the mkdtemp() prefix. For a Deadline Cloud session that is 40 characters
(`session-` plus a 32 character hex uuid) plus mkdtemp()'s 8 random
characters: 48 characters, of which the uuid and the random suffix were both
sources of uniqueness. Only one of them needs to be.

Use the last SESSION_DIR_ID_LENGTH (6) characters of the session id as the
prefix instead, giving a 14 character name -- 34 characters recovered. The
tail rather than the head because a session id conventionally leads with
constant text saying what kind of id it is, so a leading slice can carry no
correlation at all.

Uniqueness is unaffected. mkdtemp() creates each candidate name with an
exclusive mkdir() and retries on FileExistsError (verified identical in
CPython 3.9 through 3.14, the supported range), so it cannot return an
existing directory however short the prefix is. The truncated id is purely an
operator-facing label; the full id is unchanged and still appears on every log
record for the session and immediately beside this directory's path at
initialization.

Also shorten the embedded files subdirectory prefix from "embedded_files" to
"ef", recovering 12 more characters from every embedded file path. That
directory nests inside the session working directory, so its name is charged
to everything beneath it.

BREAKING CHANGE: the on-disk name of the session working directory is no
longer prefixed with the session id, and the embedded files subdirectory is
named "ef<random>" rather than "embedded_files<random>". Neither name is part
of the public Python interface -- Session.working_directory and
Session.files_directory are unchanged, as is OPENJD_SESSION_WORKING_DIR -- but
anything that pattern-matches the directory name must be updated. Known
consumer: deadline-cloud-worker-agent's test/e2e/test_worker_config.py
asserts a `session-[a-f0-9]{32}` directory name, and its docs/state.md
documents the old shape.

Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
@crowecawcaw
crowecawcaw force-pushed the feature/shorten-session-working-dir-name branch from 072321a to b6e4f8d Compare August 12, 2026 20:56
Comment thread src/openjd/sessions/_session.py
Comment thread test/openjd/sessions_v0/test_session.py Outdated
Comment thread src/openjd/sessions/_session.py
Comment thread src/openjd/sessions/_session.py
Comment thread test/openjd/sessions_v0/test_session.py Outdated
Comment thread src/openjd/sessions/_session.py
- test_full_session_id_remains_in_the_log: filter to openjd.sessions
  records and default the session_id getattr to None, so a dropped
  LoggerAdapter fails the assertion instead of passing vacuously.
- Replace the probabilistic name-inspection assertions with a
  deterministic check that TempDir is called with prefix="".
- Assert the name length as a <= budget ceiling rather than == to an
  incidental CPython detail.
- Narrow the concurrent test's except from BaseException to Exception
  (CodeQL).
- Fix TempDir.prefix docstring (default is None -> "tmp", not "").
- Note on working_directory / retain_working_dir that the directory name
  no longer carries session identity; the log holds that mapping.

Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
@crowecawcaw
crowecawcaw force-pushed the feature/shorten-session-working-dir-name branch from b547a27 to 732c800 Compare August 13, 2026 03:44
@crowecawcaw
crowecawcaw marked this pull request as ready for review August 13, 2026 14:02
@crowecawcaw
crowecawcaw requested a review from a team as a code owner August 13, 2026 14:02

@leongdl leongdl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta comment, I'm seeing alot of changes around the components to work around windows long path. In this temp dir case it is ok, since it is not a contract. But we cannot generally solve this.

How about we push for the proper python installer fixes ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants