C3 AI Documentation Home

Define Runtime for Action Requirements

A runtime provides flexibility in a C3 AI Type method, and helps in determining the list of the required libraries/modules and dependencies, as well as the languages, environment, and other contexts in which the application logic can run.

When defining an Action.Requirement Type, a runtime can be specified as one of the requirements for running the Action. This topic explains and provides examples of how runtimes are defined and run within the context of an Action.Requirement.

Define Action.Requirement to run Actions

An instance of a Action.Requirement Type represents the minimum requirements you need to set to run an action or method. This allows you to specify how you want a method or action to be run.

Four components are specified as part of the requirements:

NOTE: Only language is required.

  • Language: Python, JavaScript, Java
  • Runtime
  • Location: SERVER or CLIENT; see also ImplLanguage.RuntimeLocation.
  • Executor: JEP, PY4J, IPYTHON, or NODE

See the following example for py-data-science-server in which:

  • Language = Python, which is denoted by py
  • Runtime = py-data-science
  • Location = server
  • Executor = None, as no executor is specified
Type
type Automobile {
    drive: member function(): string py-data-science-server
}

As such, the method drive is executed server side using a runtime that runs a superset of py-data-science Python libraries. Since the executor is not defined explicitly, the C3 AI Type System uses the best executor to run this action, which is determined by the state of the server and whether the actions require tasks to be run locally or remotely. The only exception is a Java implementation of the method. See Action.Engine.Java for more information.

See also ImplLanguage.Executor and ActionExecutor.

Example 1 of an Action.Requirement Type definition

See the following example of an Action.Requirement Type definition, in which only the language is defined (as denoted by py).

Type
type Automobile {
    park : member function(): string py
}

Since the location, executor, or runtime were not defined explicitly, the C3 AI Type System logic runs the best option for each by default.

Example 2 of an Action.Requirement Type definition

See the following example of an Action.Requirement Type definition, in which most parameters except location are defined.

Type
type Automobile {
    checkEngine : member function(): string py-data-science-py4j
}

In the above example, the following parameters are defined:

  • Language = Python, which is denoted by the py
  • Runtime = py-data-science
  • Location = None
  • Executor = PY4J, which is denoted by the py4j

In this example of the checkEngine action method, the action is run using the PY4J executor and a runtime that runs a super set of the py-data-science Python libraries. Despite not specifying location explicitly, because PY4J is an executor for server-side Python, the action method is run through server as the location.

While a claim like py-data-science-server-py4j would indicate the same thing as py-data-science-py4j, the location is considered redundant in this instance.

NOTE: The claim py-data-science-client-py4j would result in a metadata error because of the implied logic around PY4J as an executor for server-side Python.

Was this page helpful?