Class PythonDeephavenSession

java.lang.Object
io.deephaven.util.referencecounting.ReferenceCounted
io.deephaven.engine.liveness.ReferenceCountedLivenessNode
io.deephaven.engine.liveness.LivenessScope
io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
io.deephaven.integrations.python.PythonDeephavenSession
All Implemented Interfaces:
io.deephaven.base.log.LogOutputAppendable, io.deephaven.engine.liveness.LivenessManager, io.deephaven.engine.liveness.LivenessNode, io.deephaven.engine.liveness.LivenessReferent, io.deephaven.engine.liveness.ReleasableLivenessManager, io.deephaven.engine.util.ScriptSession, io.deephaven.engine.util.VariableProvider, Serializable

public class PythonDeephavenSession extends io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
A ScriptSession that uses a JPy cpython interpreter internally.

This is used for applications or the console; Python code running remotely uses WorkerPythonEnvironment for it's supporting structures.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
     

    Nested classes/interfaces inherited from class io.deephaven.engine.util.AbstractScriptSession

    io.deephaven.engine.util.AbstractScriptSession.ScriptSessionQueryScope, io.deephaven.engine.util.AbstractScriptSession.Snapshot, io.deephaven.engine.util.AbstractScriptSession.SynchronizedScriptSessionQueryScope, io.deephaven.engine.util.AbstractScriptSession.UnsynchronizedScriptSessionQueryScope

    Nested classes/interfaces inherited from interface io.deephaven.engine.util.ScriptSession

    io.deephaven.engine.util.ScriptSession.Changes, io.deephaven.engine.util.ScriptSession.Listener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
     

    Fields inherited from class io.deephaven.engine.util.AbstractScriptSession

    executionContext
  • Constructor Summary

    Constructors
    Constructor
    Description
    PythonDeephavenSession(io.deephaven.engine.updategraph.UpdateGraph updateGraph, io.deephaven.engine.util.PythonScope<?> scope)
    Creates a Python "ScriptSession", for use where we should only be reading from the scope, such as an IPython kernel session.
    PythonDeephavenSession(io.deephaven.engine.updategraph.UpdateGraph updateGraph, io.deephaven.plugin.type.ObjectTypeLookup objectTypeLookup, @Nullable io.deephaven.engine.util.ScriptSession.Listener listener, boolean runInitScripts, io.deephaven.engine.util.PythonEvaluatorJpy pythonEvaluator)
    Create a Python ScriptSession.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected io.deephaven.engine.util.ScriptSession.Changes
     
     
    protected void
    evaluate(String command, String scriptName)
     
    @NotNull Object
     
    <T> T
    getVariable(String name, T defaultValue)
     
     
     
    boolean
     
    io.deephaven.engine.context.QueryScope
     
    void
    onApplicationInitializationBegin(Supplier<io.deephaven.engine.util.scripts.ScriptPathLoader> pathLoader, io.deephaven.engine.util.scripts.ScriptPathLoaderState scriptLoaderState)
     
    void
     
    void
     
    void
    pushScope(org.jpy.PyObject pydict)
     
     
    void
    setScriptPathLoader(Supplier<io.deephaven.engine.util.scripts.ScriptPathLoader> scriptPathLoader, boolean caching)
     
    boolean
    setUseOriginalScriptLoaderState(boolean useOriginal)
     
    void
    setVariable(String name, @Nullable Object newValue)
     
     
     

    Methods inherited from class io.deephaven.engine.util.AbstractScriptSession

    applyDiff, applyVariableChangeToDiff, createScriptCache, destroy, evaluateScript, evaluateScript, getExecutionContext, getTableDefinition, getVariableProvider, getVariableType, observeScopeChanges, publishInitial

    Methods inherited from class io.deephaven.engine.liveness.LivenessScope

    release, transferTo

    Methods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessNode

    dropReference, getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryRetainReference, tryUnmanage, tryUnmanage

    Methods inherited from class io.deephaven.util.referencecounting.ReferenceCounted

    append, decrementReferenceCount, forceReferenceCountToZero, getReferenceCountDebug, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCount

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.deephaven.engine.liveness.LivenessManager

    manage, tryManage

    Methods inherited from interface io.deephaven.engine.liveness.LivenessNode

    tryUnmanage, tryUnmanage, unmanage, unmanage

    Methods inherited from interface io.deephaven.engine.liveness.LivenessReferent

    dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReference

    Methods inherited from interface io.deephaven.engine.liveness.ReleasableLivenessManager

    release

    Methods inherited from interface io.deephaven.engine.util.ScriptSession

    evaluateScript, sanitizeThrowable
  • Field Details

    • SCRIPT_TYPE

      public static String SCRIPT_TYPE
  • Constructor Details

    • PythonDeephavenSession

      public PythonDeephavenSession(io.deephaven.engine.updategraph.UpdateGraph updateGraph, io.deephaven.plugin.type.ObjectTypeLookup objectTypeLookup, @Nullable @Nullable io.deephaven.engine.util.ScriptSession.Listener listener, boolean runInitScripts, io.deephaven.engine.util.PythonEvaluatorJpy pythonEvaluator) throws IOException
      Create a Python ScriptSession.
      Parameters:
      updateGraph - the default update graph to install for the repl
      objectTypeLookup - the object type lookup
      listener - an optional listener that will be notified whenever the query scope changes
      runInitScripts - if init scripts should be executed
      pythonEvaluator -
      Throws:
      IOException - if an IO error occurs running initialization scripts
    • PythonDeephavenSession

      public PythonDeephavenSession(io.deephaven.engine.updategraph.UpdateGraph updateGraph, io.deephaven.engine.util.PythonScope<?> scope)
      Creates a Python "ScriptSession", for use where we should only be reading from the scope, such as an IPython kernel session.
  • Method Details

    • newQueryScope

      @VisibleForTesting public io.deephaven.engine.context.QueryScope newQueryScope()
      Specified by:
      newQueryScope in class io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
    • getVariable

      @NotNull public @NotNull Object getVariable(String name) throws io.deephaven.engine.context.QueryScope.MissingVariableException
      Throws:
      io.deephaven.engine.context.QueryScope.MissingVariableException
    • getVariable

      public <T> T getVariable(String name, T defaultValue)
    • pushScope

      @ScriptApi public void pushScope(org.jpy.PyObject pydict)
    • popScope

      @ScriptApi public void popScope()
    • evaluate

      protected void evaluate(String command, String scriptName)
      Specified by:
      evaluate in class io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
    • getVariables

      public Map<String,Object> getVariables()
    • emptySnapshot

      protected PythonDeephavenSession.PythonSnapshot emptySnapshot()
      Specified by:
      emptySnapshot in class io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
    • takeSnapshot

      protected PythonDeephavenSession.PythonSnapshot takeSnapshot()
      Specified by:
      takeSnapshot in class io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
    • createDiff

      protected io.deephaven.engine.util.ScriptSession.Changes createDiff(PythonDeephavenSession.PythonSnapshot from, PythonDeephavenSession.PythonSnapshot to, RuntimeException e)
      Specified by:
      createDiff in class io.deephaven.engine.util.AbstractScriptSession<PythonDeephavenSession.PythonSnapshot>
    • getVariableNames

      public Set<String> getVariableNames()
    • hasVariableName

      public boolean hasVariableName(String name)
    • setVariable

      public void setVariable(String name, @Nullable @Nullable Object newValue)
    • scriptType

      public String scriptType()
    • onApplicationInitializationBegin

      public void onApplicationInitializationBegin(Supplier<io.deephaven.engine.util.scripts.ScriptPathLoader> pathLoader, io.deephaven.engine.util.scripts.ScriptPathLoaderState scriptLoaderState)
    • onApplicationInitializationEnd

      public void onApplicationInitializationEnd()
    • setScriptPathLoader

      public void setScriptPathLoader(Supplier<io.deephaven.engine.util.scripts.ScriptPathLoader> scriptPathLoader, boolean caching)
    • clearScriptPathLoader

      public void clearScriptPathLoader()
    • setUseOriginalScriptLoaderState

      public boolean setUseOriginalScriptLoaderState(boolean useOriginal)
    • unwrapObject

      public Object unwrapObject(Object object)