1 | {
|
2 | "title": "CodeExpression",
|
3 | "@id": "stencila:CodeExpression",
|
4 | "extends": "CodeExecutable",
|
5 | "role": "secondary",
|
6 | "status": "unstable",
|
7 | "category": "code",
|
8 | "description": "An executable programming code expression.",
|
9 | "properties": {
|
10 | "type": {
|
11 | "@id": "schema:type",
|
12 | "description": "The name of the type.",
|
13 | "type": "string",
|
14 | "enum": [
|
15 | "CodeExpression"
|
16 | ],
|
17 | "default": "CodeExpression",
|
18 | "from": "Entity"
|
19 | },
|
20 | "id": {
|
21 | "@id": "schema:id",
|
22 | "description": "The identifier for this item.",
|
23 | "type": "string",
|
24 | "from": "Entity"
|
25 | },
|
26 | "meta": {
|
27 | "@id": "stencila:meta",
|
28 | "description": "Metadata associated with this item.",
|
29 | "type": "object",
|
30 | "from": "Entity"
|
31 | },
|
32 | "text": {
|
33 | "@id": "schema:text",
|
34 | "description": "The text of the code.",
|
35 | "type": "string",
|
36 | "from": "Code"
|
37 | },
|
38 | "programmingLanguage": {
|
39 | "@id": "schema:programmingLanguage",
|
40 | "description": "The programming language of the code.",
|
41 | "type": "string",
|
42 | "from": "Code",
|
43 | "isOverride": true
|
44 | },
|
45 | "mediaType": {
|
46 | "@id": "schema:encodingFormat",
|
47 | "aliases": [
|
48 | "encodingFormat"
|
49 | ],
|
50 | "description": "Media type, typically expressed using a MIME format, of the code.",
|
51 | "$comment": "This property allows the differentiation of formats using the same programming language\nor variants of a programming language. An example is using `programmingLanguage` \"json\" and\n`encodingFormat` \"application/ld+json\" for JSON-LD code examples.\n",
|
52 | "type": "string",
|
53 | "from": "Code"
|
54 | },
|
55 | "codeDependencies": {
|
56 | "@id": "stencila:codeDependencies",
|
57 | "description": "The upstream dependencies of the code.",
|
58 | "type": "array",
|
59 | "items": {
|
60 | "anyOf": [
|
61 | {
|
62 | "$ref": "CodeChunk.schema.json"
|
63 | },
|
64 | {
|
65 | "$ref": "Parameter.schema.json"
|
66 | }
|
67 | ]
|
68 | },
|
69 | "$comment": "Note that this excludes `CodeExpression` nodes since they should not have side effects\n(e.g. assigning variables) that would cause another node to be dependent upon them.\n",
|
70 | "from": "CodeExecutable",
|
71 | "isArray": true,
|
72 | "isPlural": true,
|
73 | "aliases": [
|
74 | "codeDependencie"
|
75 | ]
|
76 | },
|
77 | "codeDependents": {
|
78 | "@id": "stencila:codeDependents",
|
79 | "description": "The downstream dependents of the code.",
|
80 | "type": "array",
|
81 | "items": {
|
82 | "anyOf": [
|
83 | {
|
84 | "$ref": "CodeChunk.schema.json"
|
85 | },
|
86 | {
|
87 | "$ref": "CodeExpression.schema.json"
|
88 | }
|
89 | ]
|
90 | },
|
91 | "$comment": "Note that in comparison to `codeDependencies`, this property does not allow for `Parameter`\ndependents (because parameters are never dependent upon others).\n",
|
92 | "from": "CodeExecutable",
|
93 | "isArray": true,
|
94 | "isPlural": true,
|
95 | "aliases": [
|
96 | "codeDependent"
|
97 | ]
|
98 | },
|
99 | "compileDigest": {
|
100 | "@id": "stencila:compileDigest",
|
101 | "description": "A digest of the content, semantics and dependencies of the node.",
|
102 | "type": "string",
|
103 | "from": "CodeExecutable"
|
104 | },
|
105 | "executeCount": {
|
106 | "@id": "stencila:executeCount",
|
107 | "description": "A count of the number of times that the node has been executed.",
|
108 | "type": "integer",
|
109 | "minimum": 0,
|
110 | "$comment": "Intended to increment with each successive execution of the node, including across sessions.\nNote that this differs to the `execution_count` in Jupyter Notebook format which is\nthe \"code cell's prompt number\" and which resets at the start of each new session.\n",
|
111 | "from": "CodeExecutable"
|
112 | },
|
113 | "executeDigest": {
|
114 | "@id": "stencila:executeDigest",
|
115 | "description": "The `compileDigest` of the node when it was last executed.",
|
116 | "type": "string",
|
117 | "from": "CodeExecutable"
|
118 | },
|
119 | "executeRequired": {
|
120 | "@id": "stencila:executeRequired",
|
121 | "description": "Whether, and why, a node requires execution or re-execution.",
|
122 | "enum": [
|
123 | "No",
|
124 | "NeverExecuted",
|
125 | "SemanticsChanged",
|
126 | "DependenciesChanged",
|
127 | "DependenciesFailed"
|
128 | ],
|
129 | "$comment": "Derived from a comparison of `compileDigest` and `executeDigest` and the `executeStatus`\nof dependencies.\n`No`: no re-execution is required, the semantics of the code and its dependencies has not changed\nsince it was last executed.\n`NeverExecuted`: execution is required because the code has never been executed (or any previous\nexecution was not persisted in its state).\n`SemanticsChanged`: re-execution is required because the semantics of the code has changed since it was\nlast executed.\n`DependenciesChanged`: the semantics of one or more dependencies (including transitive dependencies) \nchanged since it was last executed.\n`DependenciesFailed`: one or more dependencies (including transitive dependencies) failed when it was\nlast executed.\n",
|
130 | "from": "CodeExecutable"
|
131 | },
|
132 | "executeStatus": {
|
133 | "@id": "stencila:executeStatus",
|
134 | "description": "Status of the most recent, including any current, execution of the code.",
|
135 | "enum": [
|
136 | "Scheduled",
|
137 | "ScheduledPreviouslyFailed",
|
138 | "Running",
|
139 | "RunningPreviouslyFailed",
|
140 | "Succeeded",
|
141 | "Failed",
|
142 | "Cancelled"
|
143 | ],
|
144 | "from": "CodeExecutable"
|
145 | },
|
146 | "executeEnded": {
|
147 | "@id": "stencila:executeEnded",
|
148 | "description": "The date-time that the the last execution of the code ended.",
|
149 | "$ref": "Date.schema.json",
|
150 | "from": "CodeExecutable"
|
151 | },
|
152 | "executeDuration": {
|
153 | "@id": "stencila:executeDuration",
|
154 | "description": "Duration in seconds of the last execution of the code.",
|
155 | "type": "number",
|
156 | "minimum": 0,
|
157 | "from": "CodeExecutable"
|
158 | },
|
159 | "errors": {
|
160 | "@id": "stencila:errors",
|
161 | "description": "Errors when compiling (e.g. syntax errors) or executing the chunk.",
|
162 | "type": "array",
|
163 | "items": {
|
164 | "$ref": "CodeError.schema.json"
|
165 | },
|
166 | "from": "CodeExecutable",
|
167 | "isArray": true,
|
168 | "isPlural": true,
|
169 | "aliases": [
|
170 | "error"
|
171 | ]
|
172 | },
|
173 | "output": {
|
174 | "@id": "stencila:output",
|
175 | "description": "The value of the expression when it was last evaluated.",
|
176 | "allOf": [
|
177 | {
|
178 | "$ref": "Node.schema.json"
|
179 | }
|
180 | ],
|
181 | "from": "CodeExpression"
|
182 | }
|
183 | },
|
184 | "$comment": "Note that `CodeExpression` nodes lack the `executeAuto` and `executePure` properties that `CodeChunk` nodes have because they will always be executed (when dependencies) change and should be side-effect free.",
|
185 | "file": "CodeExpression.schema.yaml",
|
186 | "children": [],
|
187 | "descendants": [],
|
188 | "$schema": "http://json-schema.org/draft-07/schema#",
|
189 | "$id": "https://schema.stenci.la/v1/CodeExpression.schema.json",
|
190 | "source": "https://github.com/stencila/schema/blob/master/schema/CodeExpression.schema.yaml",
|
191 | "type": "object",
|
192 | "additionalProperties": false,
|
193 | "required": [
|
194 | "type",
|
195 | "text",
|
196 | "programmingLanguage"
|
197 | ],
|
198 | "propertyAliases": {
|
199 | "encodingFormat": "mediaType",
|
200 | "codeDependencie": "codeDependencies",
|
201 | "codeDependent": "codeDependents",
|
202 | "error": "errors"
|
203 | }
|
204 | }
|