Skip to content

Commit

Permalink
Make driver_name() public (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa committed Aug 8, 2024
1 parent d15216c commit cb2700c
Show file tree
Hide file tree
Showing 42 changed files with 140 additions and 112 deletions.
6 changes: 4 additions & 2 deletions src/uwtools/drivers/cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ def ocn_stream(self):
yield file(path=Path(template_file))
self._model_stream_file("ocn_streams", path, template_file)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.cdeps

# Private helper methods

def _model_namelist_file(self, group: str, path: Path) -> None:
"""
Create an atmosphere or ocean namelist file.
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def runscript(self):
}
self._write_runscript(path=path, envvars=envvars)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
Expand Down
24 changes: 14 additions & 10 deletions src/uwtools/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def __init__(
config_intermediate, _ = walk_key_path(self._config_full, key_path or [])
self._platform = config_intermediate.get("platform")
try:
self._config: dict = config_intermediate[self._driver_name]
self._config: dict = config_intermediate[self.driver_name]
except KeyError as e:
raise UWConfigError("Required '%s' block missing in config" % self._driver_name) from e
raise UWConfigError("Required '%s' block missing in config" % self.driver_name) from e
if controller:
self._config[STR.rundir] = config_intermediate[controller][STR.rundir]
self._validate(schema_file)
Expand All @@ -75,7 +75,7 @@ def __repr__(self) -> str:
return " ".join(filter(None, [str(self), cycle, leadtime, "in", self.config[STR.rundir]]))

def __str__(self) -> str:
return self._driver_name
return self.driver_name

@property
def config(self) -> dict:
Expand Down Expand Up @@ -111,7 +111,7 @@ def taskname(self, suffix: str) -> str:
if cycle and leadtime is not None
else cycle.strftime("%Y%m%d %HZ") if cycle else None
)
return " ".join(filter(None, [timestr, self._driver_name, suffix]))
return " ".join(filter(None, [timestr, self.driver_name, suffix]))

# Workflow tasks

Expand Down Expand Up @@ -153,13 +153,17 @@ def _create_user_updated_config(
else:
log.debug(f"Failed to validate {path}")

# Public helper methods

@property
@abstractmethod
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""

# Private helper methods

def _namelist_schema(
self, config_keys: Optional[list[str]] = None, schema_keys: Optional[list[str]] = None
) -> dict:
Expand All @@ -174,12 +178,12 @@ def _namelist_schema(
for config_key in config_keys or [STR.namelist]:
nmlcfg = nmlcfg[config_key]
if nmlcfg.get(STR.validate, True):
schema_file = get_schema_file(schema_name=self._driver_name.replace("_", "-"))
schema_file = get_schema_file(schema_name=self.driver_name.replace("_", "-"))
with open(schema_file, "r", encoding="utf-8") as f:
schema = json.load(f)
for schema_key in schema_keys or [
STR.properties,
self._driver_name,
self.driver_name,
STR.properties,
STR.namelist,
STR.properties,
Expand All @@ -199,7 +203,7 @@ def _validate(self, schema_file: Optional[Path] = None) -> None:
validate_external(schema_file=schema_file, config=self.config_full)
else:
validate_internal(
schema_name=self._driver_name.replace("_", "-"), config=self.config_full
schema_name=self.driver_name.replace("_", "-"), config=self.config_full
)


Expand Down Expand Up @@ -460,7 +464,7 @@ def _runscript_path(self) -> Path:
"""
Returns the path to the runscript.
"""
return self.rundir / f"runscript.{self._driver_name}"
return self.rundir / f"runscript.{self.driver_name}"

@property
def _scheduler(self) -> JobScheduler:
Expand All @@ -480,7 +484,7 @@ def _validate(self, schema_file: Optional[Path] = None) -> None:
validate_external(schema_file=schema_file, config=self.config_full)
else:
validate_internal(
schema_name=self._driver_name.replace("_", "-"), config=self.config_full
schema_name=self.driver_name.replace("_", "-"), config=self.config_full
)
validate_internal(schema_name=STR.platform, config=self.config_full)

Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/esg_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def provisioned_rundir(self):
self.runscript(),
]

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/filter_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def provisioned_rundir(self):
self.runscript(),
]

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/fv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def runscript(self):
}
self._write_runscript(path=path, envvars=envvars)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/drivers/global_equiv_resol.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ def provisioned_rundir(self):
self.runscript(),
]

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.globalequivresol

# Private helper methods

@property
def _runcmd(self):
"""
Expand Down
16 changes: 9 additions & 7 deletions src/uwtools/drivers/ioda.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,23 @@ def provisioned_rundir(self):
self.runscript(),
]

# Private helper methods
# Public helper methods

@property
def _config_fn(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of the config file used in execution.
Returns the name of this driver.
"""
return "ioda.yaml"
return STR.ioda

# Private helper methods

@property
def _driver_name(self) -> str:
def _config_fn(self) -> str:
"""
Returns the name of this driver.
Returns the name of the config file used in execution.
"""
return STR.ioda
return "ioda.yaml"

@property
def _runcmd(self) -> str:
Expand Down
16 changes: 9 additions & 7 deletions src/uwtools/drivers/jedi.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ def validate_only(self):
logging.info("%s: Config is valid", taskname)
a.ready = lambda: True

# Private helper methods
# Public helper methods

@property
def _config_fn(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of the config file used in execution.
Returns the name of this driver.
"""
return "jedi.yaml"
return STR.jedi

# Private helper methods

@property
def _driver_name(self) -> str:
def _config_fn(self) -> str:
"""
Returns the name of this driver.
Returns the name of the config file used in execution.
"""
return STR.jedi
return "jedi.yaml"

@property
def _runcmd(self) -> str:
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/drivers/make_hgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ def provisioned_rundir(self):
yield self.taskname("provisioned run directory")
yield self.runscript()

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.makehgrid

# Private helper methods

@property
def _runcmd(self):
"""
Expand Down
8 changes: 5 additions & 3 deletions src/uwtools/drivers/make_solo_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ def taskname(self, suffix: str) -> str:
:param suffix: Log-string suffix.
"""
return "%s %s" % (self._driver_name, suffix)
return "%s %s" % (self.driver_name, suffix)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.makesolomosaic

# Private helper methods

@property
def _runcmd(self):
"""
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/drivers/mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ def namelist_file(self):
schema=self._namelist_schema(),
)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.mpas

# Private helper methods

@property
def _streams_fn(self) -> str:
"""
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/drivers/mpas_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ def namelist_file(self):
schema=self._namelist_schema(),
)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.mpasinit

# Private helper methods

@property
def _streams_fn(self) -> str:
"""
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/drivers/orog_gsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ def topo_data_30s(self):
yield asset(dst, dst.is_file)
yield symlink(target=src, linkname=dst)

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.oroggsl

# Private helper methods

@property
def _runcmd(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def provisioned_rundir(self):
yield self.taskname("provisioned run directory")
yield self.namelist_file()

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/sfc_climo_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def provisioned_rundir(self):
self.runscript(),
]

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/drivers/shave.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ def provisioned_rundir(self):
yield self.taskname("provisioned run directory")
yield self.runscript()

# Private helper methods
# Public helper methods

@property
def _driver_name(self) -> str:
def driver_name(self) -> str:
"""
Returns the name of this driver.
"""
return STR.shave

# Private helper methods

@property
def _runcmd(self):
"""
Expand Down
Loading

0 comments on commit cb2700c

Please sign in to comment.