Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kreneskyp committed Feb 24, 2024
1 parent 74fb223 commit 46b1b04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ix/skills/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
label="Halt on error",
type="boolean",
description="Halt on error by raising exception",
default = False,
)
default=False,
),
],
)

Expand Down
17 changes: 9 additions & 8 deletions ix/skills/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import json
import os
import subprocess
import sys
import textwrap
import traceback
from typing import Dict, Any, Optional

from langchain_experimental.utilities import PythonREPL
Expand Down Expand Up @@ -103,28 +105,23 @@ def parse_skill(
return func_name, input_schema, description



class ErrorResponse(BaseModel):
message: str
traceback: str
line: int


import traceback
import sys

def execute_function(function, raise_errors: bool = False):
try:
result = function()
return result
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = exc_tb.tb_frame.f_code.co_filename
line_number = exc_tb.tb_lineno
error_response = ErrorResponse(
message=str(e),
traceback=''.join(traceback.format_tb(exc_tb)),
line=line_number
traceback="".join(traceback.format_tb(exc_tb)),
line=line_number,
)
if raise_errors:
raise e
Expand All @@ -133,7 +130,11 @@ def execute_function(function, raise_errors: bool = False):


def run_code_with_repl(
code: str, function: str, input: Dict[str, Any], timeout: Optional[int] = None, raise_errors: bool = False
code: str,
function: str,
input: Dict[str, Any],
timeout: Optional[int] = None,
raise_errors: bool = False,
) -> Any:
# HAX: use globals for I/O with the REPL. Hacky way to avoid serialization.
func_output = []
Expand Down

0 comments on commit 46b1b04

Please sign in to comment.