Skip to content

Commit

Permalink
Merge pull request #3074 from E3SM-Project/bartgol/eamxx/mach-specs-i…
Browse files Browse the repository at this point in the history
…ssues-fixes

Fix some issues gentle courtesy of the machine specs refactor PR
  • Loading branch information
bartgol authored Oct 31, 2024
2 parents cb30379 + fcb159a commit 3146f7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
22 changes: 13 additions & 9 deletions components/eamxx/scripts/machines_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def setup_cray(cls,name):
class PM(CrayMachine):
###############################################################################
@classmethod
def setup(cls,partition):
def setup_pm(cls,partition):
expect (partition in ['cpu', 'gpu'], "Unknown Perlmutter partition")

super().setup_cray("pm-"+partition)
Expand All @@ -132,16 +132,16 @@ class PMCPU(PM):
###############################################################################
concrete = True
@classmethod
def setup(cls,partition):
super().setup_cray("cpu")
def setup(cls):
super().setup_pm("cpu")

###############################################################################
class PMGPU(PM):
###############################################################################
concrete = True
@classmethod
def setup(cls,partition):
super().setup_base("gpu")
def setup(cls):
super().setup_pm("gpu")

cls.num_run_res = 4 # four gpus
cls.gpu_arch = "cuda"
Expand Down Expand Up @@ -340,7 +340,7 @@ def setup(cls):
]

###############################################################################
def get_all_machines ():
def get_all_machines (base=Machine):
###############################################################################
# If the user has the file ~/.cime/scream_mach_specs.py, import the machine type Local from it
if pathlib.Path("~/.cime/scream_mach_specs.py").expanduser().is_file(): # pylint: disable=no-member
Expand All @@ -354,11 +354,15 @@ def get_all_machines ():
# so it doesn't find the module
from scream_mach_specs import Local# pylint: disable=unused-import, import-error

for m in Machine.__subclasses__():
machines = []
for m in base.__subclasses__():
if m.concrete:
m.setup()
m.setup() # Init the class static data
machines.append(m)

machines.extend(get_all_machines(m))

return [m for m in Machine.__subclasses__() if m.concrete]
return machines

###############################################################################
def get_machine (name):
Expand Down
9 changes: 4 additions & 5 deletions components/eamxx/scripts/scream-env-cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ script to conveniently load the SCREAM-approved env into your current shell.
from utils import check_minimum_python_version, GoodFormatter
check_minimum_python_version(3, 4)

from machines_specs import get_mach_env_setup_command, get_machine
from machines_specs import get_mach_env_setup_command

import argparse, sys, pathlib

Expand Down Expand Up @@ -44,15 +44,14 @@ OR
formatter_class=GoodFormatter
)

parser.add_argument("mach_name", help="The machine name for which you want the scream env")
parser.add_argument("mach", help="The machine name for which you want the scream env")

return parser.parse_args(args[1:])

###############################################################################
def dump_scream_env(mach_name):
def dump_scream_env(mach):
###############################################################################
machine = get_machine(mach_name)
commands = get_mach_env_setup_command(machine)
commands = get_mach_env_setup_command(mach)
print(" && ".join(commands))
print("\n".join(commands), file=sys.stderr)

Expand Down

0 comments on commit 3146f7f

Please sign in to comment.