Skip to content

lifesim changes current working directory upon import #53

@thomabir

Description

@thomabir

I'm using LIFEsim commit da999aa93ff6dace0835a50783962e8ee23bf6de

When importing LIFEsim, the current working directory is changed. This breaks all relative paths used after importing LIFEsim, and makes plotting and saving data etc. more difficult.

import os
print('Current working directory: ', os.getcwd())
import lifesim
print('Current working directory: ', os.getcwd())
Current working directory:  /Users/thomabir/polybox/nice/publications/2025_nice-paper-i/01_derive-requirements
Current working directory:  /Users/thomabir/polybox/nice/publications/2025_nice-paper-i/01_derive-requirements/LIFEsim/lifesim/gui

Temporary workaround: Save cfd before importing lifesim, and reset it manually after the import:

import os
cwd = os.getcwd()
print('Current working directory: ', cwd)
import lifesim
os.chdir(cwd)
print('Current working directory: ', os.getcwd())
Current working directory:  /Users/thomabir/polybox/nice/publications/2025_nice-paper-i/01_derive-requirements
Current working directory:  /Users/thomabir/polybox/nice/publications/2025_nice-paper-i/01_derive-requirements/LIFEsim/lifesim/gui

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions