Skip to content

Commit

Permalink
lpdiag: improved work-dir diagnostics.
Browse files Browse the repository at this point in the history
Diagnostics of possible problems with wrong working directory improved, as well as the corresponding tip on dealing with the problem.
  • Loading branch information
marek-iiasa committed Jul 4, 2023
1 parent e74ae1c commit fbc407f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions message_ix/tools/lp_diag/lpdiag.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ def read_args():
# dir2 = os.getcwd()
# print(f"{dir2 =}")
w_dir = args.wdir or "."
# prob_id = args.mps or "test_mps/diet" # default MPS for testing
prob_id = args.mps or "test_mps/aez" # default MPS for testing

Check warning on line 76 in message_ix/tools/lp_diag/lpdiag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lpdiag.py#L75-L76

Added lines #L75 - L76 were not covered by tests
# alternative specs of test-MPS commented below
# prob_id = args.mps or "test_mps/diet" # default MPS for testing
# prob_id = args.mps or "test_mps/err_tst" # default MPS for testing
# prob_id = args.mps or "test_mps/jg_korh" # default MPS for testing
# prob_id = args.mps or "test_mps/lotfi" # default MPS for testing
# prob_id = args.mps or "test_mps/of_led1" # default MPS for testing
if len(w_dir) > 1:
work_dir = w_dir
print(f"Changing work-directory to: {w_dir}.")
try:
os.chdir(w_dir)
Expand All @@ -87,8 +89,8 @@ def read_args():
# dir3 = os.getcwd()
# print(f"{dir3 =}")
assert isfile(prob_id), (

Check warning on line 91 in message_ix/tools/lp_diag/lpdiag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lpdiag.py#L91

Added line #L91 was not covered by tests
f"MPS file {prob_id} not accessible from the dir:\n'{w_dir}'.\n"
"Try to use the --wdir command option to set the work-directory."
f"MPS file {prob_id} not accessible from the work-directory:\n'{work_dir}'."
"\nTry to use the --wdir command option to set the work-directory."
)
assert access(prob_id, R_OK), f"MPS file {prob_id} is not readable."

Check warning on line 95 in message_ix/tools/lp_diag/lpdiag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lpdiag.py#L95

Added line #L95 was not covered by tests

Expand Down

0 comments on commit fbc407f

Please sign in to comment.