StartExternalSession
Listing of External Evaluators »StartExternalSession["sys"]
starts an external session using the external evaluator sys, returning an external session object.
StartExternalSession[assoc]
starts the external evaluator specified by assoc.
StartExternalSession[{"sys",opts}]
uses the options opts for the external evaluator.
StartExternalSession[systype]
specifies that output from the external evaluator should be converted to the specified type.
StartExternalSession[DatabaseReference[ref]]
uses the database specified by ref to start a database session.
Details
- StartExternalSession starts an external process that can be used to implement an external evaluator session in which there are multiple evaluations requested by ExternalEvaluate.
- In StartExternalSession[assoc], elements of the association can include:
-
"System" the external system or language to start "Evaluator" the specific evaluator to execute code "Name" the registered name of an evaluator "ID" a unique identifier "ReturnType" type of object to return ("String", "Expression", ...) "Prolog" code to run before the command "Epilog" code to run after the command "SessionProlog" code to run before the session "SessionEpilog" code to run after the session - "System" is the only required key; all others are optional.
- In StartExternalSession[sys], possible choices of sys include:
-
"Python" Python "NodeJS" JavaScript running through Node.js "Julia" Julia "Ruby" Ruby "R" R "Shell" Bash, Sh, Zsh, ... "Jupyter" Jupyter kernel "SQL" SQL database "SQL-JDBC" SQL database using JDBC - Possible settings for "type" in StartExternalSession[sys"type",…], or for "ReturnType", are dependent on the evaluation system, and typically include:
-
"Expression" attempt to convert to a Wolfram Language expression "String" give the raw string output by the external evaluator - The possible settings for evaluator in StartExternalSession[{sys,"Evaluator"evaluator},…] depend on sys, and include:
-
"path" path to a language executable DatabaseReference[…] an SQL database connection SQLConnection[…] an SQL-JDBC database connection - Typically, StartExternalSession uses the setting "ReturnType""Expression".
- StartExternalSession[{"sys",opts}] is equivalent to StartExternalSession[<"System""sys",opts >].
- StartExternalSession[{sys,"ID""id",…}] either returns an already running session with the given "id" or starts a new session with the unique "id".
- FindExternalEvaluators gives a dataset of evaluator systems that can be used.
- ExternalSessions gives a list of active external sessions.
- DeleteObject[ExternalSessionObject[…]] kills and removes an external session started by StartExternalSession.
Examples
open allclose allBasic Examples (3)
Start an external Python session, automatically discovering any usable installations:
Stop the session with DeleteObject:
Start a session using Python Version 3:
Start a new Python session in a provisioned environment:
Scope (16)
Basic Uses (2)
Multiple external sessions can be run simultaneously:
Start an external Python session using the executable in /usr/bin/python3:
Use the session for multiple calls to ExternalEvaluate:
Stop the session with DeleteObject:
Session Options (14)
"ReturnType" (4)
For most systems, the default return type is "Expression":
Numbers, strings, lists and associations are automatically imported for the "Expression" return type:
The return type of "String" returns a string of the result in the external language:
When using a database, the default return type is "Dataset":
"ReturnType" can be used to return data in a different form:
"Evaluator" (3)
Evaluate code using a specified "Evaluator":
An Association can be used to start a Python provisioned environment:
Use the session to evaluate the code:
When using a File with the "SQL" evaluator, the target can be a path to an SQLite file or a DatabaseReference specification:
"Name" (1)
"ID" (1)
Start an evaluator with a given "ID":
The operation is idempotent; starting a session with the same "ID" will return the same running session:
You can check that there is only one running session, even if you run StartExternalSession two times:
"SessionProlog" (2)
"SessionEpilog" (1)
"Prolog" (1)
Properties & Relations (4)
Each session runs in its own process:
The process IDs for each session are different:
If only the language is specified, the first evaluator returned by FindExternalEvaluators is used:
External language cells implicitly call StartExternalSession:
A new session has been started:
By default, all cells of a given system use that session:
End the session so that subsequent evaluations start in a new session:
Text
Wolfram Research (2017), StartExternalSession, Wolfram Language function, https://reference.wolfram.com/language/ref/StartExternalSession.html (updated 2024).
CMS
Wolfram Language. 2017. "StartExternalSession." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/StartExternalSession.html.
APA
Wolfram Language. (2017). StartExternalSession. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StartExternalSession.html