Skip to content

Commit

Permalink
rfc14: require exactly one key in tasks.count
Browse files Browse the repository at this point in the history
Problem: the desired number of tasks is ambiguous if more than one key
is set in tasks.count (but exactly one is required)

Update spec_14 to specify that tasks.count SHALL have exactly one
supported key set, and update jsonschema to match (also added
per_resource definition to the jsonschema)
  • Loading branch information
sam-maloney committed Feb 12, 2025
1 parent a1324d4 commit b39946b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
18 changes: 14 additions & 4 deletions data/spec_14/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{ "$ref": "#/definitions/resource_vertex_base" },
{
"properties": {
"type": { "enum": ["slot"] }
"type": { "const": "slot" }
},
"required": ["label"]
}
Expand All @@ -64,7 +64,7 @@
{ "$ref": "#/definitions/resource_vertex_base" },
{
"properties": {
"type": { "not": { "enum": ["slot"] } }
"type": { "not": { "const": "slot" } }
}
}
]
Expand Down Expand Up @@ -117,7 +117,7 @@
"type": "array",
"items": {
"type": "object",
"required": ["command", "slot", "count" ],
"required": ["command", "slot", "count"],
"properties": {
"command": {
"type": "array",
Expand All @@ -127,8 +127,18 @@
"slot": { "type": "string" },
"count": {
"type": "object",
"minProperties": 1,
"maxProperties": 1,
"properties": {
"per_slot": { "type": "integer", "minimum" : 1 },
"per_resource": {
"type": "object",
"required": ["type", "count"],
"properties": {
"type": { "type": "string" },
"count": { "type": "integer", "minimum": 1 }
}
},
"total": { "type": "integer", "minimum" : 1 }
}
},
Expand All @@ -138,7 +148,7 @@
"properties": {
"environment": { "type" : "object"}
},
"additionalProperties": { "type": "string" }
"additionalProperties": { "type": "string" }
}
},
"additionalProperties": false
Expand Down
42 changes: 21 additions & 21 deletions spec_14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,45 +229,45 @@ Reserved Resource Types
Tasks
=====

The value of the ``tasks`` key SHALL be a strict list which MUST
define at least one task. Each list element SHALL be a dictionary
representing a task or tasks to run as part of the program. A task
descriptor SHALL contain the following keys:
The ``tasks`` key SHALL be a strict list which MUST define at least one task.
Each list element SHALL be a dictionary representing a task or tasks to run as
part of the program. A task descriptor SHALL contain the following keys:

**command**
The value of the ``command`` key SHALL be a list representing an
executable and its arguments.
The ``command`` key SHALL be a list representing an executable and its
arguments.

**slot**
The value of the ``slot`` key SHALL match a ``label`` of a resource vertex
of type ``slot``. It is used to indicate the **task slot**
The ``slot`` key SHALL be a string matching the ``label`` of a resource
vertex of type ``slot``. It is used to indicate the **task slot**
on which this task or tasks shall be contained and executed. The
number of tasks executed per task slot SHALL be a function of the
number of resource slots and total number of tasks requested to execute.

**count**
The value of the ``count`` key SHALL be a dictionary supporting at
least the keys ``per_slot``, ``per_resource``, and ``total``, with other keys
reserved for future or site-specific extensions.
The ``count`` key SHALL be a dictionary supporting at least the keys
``per_slot``, ``per_resource``, and ``total``, with other keys reserved for
future or site-specific extensions, and SHALL contain exactly one supported
key.

**per_slot**
The value of ``per_slot`` SHALL be a number indicating the number
The ``per_slot`` key SHALL be a positive integer indicating the number
of tasks to execute per task slot allocated to the program.

**per_resource**
The value of ``per_resource`` SHALL be a dictionary which
SHALL contain the following keys:
The ``per_resource`` SHALL be a dictionary which SHALL contain the
following keys:

- **type** The value of the ``type`` key SHALL be a resource type explicitly
declared in the associated task’s slot.
- **type** The ``type`` key SHALL be a string matching a resource type
explicitly declared in the associated task’s slot.

- **count** The value of the ``count`` key SHALL be a number indicating the number
of tasks to execute per resource of type ``type`` occurring in the task’s
slot.
- **count** The ``count`` key SHALL be a positive integer indicating
the number of tasks to execute per resource of type ``type`` occurring
in the task’s slot.

**total**
The value of the ``total`` field SHALL indicate the total number of
tasks to be run across all task slots, possibly oversubscribed.
The ``total`` key SHALL be a positive integer indicating the total number
of tasks to be run across all task slots, possibly oversubscribed.

**attributes**
The ``attributes`` key SHALL be a free-form dictionary of keys which may
Expand Down

0 comments on commit b39946b

Please sign in to comment.