Skip to content

Commit

Permalink
simplify my life
Browse files Browse the repository at this point in the history
  • Loading branch information
jcblemai committed Sep 30, 2024
1 parent ae86e52 commit 965ef19
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def calibrate(
resume,
resume_location,
):

run_id = config_filepath.split("/")[-1].split(".")[0].replace("config_", "")
# TODO check the other default...
filename = f"{run_id}_backend.h5"
if os.path.exists(filename):
if not resume:
Expand Down

4 comments on commit 965ef19

@pearsonca
Copy link
Contributor

Choose a reason for hiding this comment

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

Your life can be even simpler if we advance the Python dependency from 3.1 => 3.4:

per https://stackoverflow.com/questions/678236/how-do-i-get-the-filename-without-the-extension-from-a-path-in-python

from pathlib import Path
run_id = Path(config_filepath).stem.replace("^config_", "")

even if not upgrading Python, the os.path.basename and os.path.splitext methods mentioned in those answers should be more platform-independent (in terms of handling how filename separators are expressed etc).

@TimothyWillard
Copy link
Contributor

Choose a reason for hiding this comment

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

Python 3.4 reached end of life in 2019, the GitHub action uses 3.10 and I've been successfully using 3.11 locally.

@pearsonca
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry - was misreading 3.10 as 3.1! So better option already just available.

@jcblemai
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, changed

Please sign in to comment.