Skip to content

Add inherit_env and login_shell submit options#4

Merged
krokicki merged 1 commit into
fix-cross-user-pollingfrom
job-env-control
Jul 9, 2026
Merged

Add inherit_env and login_shell submit options#4
krokicki merged 1 commit into
fix-cross-user-pollingfrom
job-env-control

Conversation

@krokicki

@krokicki krokicki commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

  • By default, jobs inherit the submitting process's full environment (Popen merges os.environ locally; bsub copies the caller's environment on LSF), which leaks whatever the submitter happened to have set (e.g. PIXI_PROJECT_MANIFEST, worker-internal vars). Two new submit() kwargs let callers construct the job's environment instead of inheriting it:
    • inherit_env=False — local jobs get a minimal baseline (identity vars + fixed PATH) plus any explicit env; LSF submits with -env none, and explicit env vars move into the script as exports since bsub will no longer copy them.
    • login_shell=True — run under a login shell (bash -l locally, bsub -L /bin/bash on LSF) so the target user's own profile builds PATH/modules/conda, as an SSH session would.
  • Defaults (inherit_env=True, login_shell=False) preserve existing behavior — this is purely additive.

Stacked on #3 (fix-cross-user-polling) since that's what it was branched from; the diff here is only the new commit.

Why

fileglancer's cluster-job launcher needs to stop leaking its own process environment into every submitted job. This library needs the explicit inherit_env/login_shell controls before fileglancer's PR can be un-blocked and released against.

Test plan

  • pixi run test — 162 passed (new coverage in tests/test_local.py and tests/test_lsf.py)
  • Release a new version to PyPI once merged, so downstream (fileglancer) can bump its pin

@StephanPreibisch @JaneliaSciComp/fileglancer

By default jobs inherit the submitting process's full environment (Popen
os.environ merge locally; bsub's environment copy on LSF), which leaks
whatever the submitter has set. The new kwargs let callers construct the
job environment instead:

- inherit_env=False: local jobs get a minimal baseline (identity vars +
  fixed PATH) plus explicit env; LSF submits with `-env none`, and any
  explicit env vars move into the script as exports since bsub will no
  longer copy them.
- login_shell=True: run under a login shell (`bash -l` locally,
  `bsub -L /bin/bash` on LSF) so the target user's own profile builds
  PATH/modules/conda, as an SSH session would.

Defaults preserve existing behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@krokicki krokicki merged commit f89d5d8 into fix-cross-user-polling Jul 9, 2026
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