Tachi67 commited on
Commit
b658ad5
·
1 Parent(s): 03af161

Update InterpreterAtomicFlow.py

Browse files
Files changed (1) hide show
  1. InterpreterAtomicFlow.py +9 -6
InterpreterAtomicFlow.py CHANGED
@@ -45,17 +45,19 @@ class InterpreterAtomicFlow(AtomicFlow):
45
  self.flow_state["language"] = language
46
  self.flow_state["code"] = code
47
 
48
- def _process_input_data(self, input_data: Dict[str, Any]):
49
  """
50
- sanity check for input, allocate interpreter if any,
51
- pass input data into flow state
52
-
53
- should call something like self._update_flow_state()
54
  """
55
- # ~~~ Sanity check of input_data ~~~
56
  assert "language" in input_data, "attribute 'language' not in input data."
57
  assert "code" in input_data, "attribute 'code' not in input data."
58
 
 
 
 
 
 
59
  # code in Jupyter notebook that starts with '!' is actually shell command.
60
  if input_data["language"] == "python" and input_data["code"].startswith("!"):
61
  input_data["language"] = "shell"
@@ -93,6 +95,7 @@ class InterpreterAtomicFlow(AtomicFlow):
93
  def run(
94
  self,
95
  input_data: Dict[str, Any]):
 
96
  self._process_input_data(input_data)
97
  response = self._call()
98
  return {"interpreter_output": response}
 
45
  self.flow_state["language"] = language
46
  self.flow_state["code"] = code
47
 
48
+ def _check_input(self, input_data: Dict[str, Any]):
49
  """
50
+ Sanity check of input data
 
 
 
51
  """
52
+ # ~~~ Sanity check of input_data ~~~
53
  assert "language" in input_data, "attribute 'language' not in input data."
54
  assert "code" in input_data, "attribute 'code' not in input data."
55
 
56
+
57
+ def _process_input_data(self, input_data: Dict[str, Any]):
58
+ """
59
+ Allocate interpreter if any, pass input data into flow state
60
+ """
61
  # code in Jupyter notebook that starts with '!' is actually shell command.
62
  if input_data["language"] == "python" and input_data["code"].startswith("!"):
63
  input_data["language"] = "shell"
 
95
  def run(
96
  self,
97
  input_data: Dict[str, Any]):
98
+ self._check_input(input_data)
99
  self._process_input_data(input_data)
100
  response = self._call()
101
  return {"interpreter_output": response}