Skip to content

Question/Feature Request: Exploring ways to pass variables between host and sandbox environment #6

Open
@amn-max

Description

@amn-max

Description
I'm trying to understand if there's a way to pass variables, especially pandas DataFrames, from the host environment to the sandboxed container when using PythonContainerREPL. If this isn't currently possible, it would be a valuable feature to have.

Use Case Example

# Host environment
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c']})

# Need to use this DataFrame in sandbox
repl = PythonContainerREPL(port=7121)
# Ideally something like:
repl.exec(code, context={'df': df})  # Currently not possible?

Current Challenges

  • Need to pass initial state/context from host environment
  • Share DataFrames and other variables between host and sandbox
  • Maintain compatibility with existing code that relies on shared state

Potential Solution Ideas

  1. Direct variable transfer methods:

    repl.set_variables({'df': df})  # Send variables to sandbox
    repl.get_variables(['result_df'])  # Retrieve variables from sandbox
  2. File-based transfer for larger objects:

    # Host
    df.to_parquet('temp.parquet')
    repl.exec('df = pd.read_parquet("temp.parquet")')
  3. Network-based transfer protocol

Questions

  1. Is there currently any way to achieve this or any workarounds being used?

Would appreciate any insights or guidance on this topic!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions