Skip to content

Commit

Permalink
compatibility with python on longleaf. To remove ?
Browse files Browse the repository at this point in the history
  • Loading branch information
jcblemai committed Sep 27, 2024
1 parent b5409a7 commit 7e2a061
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flepimop/gempyor_pkg/src/gempyor/file_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- run_id: Generates a run ID based on the current or provided timestamp.
- create_dir_name: Creates a directory name based on given parameters.
"""

from __future__ import annotations
from datetime import datetime
import os
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion flepimop/gempyor_pkg/src/gempyor/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import datetime
import functools
import logging
Expand All @@ -20,7 +21,6 @@

from gempyor import file_paths


logger = logging.getLogger(__name__)

config = confuse.Configuration("flepiMoP", read=False)
Expand Down

5 comments on commit 7e2a061

@TimothyWillard
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally don't comment on commits outside of PRs, but since this was referenced in GH-280 this caught my eye. This is not resolved by upgrading from python 3.10 to 3.11, future annotations are still in place (in fact I don't think it made it into 3.13 either even). However, I'm confused why this is required here? I don't see any circular type hints between these two files which is typically what this is meant to fix. I was able to check out the branch and run the unit tests successfully without the from __future__ import annotations lines in either file.

@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.

no, you are right to comment here, I wanted to bring that to your attention. There are still some python3.9 env

(base) ➜  ~ python
Python 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

and without this we get as error

Traceback (most recent call last):
  File "/nas/longleaf/home/chadi/.local/bin/flepimop-calibrate", line 33, in <module>
    sys.exit(load_entry_point('gempyor', 'console_scripts', 'flepimop-calibrate')())
  File "/nas/longleaf/home/chadi/.local/bin/flepimop-calibrate", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/nas/longleaf/rhel8/apps/anaconda/2021.11/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/nas/longleaf/rhel8/apps/anaconda/2021.11/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/__init__.py", line 3, in <module>
    from .inference import *
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/inference.py", line 12, in <module>
    from . import seir, model_info
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/seir.py", line 9, in <module>
    from . import NPI, model_info, steps_rk4
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/model_info.py", line 3, in <module>
    from . import seeding, subpopulation_structure, parameters, compartments, file_paths, initial_conditions
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/seeding.py", line 8, in <module>
    from . import utils
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/utils.py", line 22, in <module>
    from gempyor import file_paths
  File "/work/users/c/h/chadi/flepiMoP_Notebooks/flepiMoP/flepimop/gempyor_pkg/src/gempyor/file_paths.py", line 21, in <module>
    index: str | int,
TypeError: unsupported operand type(s) for |: 'type' and 'type'

@jcblemai
Copy link
Collaborator Author

@jcblemai jcblemai commented on 7e2a061 Oct 18, 2024

Choose a reason for hiding this comment

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

straightforward fix is to update the environement, but constantly things running at the moment. I think we'll remove that in the PR.

@TimothyWillard
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. This is because of the str | int syntax, for python 3.9 need to use Union[str, int]. Although that would be quite the change to support 3.9 in the mainstream gempyor. Yeah, I think this is the right approach for the moment, hopefully the HPC install script PR makes it easy to correct this soon.

@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.

yes, can't wait to try this after the current rush.

Please sign in to comment.