Code Expression
An executable programming code expression.
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.
This schema type is marked as unstable ⚠️ and is subject to change.
Properties
Name | @id | Type | Description | Inherited from |
---|---|---|---|---|
programmingLanguage | schema:programmingLanguage | string | The programming language of the code. | Code |
text | schema:text | string | The text of the code. | Code |
codeDependencies | stencila:codeDependencies | Array of (CodeChunk or Parameter) | The upstream dependencies of the code. See note 1. | CodeExecutable |
codeDependents | stencila:codeDependents | Array of (CodeChunk or CodeExpression) | The downstream dependents of the code. See note 2. | CodeExecutable |
compileDigest | stencila:compileDigest | string | A digest of the content, semantics and dependencies of the node. | CodeExecutable |
errors | stencila:errors | Array of CodeError | Errors when compiling (e.g. syntax errors) or executing the chunk. | CodeExecutable |
executeCount | stencila:executeCount | integer | A count of the number of times that the node has been executed. See note 3. | CodeExecutable |
executeDigest | stencila:executeDigest | string | The compileDigest of the node when it was last executed. | CodeExecutable |
executeDuration | stencila:executeDuration | number | Duration in seconds of the last execution of the code. | CodeExecutable |
executeEnded | stencila:executeEnded | Date | The date-time that the the last execution of the code ended. | CodeExecutable |
executeRequired | stencila:executeRequired | 'No', 'NeverExecuted', 'SemanticsChanged', 'DependenciesChanged', 'DependenciesFailed' | Whether, and why, a node requires execution or re-execution. See note 4. | CodeExecutable |
executeStatus | stencila:executeStatus | 'Scheduled', 'ScheduledPreviouslyFailed', 'Running', 'RunningPreviouslyFailed', 'Succeeded', 'Failed', 'Cancelled' | Status of the most recent, including any current, execution of the code. | CodeExecutable |
id | schema:id | string | The identifier for this item. | Entity |
mediaType | schema:encodingFormat | string | Media type, typically expressed using a MIME format, of the code. See note 5. | Code |
meta | stencila:meta | object | Metadata associated with this item. | Entity |
output | stencila:output | Node | The value of the expression when it was last evaluated. | CodeExpression |
Notes
- codeDependencies : Note that this excludes
CodeExpression
nodes since they should not have side effects (e.g. assigning variables) that would cause another node to be dependent upon them. - codeDependents : Note that in comparison to
codeDependencies
, this property does not allow forParameter
dependents (because parameters are never dependent upon others). - executeCount : Intended to increment with each successive execution of the node, including across sessions. Note that this differs to the
execution_count
in Jupyter Notebook format which is the "code cell's prompt number" and which resets at the start of each new session. - executeRequired : Derived from a comparison of
compileDigest
andexecuteDigest
and theexecuteStatus
of dependencies.No
: no re-execution is required, the semantics of the code and its dependencies has not changed since it was last executed.NeverExecuted
: execution is required because the code has never been executed (or any previous execution was not persisted in its state).SemanticsChanged
: re-execution is required because the semantics of the code has changed since it was last executed.DependenciesChanged
: the semantics of one or more dependencies (including transitive dependencies) changed since it was last executed.DependenciesFailed
: one or more dependencies (including transitive dependencies) failed when it was last executed. - mediaType : This property allows the differentiation of formats using the same programming language or variants of a programming language. An example is using
programmingLanguage
"json" andencodingFormat
"application/ld+json" for JSON-LD code examples.
Related
- Parent: CodeExecutable
- Descendants: None
Available as
- JSON-LD
- JSON Schema
- Python
class CodeExpression
- TypeScript
interface CodeExpression
- R
class CodeExpression
- Rust
struct CodeExpression
Source
This documentation was generated from CodeExpression.schema.yaml.