Open
Description
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
-
Direct variable transfer methods:
repl.set_variables({'df': df}) # Send variables to sandbox repl.get_variables(['result_df']) # Retrieve variables from sandbox
-
File-based transfer for larger objects:
# Host df.to_parquet('temp.parquet') repl.exec('df = pd.read_parquet("temp.parquet")')
-
Network-based transfer protocol
Questions
- 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
Labels
No labels