Skip to content

Commit

Permalink
feat(Executable nodes): Add properties summarising dependencies and e…
Browse files Browse the repository at this point in the history
…xecution
  • Loading branch information
nokome committed Jan 12, 2022
1 parent e61e979 commit 2cec08b
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 3 deletions.
32 changes: 32 additions & 0 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"])

EExecuteRequired = Enum("ExecuteRequired", ["No", "NeverExecuted", "SemanticsChanged", "DependenciesChanged"])

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

EClaimType = Enum("ClaimType", ["Statement", "Theorem", "Lemma", "Proof", "Postulate", "Hypothesis", "Proposition", "Corollary"])
Expand Down Expand Up @@ -215,6 +217,12 @@ class CodeExecutable(Code):
programmingLanguage: String # type: ignore
"""The programming language of the code."""

codeDependencies: Optional[Array[Union["CodeChunk", "CodeExpression", "Parameter"]]] = None
"""The upstream dependencies of the code."""

codeDependents: Optional[Array[Union["CodeChunk", "CodeExpression"]]] = None
"""The downstream dependents of the code."""

compileDigest: Optional[String] = None
"""A digest of the content, semantics and dependencies of the node."""

Expand All @@ -230,6 +238,9 @@ class CodeExecutable(Code):
executeEnded: Optional["Date"] = None
"""The date-time that the the last execution of the code ended."""

executeRequired: Optional["EExecuteRequired"] = None
"""Whether, and why, a node requires execution or re-execution."""

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

