pyflightstream.workspace.hpc (provisional)¶
Generated from the docstrings at build time: every one of the 13 names in the __all__ of pyflightstream.workspace.hpc has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The HPC profile of a workspace: the cluster it may be opened on (FR-99).
A workspace keeps, under hpc/, the profile of each cluster its campaign
may be submitted to: the scheduler's name for the application (the one
mandatory field), the descriptor format the package writes, the walltime
arithmetic, the log keys (FR-311) and the [builds] table that maps each
canonical build to the name this scheduler gives it. :func:read_hpc_profile
reads one into an :class:HpcProfile, refusing an unknown or misplaced key
by name, and :func:resolve_hpc_profile finds the one a run names.
Every public name but :func:select_hpc_profile is re-exported, unchanged, by
:mod:pyflightstream.workspace.inputs, its path (AD-11); the selector is imported from
this module.
Advanced¶
pyflightstream.workspace.hpc.HPC_FORMATS
module-attribute
¶
HPC_FORMATS = ('yaml', 'json', 'toml', 'text')
pyflightstream.workspace.hpc.HPC_LOG_KEYS
module-attribute
¶
HPC_LOG_KEYS: frozenset[str] = frozenset(
{"export_log", "native_log", "job_end_files"}
)
pyflightstream.workspace.hpc.HPC_PROFILE_KEYS
module-attribute
¶
HPC_PROFILE_KEYS: frozenset[str] = frozenset(
{
"application_id",
"descriptor",
"submit",
"defaults",
"builds",
"application_ids",
"walltime_arithmetic",
"log",
"max_walltime",
"job_root",
}
)
pyflightstream.workspace.hpc.HpcProfile
dataclass
¶
HpcProfile(
application_id: str,
descriptor_format: str,
descriptor_name: str,
fields: dict,
submit: tuple,
path: Path,
builds: dict = dict(),
application_ids: dict = dict(),
walltime_arithmetic: str = "wall",
export_log: bool = True,
native_log: str | None = None,
job_end_files: tuple[str, ...] = (),
max_walltime_s: float | None = None,
job_root: str = "{work_dir}",
)
How ONE cluster is asked to run a job (FR-99).
NO ROW CITES THIS. The code sees Linux and that is the cluster, so a study moves between machines by being opened on the other one and changing no cell.
Attributes:
| Name | Type | Description |
|---|---|---|
application_id |
str
|
The scheduler's own name for the application, for every build
|
descriptor_format |
str
|
One of :data: |
descriptor_name |
str
|
What it is called inside the simulation folder. |
fields |
dict of str to str
|
The keys THIS cluster expects, in the order they are written, and
what pyflightstream puts in each. A value in braces is substituted.
A cluster that spells |
submit |
tuple of str
|
The command, argument by argument, never one string through a shell: a path with a space in it is then not a second argument. |
path |
Path
|
Where this was read from, for a refusal that has to name it. |
builds |
dict of str to str
|
What this scheduler calls each canonical build, read from the
|
application_ids |
dict of str to str
|
The application name per canonical build where it differs from
|
application_id_for
¶
application_id_for(build: object) -> str
Return the application name the descriptor writes for build.
The line of [application_ids] for that canonical build when the
profile has one, otherwise the top-level application_id.
pyflightstream.workspace.hpc.WALLTIME_ARITHMETIC
module-attribute
¶
WALLTIME_ARITHMETIC: frozenset[str] = frozenset(
{"wall", "seconds"}
)
pyflightstream.workspace.hpc.descriptor_name_refusal
¶
descriptor_name_refusal(
name: str, source: object
) -> str | None
Why name cannot name a submission descriptor, or None when it can.
The descriptor is written in the folder each point runs in, so its name
is a plain file name: no folder, no parent folder, and no form Windows
reads as another file's, any of which would put it on a file another
point's record names. source names the profile in the sentence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The descriptor name the profile states. |
required |
source
|
object
|
The profile (usually its path), named in the refusal sentence. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
The sentence that says why |
pyflightstream.workspace.hpc.hpc_profiles
¶
hpc_profiles(inputs_dir: str | Path) -> list[Path]
Every HPC profile a workspace carries, sorted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs_dir
|
str or Path
|
The workspace |
required |
Returns:
| Type | Description |
|---|---|
list of Path
|
The profile files in name order; empty when the folder is absent or holds none. |
pyflightstream.workspace.hpc.read_hpc_profile
¶
read_hpc_profile(path: str | Path) -> HpcProfile
Read one HPC profile, refusing what it cannot act on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
The profile file, a TOML document. |
required |
Returns:
| Type | Description |
|---|---|
HpcProfile
|
The profile read from the file. |
Raises:
| Type | Description |
|---|---|
InputArtifactError
|
If the file is not valid TOML, lacks the scheduler's application name, asks for a descriptor format or walltime arithmetic this package does not write, names a descriptor that is not a plain file name, lists no descriptor fields or no submit command, states a key this package does not read (or one it owns under the wrong table), states descriptor, submit or log as something other than a table, or states export_log as anything but true or false. |
pyflightstream.workspace.hpc.resolve_hpc_profile
¶
resolve_hpc_profile(
inputs_dir: str | Path,
) -> HpcProfile | None
Return the profile of the cluster this workspace is on, or None.
ONE PROFILE NEEDS NO SELECTOR. A workspace carrying several and no
selection (:func:select_hpc_profile, CLI --hpc NAME) is REFUSED
rather than guessed, because guessing spends a queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs_dir
|
str or Path
|
The workspace |
required |
Returns:
| Type | Description |
|---|---|
HpcProfile or None
|
The selected profile, else the profile of the one cluster the workspace carries, or None when it carries no profile. |
Raises:
| Type | Description |
|---|---|
InputArtifactError
|
If a selection names no profile of the folder, if the folder holds
more than one profile and none is selected, or the profile is refused
by :func: |
pyflightstream.workspace.hpc.select_hpc_profile
¶
select_hpc_profile(name: str | None) -> None
Select which profile :func:resolve_hpc_profile returns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str or None
|
The file stem of the profile, |
required |
Returns:
| Type | Description |
|---|---|
None
|
The selection is held in a context variable, so it belongs to the invocation that made it. |