Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message on incorrect machine #892

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion mpas_analysis/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import logging
import xarray
import time
from importlib.resources import contents

from mache import discover_machine, MachineInfo

Expand Down Expand Up @@ -794,7 +795,21 @@ def main():

if machine is not None:
print(f'Detected E3SM supported machine: {machine}')
config.add_from_package('mache.machines', f'{machine}.cfg')
try:
config.add_from_package('mache.machines', f'{machine}.cfg')
except FileNotFoundError:

possible_machines = []
machine_configs = contents('mache.machines')
for config in machine_configs:
if config.endswith('.cfg'):
possible_machines.append(os.path.splitext(config)[0])

possible_machines = '\n '.join(sorted(possible_machines))
raise ValueError(
f'We could not find the machine: {machine}.\n'
f'Possible machines are:\n {possible_machines}')

try:
config.add_from_package('mpas_analysis.configuration',
f'{machine}.cfg')
Expand Down