-
Notifications
You must be signed in to change notification settings - Fork 51
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
shell: support more mustache tags #6525
Conversation
ee8f2e2
to
fdf8226
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just a couple minor nits
@@ -577,6 +577,8 @@ static json_t *flux_shell_get_rank_info_object (flux_shell_t *shell, int rank) | |||
char *taskids = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message: s/usefule/useful/
doc/man1/flux-shell.rst
Outdated
@@ -610,13 +610,17 @@ supported. Job shell specific functions and tables are described below: | |||
then the current rank is used. Returns a table of rank-specific | |||
information including: | |||
|
|||
**id** | |||
The current shell rank (matches ``shell_rank`` input parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a close paren
Problem: The `void *` arg for the mustache renderer is passed to mustache_renderer_create() and can't be changed, limiting flexibility. Move `arg` to mustache_render() from mustache_renderer_create(). Update callers.
Problem: The shell doesn't support expansion of task-specific tags in mustache templates. Add support for the following task-specific tags: - {{taskid}}, {{task.id}}, {{task.rank}} - global task rank - {{task.index}}, {{task.localid}} - local task rank
Problem: Some useful data is not included in the result object returned from flux_shell_get_rank_info(3). Add the following new items to the rank_info object: - id (int) The shell rank the object describes - name (str) hostname - resources.ncores (int) Count of cores
Problem: The new keys available in the shell "rank_info" object are not documented. Update the documentation in flux-shell(1) and flux_shell_get_rank_info(3).
Problem: The shell doesn't support expansion of any node-specific tags in mustache templates. Add support for expansion of node-specific data via a set of node.<key> mustache tags. The <key> is pulled directly from the shell "rank info" object, so any item present in that object can be expanded, including {{node.id}} for the nodeid (job local node rank), {{node.name}} for the hostname, {{node.taskids}} for the list of tasks assigned to the node, etc.
Problem: It would be useful to have mustache tags that expand to the job size/ntasks and total number of nodes in the current job, but this is currently not supported. Support these tags in the job shell mustache renderer.
Problem: Callers to flux_shell_mustache_render() may want to know if a tag or tags is not supported, but not necessarily have an error logged to the job. Return an error with errno=ENOENT instead of logging an error when a tag is not supported and it is practical to do so.
Problem: The current set of supported mustache tags is not documented in the submission cli manual pages. Add a new MUSTACHE TEMPLATES section in doc/man1/common/job-mustache-templates.rst and include it in relevant manuals, replacing the short bit of text in common/job-standard-io.rst.
Problem: There are no specific tests for testing shell mustache template expansion. Add t2620-job-shell-mustache.t for this purpose.
Problem: An R object used for alloc-bypass in the testsuite doesn't contain the nodelist key, which trips up the job shell. Ensure the Rv1 object is compliant with RFC 20, which requires that nodelist is present.
fdf8226
to
d8777dd
Compare
Thanks! Fixed those and I'll set MWP. |
Thanks! Fixed those errors and will set MWP. |
Hm, two builders failed in
I assume this is unrelated to this PR so I'll restart those. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6525 +/- ##
==========================================
+ Coverage 83.62% 83.64% +0.01%
==========================================
Files 522 522
Lines 87809 87860 +51
==========================================
+ Hits 73433 73488 +55
+ Misses 14376 14372 -4
|
This PR adds new mustache tags specific to tasks and nodes (shell rank, really), formatted as
{{task.*}}
and{{node.*}}
, with a couple special cases. The node tags use the "rank info" object in the shell to render results, which has been updated with additional items for mustache tag use.Since there are many more supported tags to document, a new MUSTACHE TEMPLATES section is added to the job submission ccommands' manual pages, pasted here since it contains the set of supported tags:
MUSTACHE TEMPLATES
Submission commands support a simplified version of mustache templates in select options (e.g.,
--output
,--error
,--dump
), and job commands/arguments. These templates are replaced by job details once available. A mustache template is a tag in double braces, like{{tag}}
.The following is a list of currently supported tags:
Job mustache tags:
{{id}}
or{{jobid}}
Expands to the current jobid in F58 encoding. If needed, an alternate encoding may be selected by using a subkey with the name of the desired encoding, e.g.,
{{id.dec}}
. Supported encodings includef58
(the default),dec
,hex
,dothex
, andwords
.{{name}}
Expands to the current job name. If a name is not set for the job, then the basename of the command will be used.
{{nnodes}}
Expands to the number of nodes allocated to the job.
{{size}}
or{{ntasks}}
Expands to the job size, or total number of tasks in the job.
Node-specific tags
Node-specific tags are prefixed with
node.
, and support any of the keys present in the object returned byflux_shell_get_rank_info
. These include:{{node.id}}
Expands to the current node index within the job (0 - nnodes-1).
{{node.name}}
Expands to the hostname of the current node.
{{node.broker_rank}}
Expands to the broker rank of the enclosing instance on this node.
{{node.cores}}
Expands to the core id list assigned to the current node in idset form. For example,
0-3
or1
.{{node.gpus}}
Expands to the GPU id list assigned to the job on this node in idset form, e.g.,
0-1
or4
.{{node.ncores}}
Expands to the number of cores allocated to the job on this node.
Task-specific tags
Task-specific tags are prefixed with
task.
, with the special case of{{taskid}}
, which is an alias for{{task.id}}
.{{task.id}}
,{{task.rank}}
, or{{taskid}}
Expands to the global rank for the current task
{{task.index}}
or{{task.localid}}
Expands to the local rank for the current task
Other tags:
{{tmpdir}}
Expands to the path of the job temporary directory on the local system.
If an unknown mustache tag is encountered, an error message may be displayed and the unknown template will appear in the result.