Skip to content

Commit

Permalink
feat(Executable code nodes): Add properties for execution status etc
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Jan 9, 2022
1 parent 3d6e89d commit 9e3de92
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 77 deletions.
46 changes: 34 additions & 12 deletions python/stencila/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

ECitationMode = Enum("CitationMode", ["Parenthetical", "Narrative", "NarrativeAuthor", "NarrativeYear", "normal", "suppressAuthor"])

EExecuteStatus = Enum("ExecuteStatus", ["Scheduled", "Running", "Succeeded", "Failed", "Cancelled"])

EClaimType = Enum("ClaimType", ["Statement", "Theorem", "Lemma", "Proof", "Postulate", "Hypothesis", "Proposition", "Corollary"])

EItemListOrder = Enum("ItemListOrder", ["Ascending", "Descending", "Unordered"])
Expand Down Expand Up @@ -214,26 +216,34 @@ class CodeExecutable(Code):
"""The programming language of the code."""

compileDigest: Optional[String] = None
"""The SHA-256 digest of the `text`, `programmingLanguage` and `mediaType` properties the last time the node was compiled."""

duration: Optional[Number] = None
"""Duration in seconds of the last execution of the code."""
"""A digest of the content, semantics and dependencies of the node."""

errors: Optional[Array["CodeError"]] = None
"""Errors when compiling (e.g. syntax errors) or executing the chunk."""

executeDigest: Optional[String] = None
"""The SHA-256 digest of `compileDigest` and the `executeDigest`s of all dependencies, the last time the node was executed."""
"""The `compileDigest` of the node when it was last executed."""

executeDuration: Optional[Number] = None
"""Duration in seconds of the last execution of the code."""

executeEnded: Optional["Date"] = None
"""The date-time that the the last execution of the code ended."""

executeStatus: Optional["EExecuteStatus"] = None
"""Status of the last execution of the code."""


