Skip to content

Commit

Permalink
lambda: Fix bug for using lambdas in jupyter notebook (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-nambiar authored Sep 18, 2024
1 parent 1d8778d commit a2cf1d0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions fennel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [1.5.23] - 2024-09-17
- Fix bug for using lambdas in jupyter notebooks

## [1.5.22] - 2024-09-12
- Add casting to pyarrow for using expression in assign.

Expand Down
18 changes: 14 additions & 4 deletions fennel/internal_lib/to_proto/source_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,20 @@ def check_ambiguous_lambda(
"""
# Get the next line and append to lambda text
next_line = ""
with open(lambda_func.__code__.co_filename, "r") as f:
lines = f.readlines()
if line_num < len(lines):
next_line = lines[line_num].strip()
try:
with open(lambda_func.__code__.co_filename, "r") as f:
lines = f.readlines()
if line_num < len(lines):
next_line = lines[line_num].strip()
except Exception:
# In jupyter notebook, we don't have co_filename available.
# So we are using fennel_get_source to get the source code and try to find the next line.
# This is not perfect, and might not work for all cases.
src_code = fennel_get_source(lambda_func)
num_lines = src_code.count("\n")
if num_lines <= 1:
return
next_line = src_code.split("\n")[1]

# No Next line found
if next_line == "":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fennel-ai"
version = "1.5.22"
version = "1.5.23"
description = "The modern realtime feature engineering platform"
authors = ["Fennel AI <[email protected]>"]
packages = [{ include = "fennel" }]
Expand Down

0 comments on commit a2cf1d0

Please sign in to comment.