Skip to content

Commit dca34c4

Browse files
committed
add command line jobspec
Problem: we cannot define a shape on the command line to map into a job specification resources section. Solution: first add a command line jobspec that defines this shape. Signed-off-by: vsoch <[email protected]>
1 parent e83e8c7 commit dca34c4

File tree

2 files changed

+230
-0
lines changed

2 files changed

+230
-0
lines changed

index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ I/O streams in the Flux KVS.
185185
Version 1 of the domain specific job specification language
186186
canonically defined in RFC14.
187187

188+
188189
:doc:`26/Job Dependency Specification <spec_26>`
189190
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190191

@@ -257,6 +258,13 @@ and other directives in files.
257258
The File Archive Format defines a JSON representation of a set or list
258259
of file system objects.
259260

261+
:doc:`38/Command Line Job Specification Version 1 <spec_38>`
262+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263+
264+
The command line jobspec describes how to define a shape on the
265+
command line that expands out to a full Job Specification.
266+
It can be provided to several Flux commands.
267+
260268
.. Each file must appear in a toctree
261269
.. toctree::
262270
:hidden:
@@ -297,3 +305,4 @@ of file system objects.
297305
spec_35
298306
spec_36
299307
spec_37
308+
spec_38

spec_38.rst

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
.. github display
2+
GitHub is NOT the preferred viewer for this file. Please visit
3+
https://flux-framework.rtfd.io/projects/flux-rfc/en/latest/spec_37.html
4+
5+
38/Command Line Job Specification Version 1
6+
===========================================
7+
8+
The Command Line Job Specification includes specification of a shape string
9+
that can be provided to several Flux commands by a user to expand into a resource
10+
graph. This RFC describes version 1 of jobspec, which represents a request
11+
to run one or more tasks, and can be provided to a flux run, batch, or submit.
12+
13+
- Name: github.com/flux-framework/rfc/spec_37.rst
14+
- Editor: Vanessa Sochat <[email protected]>
15+
- State: raw
16+
17+
Language
18+
--------
19+
20+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
21+
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to
22+
be interpreted as described in `RFC 2119 <https://tools.ietf.org/html/rfc2119>`__.
23+
24+
25+
Related Standards
26+
-----------------
27+
28+
- :doc:`4/Flux Resource Model <spec_4>`
29+
30+
- :doc:`8/Flux Task and Program Execution Services <spec_8>`
31+
32+
- :doc:`14/Canonical Job Specification <spec_14>`
33+
34+
- :doc:`20/Resource Set Specification Version 1 <spec_20>`
35+
36+
- :doc:`25/Job Specification Version 1 <spec_25>`
37+
38+
- :doc:`26/Job Dependency Specification <spec_26>`
39+
40+
- :doc:`31/Job Constraints Specification <spec_31>`
41+
42+
43+
Goals
44+
-----
45+
46+
- Express a resource specification on the command line, a "shape." to expand into the resources of a Job Specification (rfc 25).
47+
48+
- The shape should include resources, counts, attributes, and grouping.
49+
50+
- Allow to be included in several submission contexts, including submit, run, and batch.
51+
52+
53+
Overview
54+
--------
55+
56+
This RFC describes the version 1 form of the command line jobspec,
57+
a string that can be expanded out into a Job Specification resources section.
58+
The version 1 of the command line jobspec SHALL consist of
59+
a single string of resources, attributes, and groups that can be mapped out
60+
into a YAML document representing a reusable request to run
61+
one or more tasks on a set of resources.
62+
63+
64+
Command Line Job Definition
65+
---------------------------
66+
67+
A command line V1 specification SHALL consist of a shape definition,
68+
a string that describes resources, attributes, and groups. This
69+
shape specification can be expanded to the ``resources`` section
70+
of a YAML document. The shape SHALL meet the form and requirements
71+
listed in detail in the sections below.
72+
73+
74+
Shape
75+
~~~~~
76+
77+
The value of the ``shape`` key SHALL be a single shape (string value).
78+
A shape is expanded into a resource definition. Only one of shape OR
79+
resources is allowed, and one is required. A shape takes the general format
80+
of ``Resource[Count+Attribute]`` where:
81+
82+
- ``Resource`` includes the set defined below
83+
- ``Count`` is a positive intege to indicate the number of the resource
84+
- ``Attribute`` is indicated by the presence of a ``+`` and can be a key value pair ``+label=nodes`` or a boolean value ``+exclusive``
85+
86+
And groups of resources can be indicated by adding parentheses, and having
87+
resources inside the group separated by a comma. E.g.,: ``A(B[1],C[2])``.
88+
89+
90+
Each of these will be described in further detail.
91+
92+
Resource
93+
^^^^^^^^
94+
95+
A resource is a named entity that represents a physical or virtual resource.
96+
The name of the resource MAY be lowercase, but it SHOULD be capitalized.
97+
Resource groups are separated by colons ``:``.
98+
As an example, the following shape indicates a single node with 1 core:
99+
100+
.. ::code-block console
101+
102+
Node:Core
103+
104+
and is expanded to
105+
106+
.. ::code-block yaml
107+
108+
resources:
109+
- type: Node
110+
count: 1
111+
with:
112+
- type: Core
113+
count: 1
114+
115+
In the YAML above, note that the resource name (e.g., "Node" or "Core") is mapped
116+
to the resources "type," and is always added as an item in a list. Given that a resource
117+
list has children, these are appended via the "with" attribute.
118+
119+
120+
Count
121+
^^^^^
122+
123+
Note that for a count of 1 for any resource, it MAY be defined but is optional.
124+
All of these shapes would expand to the same resources shown above:
125+
126+
.. ::code-block console
127+
128+
Node:Core
129+
Node:Core[1]
130+
Node[1]:Core
131+
Node[1]:Core[1]
132+
133+
134+
The ``count`` is thus optional, and when provided, must be a positive integer value.
135+
The count maps directly to the number we provided in brackets, and when not present, it defaults to
136+
1.
137+
138+
Attributes
139+
^^^^^^^^^^
140+
141+
Attributes are additional qualifiers that can be added to any resource, inside
142+
of the brackets. An attribute MUST be a known resource vertex as defined in RFC
143+
25. Attributes can be key value pairs or booleans, where each is prefixed by a
144+
``+``. For a key value pair, the format is ``[+key=value]`` and for a boolean
145+
flag (to indicate presence) it takes the general format ``[+flag]``.
146+
As an example, starting with these shapes (that are equivalent):
147+
148+
149+
.. ::code-block console
150+
151+
Node[4]:Slot:Core[2]
152+
Node[4]:Slot[1]:Core[2]
153+
154+
Are equivalent and are expanded to:
155+
156+
.. ::code-block yaml
157+
158+
resources:
159+
- type: node
160+
count: 4
161+
with:
162+
- type: slot
163+
count: 1
164+
with:
165+
- type: core
166+
count: 2
167+
168+
169+
To add the attribute "label" to the same graph we might do:
170+
171+
.. ::code-block console
172+
173+
Node[4]:Slot[+label=default]:Core[2]
174+
Node[4]:Slot[1+label=default]:Core[2]
175+
176+
177+
To generate this YAML document:
178+
179+
.. ::code-block yaml
180+
181+
resources:
182+
- type: node
183+
count: 4
184+
with:
185+
- type: slot
186+
count: 1
187+
label: default
188+
with:
189+
- type: core
190+
count: 2
191+
192+
193+
Note that when a number is provided, it doesn't need an additional separator
194+
between the count (1) and label as the ``+`` acts as this delimiter.
195+
196+
Groups
197+
^^^^^^
198+
199+
Finally, it is possible to define multiple resources at the same level with the addition
200+
of parentheses. We call this a group. As an example, this shape:
201+
202+
.. ::code-block console
203+
204+
Node[5]:(Core[5],GPU[1])
205+
206+
Would map to this resource graph:
207+
208+
.. ::code-block yaml
209+
210+
resources:
211+
- type: node
212+
count: 5
213+
with:
214+
- type: core
215+
count: 5
216+
- type: gpu
217+
count: 1
218+
219+
The assumption of this design is that most shape specifications would not have
220+
huge complexity of nesting. Any resource specification that warrants such complexity
221+
would best be defined in a YAML document directly.

0 commit comments

Comments
 (0)