Skip to content

Commit bf614d0

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 bf614d0

File tree

2 files changed

+229
-0
lines changed

2 files changed

+229
-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: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
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 integer 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+
Each of these will be described in further detail.
90+
91+
Resource
92+
^^^^^^^^
93+
94+
A resource is a named entity that represents a physical or virtual resource.
95+
The name of the resource MAY be lowercase, but it SHOULD be capitalized.
96+
Resource groups are separated by colons ``:``.
97+
As an example, the following shape indicates a single node with 1 core:
98+
99+
.. ::code-block console
100+
101+
Node:Core
102+
103+
and is expanded to
104+
105+
.. ::code-block yaml
106+
107+
resources:
108+
- type: Node
109+
count: 1
110+
with:
111+
- type: Core
112+
count: 1
113+
114+
In the YAML above, note that the resource name (e.g., "Node" or "Core") is mapped
115+
to the resources "type," and is always added as an item in a list. Given that a resource
116+
list has children, these are appended via the "with" attribute.
117+
118+
119+
Count
120+
^^^^^
121+
122+
Note that for a count of 1 for any resource, it MAY be defined but is optional.
123+
All of these shapes would expand to the same resources shown above:
124+
125+
.. ::code-block console
126+
127+
Node:Core
128+
Node:Core[1]
129+
Node[1]:Core
130+
Node[1]:Core[1]
131+
132+
133+
The ``count`` is thus optional, and when provided, must be a positive integer value.
134+
The count maps directly to the number we provided in brackets, and when not present, it defaults to
135+
1.
136+
137+
Attributes
138+
^^^^^^^^^^
139+
140+
Attributes are additional qualifiers that can be added to any resource, inside
141+
of the brackets. An attribute MUST be a known resource vertex as defined in RFC
142+
25. Attributes can be key value pairs or a boolean, where each is prefixed by a
143+
``+``. For a key value pair, the format is ``[+key=value]`` and for a boolean
144+
flag (to indicate presence) it takes the general format ``[+flag]``.
145+
As an example, starting with these shapes (that are equivalent):
146+
147+
148+
.. ::code-block console
149+
150+
Node[4]:Slot:Core[2]
151+
Node[4]:Slot[1]:Core[2]
152+
153+
Are equivalent and are expanded to:
154+
155+
.. ::code-block yaml
156+
157+
resources:
158+
- type: node
159+
count: 4
160+
with:
161+
- type: slot
162+
count: 1
163+
with:
164+
- type: core
165+
count: 2
166+
167+
168+
To add the attribute "label" to the same graph we might do:
169+
170+
.. ::code-block console
171+
172+
Node[4]:Slot[+label=default]:Core[2]
173+
Node[4]:Slot[1+label=default]:Core[2]
174+
175+
176+
To generate this YAML document:
177+
178+
.. ::code-block yaml
179+
180+
resources:
181+
- type: node
182+
count: 4
183+
with:
184+
- type: slot
185+
count: 1
186+
label: default
187+
with:
188+
- type: core
189+
count: 2
190+
191+
192+
Note that when a number is provided, it doesn't need an additional separator
193+
between the count (1) and label as the ``+`` acts as this delimiter.
194+
195+
Groups
196+
^^^^^^
197+
198+
Finally, it is possible to define multiple resources at the same level with the addition
199+
of parentheses. We call this a group. As an example, this shape:
200+
201+
.. ::code-block console
202+
203+
Node[5]:(Core[5],GPU[1])
204+
205+
Would map to this resource graph:
206+
207+
.. ::code-block yaml
208+
209+
resources:
210+
- type: node
211+
count: 5
212+
with:
213+
- type: core
214+
count: 5
215+
- type: gpu
216+
count: 1
217+
218+
The assumption of this design is that most shape specifications would not have
219+
huge complexity of nesting. Any resource specification that warrants such complexity
220+
would best be defined in a YAML document directly.

0 commit comments

Comments
 (0)