Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: TypeError: _model_summary_file.<locals>.<lambda>() got an unexpected keyword argument 'line_break' #59

Closed
joshuaeh opened this issue Oct 26, 2023 · 3 comments · Fixed by #61
Assignees
Labels
bug Something isn't working

Comments

@joshuaeh
Copy link

Describe the bug

Keras provides a key-word argument line_break to the provided print_fn when outputting the model summary which neptune does not currently handle

Reproduction

When keras is given a print_fn, print_summary() will provide a key-word argument line_break
see here. The lambda function created in neptune only handles a single positional argument:
Neptune Code Here

I have handled this by modifying the lambda function locally:
model.summary(print_fn=lambda x: stream.write(x + '\n')) -> model.summary(print_fn=lambda x, **kwargs: stream.write(x + '\n'))

Expected behavior

StreamIO object to capture the model summary

Traceback

{
	"name": "TypeError",
	"message": "_model_summary_file.<locals>.<lambda>() got an unexpected keyword argument 'line_break'",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/anaconda3/envs/env/lib/python3.11/site-packages/keras_core/src/utils/traceback_utils.py:123, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    120     filtered_tb = _process_traceback_frames(e.__traceback__)
    121     # To get the full stack trace, call:
    122     # `keras_core.config.disable_traceback_filtering()`
--> 123     raise e.with_traceback(filtered_tb) from None
    124 finally:
    125     del filtered_tb

File ~/anaconda3/envs/env/lib/python3.11/site-packages/neptune_tensorflow_keras/impl/__init__.py:157, in NeptuneCallback.on_train_end(self, logs)
    154 def on_train_end(self, logs=None):
    155     # We need this to be logged at the end of the training, otherwise we are risking this to happen:
    156     # https://stackoverflow.com/q/55908188/3986320
--> 157     self._model_logger[\"summary\"] = _model_summary_file(self.model)
    159     if self._log_model_diagram:
    160         self._model_logger[\"visualization\"] = _model_diagram(self.model)

File ~/anaconda3/envs/env/lib/python3.11/site-packages/neptune_tensorflow_keras/impl/__init__.py:182, in _model_summary_file(model)
    180 def _model_summary_file(model) -> File:
    181     stream = io.StringIO()
--> 182     model.summary(print_fn=lambda x: stream.write(x + \"\
\"))
    183     return File.from_stream(stream, extension=\"txt\")

TypeError: _model_summary_file.<locals>.<lambda>() got an unexpected keyword argument 'line_break'"
}

Environment

The output of pip list:

absl-py==1.4.0
anyio==4.0.0
appnope @ file:///home/conda/feedstock_root/build_artifacts/appnope_1649077682618/work
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1694046349000/work
astunparse==1.6.3
async-lru==2.0.4
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1683424013410/work
Babel==2.12.1
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1687772187254/work
beautifulsoup4==4.12.2
bleach==6.0.0
blosc2==2.0.0
boto3==1.28.70
botocore==1.31.70
bravado==11.0.3
bravado-core==6.1.0
Brotli @ file:///Users/runner/miniforge3/conda-bld/brotli-split_1693583518054/work
cachetools==5.3.1
Cartopy @ file:///Users/runner/miniforge3/conda-bld/cartopy_1691614952056/work
certifi==2023.7.22
cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1671179421243/work
cfgrib @ file:///home/conda/feedstock_root/build_artifacts/cfgrib_1684493284302/work
cftime==1.6.2
chardet==4.0.0
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1688813409104/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1692311806742/work
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1691044910542/work
contourpy @ file:///Users/runner/miniforge3/conda-bld/contourpy_1686733899847/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work
Cython==3.0.2
debugpy @ file:///private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_563_nwtkoc/croot/debugpy_1690905063850/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work
defusedxml==0.7.1
dm-tree==0.1.8
eccodes @ file:///Users/runner/miniforge3/conda-bld/python-eccodes_1675177455229/work
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1692026125334/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1667317341051/work
fastjsonschema==2.18.0
filelock==3.12.3
findlibs @ file:///home/conda/feedstock_root/build_artifacts/findlibs_1682423883580/work
flatbuffers==23.5.26
fonttools @ file:///Users/runner/miniforge3/conda-bld/fonttools_1692542667314/work
fqdn==1.5.1
future==0.18.3
gast==0.5.4
gitdb==4.0.11
GitPython==3.1.40
google-auth==2.23.3
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
grpcio==1.59.0
h5py==3.9.0
h5pyd==0.16.0
herbie-data @ file:///home/conda/feedstock_root/build_artifacts/herbie-data_1690475423999/work
idna==2.10
importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1688754491823/work
importlib-resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1691408075105/work
ipykernel @ file:///Users/runner/miniforge3/conda-bld/ipykernel_1693880377119/work
ipython @ file:///Users/runner/miniforge3/conda-bld/ipython_1693580003080/work
ipython-genutils==0.2.0
ipywidgets==8.1.0
isoduration==20.11.0
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1690896916983/work
Jinja2==3.1.2
jmespath==1.0.1
joblib==1.3.2
json5==0.9.14
jsonpointer==2.4
jsonref==1.1.0
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-events==0.7.0
jupyter-lsp==2.2.0
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1693317508789/work
jupyter_core @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/abs_d1sy1hlz9t/croot/jupyter_core_1679906585151/work
jupyter_server==2.7.3
jupyter_server_terminals==0.4.4
jupyterlab==4.0.5
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.8
jupyterlab_server==2.25.0
keras==2.14.0
keras-core==0.1.5
kiwisolver @ file:///Users/runner/miniforge3/conda-bld/kiwisolver_1692883648061/work
libclang==16.0.6
Markdown==3.5
markdown-it-py==3.0.0
MarkupSafe==2.1.3
matplotlib @ file:///Users/runner/miniforge3/conda-bld/matplotlib-suite_1678135673869/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1660814786464/work
mdurl==0.1.2
MetPy @ file:///home/conda/feedstock_root/build_artifacts/metpy_1688757851203/work
mistune==3.0.1
ml-dtypes==0.2.0
monotonic==1.6
mpmath==1.3.0
msgpack==1.0.5
munkres==1.1.4
namex==0.0.7
nbclient==0.8.0
nbconvert==7.8.0
nbformat==5.9.2
neptune==1.8.2
neptune-tensorflow-keras==2.2.0
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1664684991461/work
netCDF4==1.6.4
networkx==3.1
notebook==7.0.3
notebook_shim==0.2.3
numexpr @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/abs_76yyu1p9jk/croot/numexpr_1683221830860/work
numpy==1.25.2
oauthlib==3.2.2
opt-einsum==3.3.0
overrides==7.4.0
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1681337016113/work
pandas @ file:///Users/runner/miniforge3/conda-bld/pandas_1693415278066/work
pandocfilters==1.5.0
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work
patsy==0.5.3
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1667297516076/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow @ file:///Users/runner/miniforge3/conda-bld/pillow_1675487336340/work
Pint @ file:///home/conda/feedstock_root/build_artifacts/pint_1686171160673/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1690813113769/work
plotly==5.16.1
pooch @ file:///home/conda/feedstock_root/build_artifacts/pooch_1679580333621/work
prometheus-client==0.17.1
prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1688565951714/work
protobuf==4.24.4
psutil @ file:///Users/cbousseau/work/recipes/ci_py311_2/psutil_1678995687212/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work
pvlib==0.10.1
py-cpuinfo @ file:///Users/ktietz/demo/mc3/conda-bld/py-cpuinfo_1629480366017/work
pyarrow==13.0.0
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
pydot==1.4.2
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1691408637400/work
pygrib @ file:///Users/runner/miniforge3/conda-bld/pygrib_1667011360938/work
PyJWT==2.8.0
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1690737849915/work
pyproj @ file:///Users/runner/miniforge3/conda-bld/pyproj_1686688586795/work
pyshp @ file:///home/conda/feedstock_root/build_artifacts/pyshp_1659002966020/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
python-json-logger==2.0.7
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1693930252784/work
PyYAML==6.0.1
pyzmq @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/abs_23n9bfwjq5/croot/pyzmq_1686601381911/work
qtconsole==5.4.4
QtPy==2.4.0
referencing==0.30.2
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1684774241324/work
requests-oauthlib==1.3.1
requests-unixsocket==0.3.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rfc3987==1.3.8
rich==13.5.2
rpds-py==0.10.2
rsa==4.9
s3transfer==0.7.0
scikit-learn==1.3.1
scipy==1.11.2
seaborn==0.12.2
Send2Trash==1.8.2
shapely @ file:///Users/runner/miniforge3/conda-bld/shapely_1692436479071/work
simplejson==3.19.2
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
smmap==5.0.1
sniffio==1.3.0
solarforecastarbiter==1.0.13
soupsieve==2.5
stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1669632077133/work
statsmodels==0.14.0
swagger-spec-validator==3.0.3
sympy==1.12
tables @ file:///private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_81qnps6056/croot/pytables_1691621471831/work
tenacity==8.2.3
tensorboard==2.14.1
tensorboard-data-server==0.7.1
tensorflow==2.14.0
tensorflow-estimator==2.14.0
tensorflow-io-gcs-filesystem==0.34.0
tensorflow-macos==2.14.0
termcolor==2.3.0
terminado==0.17.1
threadpoolctl==3.2.0
tinycss2==1.2.1
toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1604308577558/work
torch==2.0.1
tornado @ file:///private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_28d93aezp2/croot/tornado_1690848278715/work
tqdm==4.66.1
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1675110562325/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1688315532570/work
tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1680081134351/work
uri-template==1.3.0
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1689789803562/work
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1673864653149/work
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.3
Werkzeug==3.0.0
widgetsnbextension==4.0.8
wrapt==1.14.1
xarray @ file:///home/conda/feedstock_root/build_artifacts/xarray_1692570435082/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1689374466814/work

The operating system you're using:
MacOS 14.0
The output of python --version:
Python 3.11

Additional context

Using keras_core to use torch backend rather than tensorflow

@SiddhantSadangi SiddhantSadangi self-assigned this Oct 27, 2023
@SiddhantSadangi
Copy link
Member

Hey @joshuaeh 👋

Thanks for reporting this issue.

Could you also share a minimal code example that we can use to reproduce this error?

@SiddhantSadangi SiddhantSadangi added the pending Waiting for a response label Oct 27, 2023
@SiddhantSadangi
Copy link
Member

Hey @joshuaeh ,
I am closing this issue as stale, but please feel free to reopen if you still need help with this.

@SiddhantSadangi SiddhantSadangi closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
@SiddhantSadangi SiddhantSadangi added stale and removed pending Waiting for a response labels Dec 5, 2023
@SiddhantSadangi SiddhantSadangi added the bug Something isn't working label Mar 13, 2024
@SiddhantSadangi
Copy link
Member

Fixed in neptune-tensorflow-keras==2.2.2 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants