DARMA-tasking / LB-analysis-framework

Analysis framework for exploring, testing, and comparing load balancing strategies
Other
3 stars 1 forks source link

Fix FileNotFoundError in lbaf v1.0.0 package #453

Closed cwschilly closed 11 months ago

cwschilly commented 11 months ago

Follow on to #447

When I run

pip install lbaf
lbaf

I get the following error:

Traceback (most recent call last):
  File "/home/calebschilly/miniconda3/envs/py38/bin/lbaf", line 8, in <module>
    sys.exit(run())
  File "/home/calebschilly/miniconda3/envs/py38/lib/python3.8/site-packages/lbaf/__init__.py", line 29, in run
    return LBAFApplication().run()
  File "/home/calebschilly/miniconda3/envs/py38/lib/python3.8/site-packages/lbaf/Applications/LBAF_app.py", line 389, in run
    self.__print_QOI()
  File "/home/calebschilly/miniconda3/envs/py38/lib/python3.8/site-packages/lbaf/Applications/LBAF_app.py", line 353, in __print_QOI
    lbs_rank_file = open(os.path.join(target_dir, rank_script_name), 'r', encoding="utf-8")
FileNotFoundError: [Errno 2] No such file or directory: '/home/calebschilly/miniconda3/envs/py38/lib/python3.8/src/lbaf/Model/lbsRank.py'
cwschilly commented 11 months ago

The actual lbsRank.py file is at

~/miniconda3/envs/py38/lib/python3.8/site-packages/lbaf/Model/lbsRank.py

While the error shows that it's looking in

~/miniconda3/envs/py38/lib/python3.8/src/lbaf/Model/lbsRank.py

(Difference between site-packages and src)

cwschilly commented 11 months ago

The error comes from the __print_QOI() function in LBAF_app.py, where I mistakenly hard-coded src into the path:

def __print_QOI(self) -> int:  # pylint:disable=C0103:invalid-name # not snake case
        """Print list of implemented QOI based on the '-verbosity' command line argument."""
        verbosity = int(self.__args.verbose)

        # Initialize file paths
        target_dir = os.path.join(PROJECT_PATH, "src", "lbaf", "Model")
        rank_script_name = "lbsRank.py"
        object_script_name = "lbsObject.py"

        # Create list of all Rank QOI (Rank.get_*)
        r_qoi_list = ["work"]
        lbs_rank_file = open(os.path.join(target_dir, rank_script_name), 'r', encoding="utf-8")
        lbs_rank_lines = lbs_rank_file.readlines()
        for line in lbs_rank_lines:
            if line[8:12] == "get_":
                r_qoi_list.append(line[12:line.find("(")])

We need to find another way to specify the target directory