Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions forloop_modules/function_handlers/variable_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ def direct_execute(self, variable_name):
def input_execute(self, inp):
var_name = inp("variable_name")
var_obj = variable_handler.variables.get(var_name)

if var_obj is not None:
#message = f'PrintVariable: {var_name} = {var_obj.value}' ##Optional Variable printing format
message = f'{var_obj.value}'
Expand All @@ -1211,7 +1211,6 @@ def input_execute(self, inp):
# message = f'PrintVariable: {var_name}' ##Optional Variable printing format
message = f'{var_name}'


# Send to FastAPI backend
try:
ncrb.post_console_log(message=message, type="print")
Expand All @@ -1228,16 +1227,36 @@ def execute(self, node_detail_form):

self.direct_execute(variable_name)

def export_code(self, *args):
"""TODO"""
code = """ """

def export_code(self, node_detail_form):
"""
Export Python code for print statement.
"""
variable_name = node_detail_form.get_chosen_value_by_name("variable_name", variable_handler)
code = f"print({variable_name})"
return code

def make_flpl_node_dict(self, line_dict: dict) -> dict:
"""
Custom method to properly handle print statements.
Maps the first argument to variable_name parameter.
"""
node_dict = {"type": self.icon_type, "params": {}}

# Get the first argument (what to print)
arguments = line_dict.get("arguments", [])
first_arg = arguments[0] if arguments else ""

# Set the variable_name parameter
node_dict["params"]["variable_name"] = {"variable": None, "value": first_arg}

return node_dict

def export_imports(self, *args):
"""TODO"""
"""
Export imports needed for print functionality.
Print is a built-in Python function, so no imports are needed.
"""
imports = []

return imports


Expand Down
16 changes: 16 additions & 0 deletions forloop_modules/queries/node_context_requests_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,22 @@ def get_user_logs() -> Response:
response = http_client.get(url)
return response

############### In app Console logs ###############
def post_console_log(message: str, type: str = "print"):

payload = {
"message": message,
"project_uid": aet.project_uid,
"type": type
}

url = f"{BASE_API}/console_logs"
return http_client.post(url, json=payload)

def get_console_logs() -> Response:
url = f"{BASE_API}/console_logs"
response = http_client.get(url)
return response

############### In app Console logs ###############

Expand Down