def __init__(
self,
programmingLanguage: String,
text: String,
compileDigest: Optional[String] = None,
duration: Optional[Number] = None,
errors: Optional[Array["CodeError"]] = None,
executeDigest: Optional[String] = None,
executeDuration: Optional[Number] = None,
executeEnded: Optional["Date"] = None,
executeStatus: Optional["EExecuteStatus"] = None,
id: Optional[String] = None,
mediaType: Optional[String] = None,
meta: Optional[Object] = None
Expand All @@ -249,12 +259,16 @@ def __init__(
self.programmingLanguage = programmingLanguage
if compileDigest is not None:
self.compileDigest = compileDigest
if duration is not None:
self.duration = duration
if errors is not None:
self.errors = errors
if executeDigest is not None:
self.executeDigest = executeDigest
if executeDuration is not None:
self.executeDuration = executeDuration
if executeEnded is not None:
self.executeEnded = executeEnded
if executeStatus is not None:
self.executeStatus = executeStatus


class CodeChunk(CodeExecutable):
Expand All @@ -279,9 +293,11 @@ def __init__(
text: String,
caption: Optional[Union[Array["BlockContent"], String]] = None,
compileDigest: Optional[String] = None,
duration: Optional[Number] = None,
errors: Optional[Array["CodeError"]] = None,
executeDigest: Optional[String] = None,
executeDuration: Optional[Number] = None,
executeEnded: Optional["Date"] = None,
executeStatus: Optional["EExecuteStatus"] = None,
id: Optional[String] = None,
label: Optional[String] = None,
mediaType: Optional[String] = None,
Expand All @@ -292,9 +308,11 @@ def __init__(
programmingLanguage=programmingLanguage,
text=text,
compileDigest=compileDigest,
duration=duration,
errors=errors,
executeDigest=executeDigest,
executeDuration=executeDuration,
executeEnded=executeEnded,
executeStatus=executeStatus,
id=id,
mediaType=mediaType,
meta=meta
Expand Down Expand Up @@ -324,9 +342,11 @@ def __init__(
programmingLanguage: String,
text: String,
compileDigest: Optional[String] = None,
duration: Optional[Number] = None,
errors: Optional[Array["CodeError"]] = None,
executeDigest: Optional[String] = None,
executeDuration: Optional[Number] = None,
executeEnded: Optional["Date"] = None,
executeStatus: Optional["EExecuteStatus"] = None,
id: Optional[String] = None,
mediaType: Optional[String] = None,
meta: Optional[Object] = None,
Expand All @@ -336,9 +356,11 @@ def __init__(
programmingLanguage=programmingLanguage,
text=text,
compileDigest=compileDigest,
duration=duration,
errors=errors,
executeDigest=executeDigest,
executeDuration=executeDuration,
executeEnded=executeEnded,
executeStatus=executeStatus,
id=id,
mediaType=mediaType,
meta=meta
Expand Down
48 changes: 33 additions & 15 deletions r/R/types.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ CodeBlock <- function(
#' @name CodeExecutable
#' @param programmingLanguage The programming language of the code. \bold{Required}.
#' @param text The text of the code. \bold{Required}.
#' @param compileDigest The SHA-256 digest of the `text`, `programmingLanguage` and `mediaType` properties the last time the node was compiled.
#' @param duration Duration in seconds of the last execution of the code.
#' @param compileDigest A digest of the content, semantics and dependencies of the node.
#' @param errors Errors when compiling (e.g. syntax errors) or executing the chunk.
#' @param executeDigest The SHA-256 digest of `compileDigest` and the `executeDigest`s of all dependencies, the last time the node was executed.
#' @param executeDigest The `compileDigest` of the node when it was last executed.
#' @param executeDuration Duration in seconds of the last execution of the code.
#' @param executeEnded The date-time that the the last execution of the code ended.
#' @param executeStatus Status of the last execution of the code.
#' @param id The identifier for this item.
#' @param mediaType Media type, typically expressed using a MIME format, of the code.
#' @param meta Metadata associated with this item.
Expand All @@ -181,9 +183,11 @@ CodeExecutable <- function(
programmingLanguage,
text,
compileDigest,
duration,
errors,
executeDigest,
executeDuration,
executeEnded,
executeStatus,
id,
mediaType,
meta
Expand All @@ -198,9 +202,11 @@ CodeExecutable <- function(
self$type <- as_scalar("CodeExecutable")
self[["programmingLanguage"]] <- check_property("CodeExecutable", "programmingLanguage", TRUE, missing(programmingLanguage), "character", programmingLanguage)
self[["compileDigest"]] <- check_property("CodeExecutable", "compileDigest", FALSE, missing(compileDigest), "character", compileDigest)
self[["duration"]] <- check_property("CodeExecutable", "duration", FALSE, missing(duration), "numeric", duration)
self[["errors"]] <- check_property("CodeExecutable", "errors", FALSE, missing(errors), Array(CodeError), errors)
self[["executeDigest"]] <- check_property("CodeExecutable", "executeDigest", FALSE, missing(executeDigest), "character", executeDigest)
self[["executeDuration"]] <- check_property("CodeExecutable", "executeDuration", FALSE, missing(executeDuration), "numeric", executeDuration)
self[["executeEnded"]] <- check_property("CodeExecutable", "executeEnded", FALSE, missing(executeEnded), Date, executeEnded)
self[["executeStatus"]] <- check_property("CodeExecutable", "executeStatus", FALSE, missing(executeStatus), Enum("Scheduled", "Running", "Succeeded", "Failed", "Cancelled"), executeStatus)
class(self) <- c(class(self), "CodeExecutable")
self
}
Expand All @@ -212,10 +218,12 @@ CodeExecutable <- function(
#' @param programmingLanguage The programming language of the code. \bold{Required}.
#' @param text The text of the code. \bold{Required}.
#' @param caption A caption for the CodeChunk.
#' @param compileDigest The SHA-256 digest of the `text`, `programmingLanguage` and `mediaType` properties the last time the node was compiled.
#' @param duration Duration in seconds of the last execution of the code.
#' @param compileDigest A digest of the content, semantics and dependencies of the node.
#' @param errors Errors when compiling (e.g. syntax errors) or executing the chunk.
#' @param executeDigest The SHA-256 digest of `compileDigest` and the `executeDigest`s of all dependencies, the last time the node was executed.
#' @param executeDigest The `compileDigest` of the node when it was last executed.
#' @param executeDuration Duration in seconds of the last execution of the code.
#' @param executeEnded The date-time that the the last execution of the code ended.
#' @param executeStatus Status of the last execution of the code.
#' @param id The identifier for this item.
#' @param label A short label for the CodeChunk.
#' @param mediaType Media type, typically expressed using a MIME format, of the code.
Expand Down Expand Up @@ -249,9 +257,11 @@ CodeChunk <- function(
text,
caption,
compileDigest,
duration,
errors,
executeDigest,
executeDuration,
executeEnded,
executeStatus,
id,
label,
mediaType,
Expand All @@ -262,9 +272,11 @@ CodeChunk <- function(
programmingLanguage = programmingLanguage,
text = text,
compileDigest = compileDigest,
duration = duration,
errors = errors,
executeDigest = executeDigest,
executeDuration = executeDuration,
executeEnded = executeEnded,
executeStatus = executeStatus,
id = id,
mediaType = mediaType,
meta = meta
Expand All @@ -284,10 +296,12 @@ CodeChunk <- function(
#' @name CodeExpression
#' @param programmingLanguage The programming language of the code. \bold{Required}.
#' @param text The text of the code. \bold{Required}.
#' @param compileDigest The SHA-256 digest of the `text`, `programmingLanguage` and `mediaType` properties the last time the node was compiled.
#' @param duration Duration in seconds of the last execution of the code.
#' @param compileDigest A digest of the content, semantics and dependencies of the node.
#' @param errors Errors when compiling (e.g. syntax errors) or executing the chunk.
#' @param executeDigest The SHA-256 digest of `compileDigest` and the `executeDigest`s of all dependencies, the last time the node was executed.
#' @param executeDigest The `compileDigest` of the node when it was last executed.
#' @param executeDuration Duration in seconds of the last execution of the code.
#' @param executeEnded The date-time that the the last execution of the code ended.
#' @param executeStatus Status of the last execution of the code.
#' @param id The identifier for this item.
#' @param mediaType Media type, typically expressed using a MIME format, of the code.
#' @param meta Metadata associated with this item.
Expand All @@ -299,9 +313,11 @@ CodeExpression <- function(
programmingLanguage,
text,
compileDigest,
duration,
errors,
executeDigest,
executeDuration,
executeEnded,
executeStatus,
id,
mediaType,
meta,
Expand All @@ -311,9 +327,11 @@ CodeExpression <- function(
programmingLanguage = programmingLanguage,
text = text,
compileDigest = compileDigest,
duration = duration,
errors = errors,
executeDigest = executeDigest,
executeDuration = executeDuration,
executeEnded = executeEnded,
executeStatus = executeStatus,
id = id,
mediaType = mediaType,
meta = meta
Expand Down
Loading

0 comments on commit 9e3de92

Please sign in to comment.