Skip to content

add "lazy" directory creation#276

Merged
toruseo merged 4 commits intomainfrom
develop
Mar 27, 2026
Merged

add "lazy" directory creation#276
toruseo merged 4 commits intomainfrom
develop

Conversation

@toruseo
Copy link
Copy Markdown
Owner

@toruseo toruseo commented Mar 27, 2026

This addresses B1 of #270

Copilot AI review requested due to automatic review settings March 27, 2026 06:14
@toruseo toruseo enabled auto-merge March 27, 2026 06:14
@toruseo toruseo review requested due to automatic review settings March 27, 2026 06:14
@toruseo toruseo disabled auto-merge March 27, 2026 06:14
@toruseo toruseo requested a review from Copilot March 27, 2026 06:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #270 (B1) by removing eager output-directory creation during analysis initialization and shifting directory creation closer to actual export/save actions.

Changes:

  • Removed os.makedirs(...) side effect from Analyzer.__init__.
  • Added a helper (outdir_set) and updated many save calls to create the output directory on-demand.
  • Updated World.show_network to only create the output directory when save_mode is enabled.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
uxsim/uxsim.py Makes show_network() create the output directory only when saving is enabled.
uxsim/analyzer.py Removes directory creation from Analyzer.__init__ and adds a lazy directory-creation helper used by export routines.

Comment thread uxsim/analyzer.py Outdated
Comment on lines +95 to +96
os.makedirs(f"out{s.W.name}", exist_ok=True)
return fname
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

outdir_set() always creates out{s.W.name} regardless of the directory in fname. This breaks network_anim()/network_fancy() when file_name points to a different directory (the target directory may not exist) and also reintroduces an unintended side effect (creating out...) even when saving elsewhere. Consider creating Path(fname).parent (when non-empty) instead of hard-coding out{s.W.name}.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

indeed

@toruseo toruseo merged commit 2ef5875 into main Mar 27, 2026
15 checks passed
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.

2 participants