Coder Social home page Coder Social logo

add tests for notebooks about langchain HOT 7 CLOSED

hwchase17 avatar hwchase17 commented on June 23, 2024
add tests for notebooks

from langchain.

Comments (7)

ccurme avatar ccurme commented on June 23, 2024

I looked into a couple ways of doing this. Let me know if you had a preferred method in mind.

One is to add a dependency nbmake, which is a pytest plugin that lets you execute notebooks. You can see an implementation here: master...ccurme:langchain:cc/test_notebooks

The pro is that this is a simple solution built for this use-case. You can list all the notebooks you want to test, or use --ignore to exclude certain notebooks.

One con is that the error handling looked cumbersome to me. If you expect a specific error to be raised, for example, you need to add metadata to cells in the notebook JSON, which can get overwritten. I added an example on that branch.

Another option is to use nbclient, which is already included in dependencies. I added an example here: master...ccurme:langchain:cc/test_notebooks_nbclient

This is neat because you can write the tests in python and work with errors programmatically. But it's arguably more complicated than just passing --nbmake to pytest.

Let me know if you have thoughts or if I should open a PR.

from langchain.

hwchase17 avatar hwchase17 commented on June 23, 2024

hmmm adding the metadata is definitely cumbersome. but at the same time... how many notebooks do we have that expect errors?

from langchain.

ccurme avatar ccurme commented on June 23, 2024

It doesn't look like many. My thought is to just to use nbmake and opt-in to including notebooks in the test. So we'd need to maintain a separate list of notebooks to test; we wouldn't discover them. Does this sound good, or is it important to discover notebooks so that we don't need to maintain a list?

from langchain.

hwchase17 avatar hwchase17 commented on June 23, 2024

that sounds perfect!

from langchain.

hwchase17 avatar hwchase17 commented on June 23, 2024

its probably possible to regexs, eg /* for everything in directory?

from langchain.

ccurme avatar ccurme commented on June 23, 2024

We can enumerate directories, we can also go the other way and maintain a list of notebooks we don't test.

from langchain.

dosubot avatar dosubot commented on June 23, 2024

Hi, @hwchase17! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue is about adding tests for notebooks to ensure they are kept up to date. There was a discussion with ccurme where two options were suggested: using nbmake, a pytest plugin, or using nbclient, which is already included in dependencies. The conclusion was to use nbmake and maintain a separate list of notebooks to test. There was also a suggestion to use regex to include all notebooks in a directory.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to LangChain!

from langchain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.