Expand All @@ -238,11 +249,14 @@ def __init__(
self,
programmingLanguage: String,
text: String,
codeDependencies: Optional[Array[Union["CodeChunk", "CodeExpression", "Parameter"]]] = None,
codeDependents: Optional[Array[Union["CodeChunk", "CodeExpression"]]] = None,
compileDigest: Optional[String] = None,
errors: Optional[Array["CodeError"]] = None,
executeDigest: Optional[String] = None,
executeDuration: Optional[Number] = None,
executeEnded: Optional["Date"] = None,
executeRequired: Optional["EExecuteRequired"] = None,
executeStatus: Optional["EExecuteStatus"] = None,
id: Optional[String] = None,
mediaType: Optional[String] = None,
Expand All @@ -257,6 +271,10 @@ def __init__(
)
if programmingLanguage is not None:
self.programmingLanguage = programmingLanguage
if codeDependencies is not None:
self.codeDependencies = codeDependencies
if codeDependents is not None:
self.codeDependents = codeDependents
if compileDigest is not None:
self.compileDigest = compileDigest
if errors is not None:
Expand All @@ -267,6 +285,8 @@ def __init__(
self.executeDuration = executeDuration
if executeEnded is not None:
self.executeEnded = executeEnded
if executeRequired is not None:
self.executeRequired = executeRequired
if executeStatus is not None:
self.executeStatus = executeStatus

Expand All @@ -292,11 +312,14 @@ def __init__(
programmingLanguage: String,
text: String,
caption: Optional[Union[Array["BlockContent"], String]] = None,
codeDependencies: Optional[Array[Union["CodeChunk", "CodeExpression", "Parameter"]]] = None,
codeDependents: Optional[Array[Union["CodeChunk", "CodeExpression"]]] = None,
compileDigest: Optional[String] = None,
errors: Optional[Array["CodeError"]] = None,
executeDigest: Optional[String] = None,
executeDuration: Optional[Number] = None,
executeEnded: Optional["Date"] = None,
executeRequired: Optional["EExecuteRequired"] = None,
executeStatus: Optional["EExecuteStatus"] = None,
id: Optional[String] = None,
label: Optional[String] = None,
Expand All @@ -307,11 +330,14 @@ def __init__(
super().__init__(
programmingLanguage=programmingLanguage,
text=text,
codeDependencies=codeDependencies,
codeDependents=codeDependents,
compileDigest=compileDigest,
errors=errors,
executeDigest=executeDigest,
executeDuration=executeDuration,
executeEnded=executeEnded,
executeRequired=executeRequired,
executeStatus=executeStatus,
id=id,
mediaType=mediaType,
Expand Down Expand Up @@ -341,11 +367,14 @@ def __init__(
self,
programmingLanguage: String,
text: String,
codeDependencies: Optional[Array[Union["CodeChunk", "CodeExpression", "Parameter"]]] = None,
codeDependents: Optional[Array[Union["CodeChunk", "CodeExpression"]]] = None,
compileDigest: Optional[String] = None,
errors: Optional[Array["CodeError"]] = None,
executeDigest: Optional[String] = None,
executeDuration: Optional[Number] = None,
executeEnded: Optional["Date"] = None,
executeRequired: Optional["EExecuteRequired"] = None,
executeStatus: Optional["EExecuteStatus"] = None,
id: Optional[String] = None,
mediaType: Optional[String] = None,
Expand All @@ -355,11 +384,14 @@ def __init__(
super().__init__(
programmingLanguage=programmingLanguage,
text=text,
codeDependencies=codeDependencies,
codeDependents=codeDependents,
compileDigest=compileDigest,
errors=errors,
executeDigest=executeDigest,
executeDuration=executeDuration,
executeEnded=executeEnded,
executeRequired=executeRequired,
executeStatus=executeStatus,
id=id,
mediaType=mediaType,
Expand Down
27 changes: 27 additions & 0 deletions r/R/types.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,14 @@ CodeBlock <- function(
#' @name CodeExecutable
#' @param programmingLanguage The programming language of the code. \bold{Required}.
#' @param text The text of the code. \bold{Required}.
#' @param codeDependencies The upstream dependencies of the code.
#' @param codeDependents The downstream dependents 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 `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 executeRequired Whether, and why, a node requires execution or re-execution.
#' @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.
Expand All @@ -182,11 +185,14 @@ CodeBlock <- function(
CodeExecutable <- function(
programmingLanguage,
text,
codeDependencies,
codeDependents,
compileDigest,
errors,
executeDigest,
executeDuration,
executeEnded,
executeRequired,
executeStatus,
id,
mediaType,
Expand All @@ -201,11 +207,14 @@ CodeExecutable <- function(
)
self$type <- as_scalar("CodeExecutable")
self[["programmingLanguage"]] <- check_property("CodeExecutable", "programmingLanguage", TRUE, missing(programmingLanguage), "character", programmingLanguage)
self[["codeDependencies"]] <- check_property("CodeExecutable", "codeDependencies", FALSE, missing(codeDependencies), Array(Union(CodeChunk, CodeExpression, Parameter)), codeDependencies)
self[["codeDependents"]] <- check_property("CodeExecutable", "codeDependents", FALSE, missing(codeDependents), Array(Union(CodeChunk, CodeExpression)), codeDependents)
self[["compileDigest"]] <- check_property("CodeExecutable", "compileDigest", FALSE, missing(compileDigest), "character", compileDigest)
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[["executeRequired"]] <- check_property("CodeExecutable", "executeRequired", FALSE, missing(executeRequired), Enum("No", "NeverExecuted", "SemanticsChanged", "DependenciesChanged"), executeRequired)
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 @@ -218,11 +227,14 @@ 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 codeDependencies The upstream dependencies of the code.
#' @param codeDependents The downstream dependents 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 `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 executeRequired Whether, and why, a node requires execution or re-execution.
#' @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.
Expand Down Expand Up @@ -256,11 +268,14 @@ CodeChunk <- function(
programmingLanguage,
text,
caption,
codeDependencies,
codeDependents,
compileDigest,
errors,
executeDigest,
executeDuration,
executeEnded,
executeRequired,
executeStatus,
id,
label,
Expand All @@ -271,11 +286,14 @@ CodeChunk <- function(
self <- CodeExecutable(
programmingLanguage = programmingLanguage,
text = text,
codeDependencies = codeDependencies,
codeDependents = codeDependents,
compileDigest = compileDigest,
errors = errors,
executeDigest = executeDigest,
executeDuration = executeDuration,
executeEnded = executeEnded,
executeRequired = executeRequired,
executeStatus = executeStatus,
id = id,
mediaType = mediaType,
Expand All @@ -296,11 +314,14 @@ CodeChunk <- function(
#' @name CodeExpression
#' @param programmingLanguage The programming language of the code. \bold{Required}.
#' @param text The text of the code. \bold{Required}.
#' @param codeDependencies The upstream dependencies of the code.
#' @param codeDependents The downstream dependents 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 `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 executeRequired Whether, and why, a node requires execution or re-execution.
#' @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.
Expand All @@ -312,11 +333,14 @@ CodeChunk <- function(
CodeExpression <- function(
programmingLanguage,
text,
codeDependencies,
codeDependents,
compileDigest,
errors,
executeDigest,
executeDuration,
executeEnded,
executeRequired,
executeStatus,
id,
mediaType,
Expand All @@ -326,11 +350,14 @@ CodeExpression <- function(
self <- CodeExecutable(
programmingLanguage = programmingLanguage,
text = text,
codeDependencies = codeDependencies,
codeDependents = codeDependents,
compileDigest = compileDigest,
errors = errors,
executeDigest = executeDigest,
executeDuration = executeDuration,
executeEnded = executeEnded,
executeRequired = executeRequired,
executeStatus = executeStatus,
id = id,
mediaType = mediaType,
Expand Down
Loading

0 comments on commit 2cec08b

Please sign in to comment.