diff --git a/README.md b/README.md index 8076655..8a242d4 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ temperatures, etc. See [Langchain's API ref](https://api.python.langchain.com/en Note! This is a confusing use case -- change it to something relevant to your work. ```yaml -task: | +task: | Create a hello world notebook 'x.ipynb', use nbmake's NotebookRun class to test it from a Python application steps: - Create a hello world notebook using nbformat @@ -132,3 +132,6 @@ using Phoenix. ``` 1. In another termianl, run nbwrite with the following var set: `export NBWRITE_PHOENIX_TRACE=1` 1. Check the phoenix traces in the dashboard (default http://127.0.0.1:6060/) + + +## TODO make phoenix optional, fix empty packages bug \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 8572194..f8472e7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -207,7 +207,7 @@ files = [ name = "arize-phoenix" version = "0.0.49" description = "ML Observability in your notebook" -optional = false +optional = true python-versions = "<3.12,>=3.8" files = [ {file = "arize_phoenix-0.0.49-py3-none-any.whl", hash = "sha256:8f01bb60c5cb47f891e930268142f3cba3905bcfaace5d3304015fd67ab509fa"}, @@ -259,7 +259,7 @@ test = ["astroid", "pytest"] name = "astunparse" version = "1.6.3" description = "An AST unparser for Python" -optional = false +optional = true python-versions = "*" files = [ {file = "astunparse-1.6.3-py2.py3-none-any.whl", hash = "sha256:c2652417f2c8b5bb325c885ae329bdf3f86424075c4fd1a128674bc6fba4b8e8"}, @@ -314,7 +314,7 @@ files = [ name = "backoff" version = "2.2.1" description = "Function decoration for backoff and retry" -optional = false +optional = true python-versions = ">=3.7,<4.0" files = [ {file = "backoff-2.2.1-py3-none-any.whl", hash = "sha256:63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8"}, @@ -325,7 +325,7 @@ files = [ name = "bcrypt" version = "4.0.1" description = "Modern password hashing for your software and your servers" -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "bcrypt-4.0.1-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:b1023030aec778185a6c16cf70f359cbb6e0c289fd564a7cfa29e727a1c38f8f"}, @@ -544,7 +544,7 @@ files = [ name = "chroma-hnswlib" version = "0.7.3" description = "Chromas fork of hnswlib" -optional = false +optional = true python-versions = "*" files = [ {file = "chroma-hnswlib-0.7.3.tar.gz", hash = "sha256:b6137bedde49fffda6af93b0297fe00429fc61e5a072b1ed9377f909ed95a932"}, @@ -581,7 +581,7 @@ numpy = "*" name = "chromadb" version = "0.4.14" description = "Chroma." -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "chromadb-0.4.14-py3-none-any.whl", hash = "sha256:c1b59bdfb4b35a40bad0b8927c5ed757adf191ff9db2b9a384dc46a76e1ff10f"}, @@ -638,7 +638,7 @@ files = [ name = "coloredlogs" version = "15.0.1" description = "Colored terminal output for Python's logging module" -optional = false +optional = true python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ {file = "coloredlogs-15.0.1-py2.py3-none-any.whl", hash = "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934"}, @@ -807,34 +807,34 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "41.0.4" +version = "41.0.5" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false python-versions = ">=3.7" files = [ - {file = "cryptography-41.0.4-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:80907d3faa55dc5434a16579952ac6da800935cd98d14dbd62f6f042c7f5e839"}, - {file = "cryptography-41.0.4-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:35c00f637cd0b9d5b6c6bd11b6c3359194a8eba9c46d4e875a3660e3b400005f"}, - {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cecfefa17042941f94ab54f769c8ce0fe14beff2694e9ac684176a2535bf9714"}, - {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e40211b4923ba5a6dc9769eab704bdb3fbb58d56c5b336d30996c24fcf12aadb"}, - {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:23a25c09dfd0d9f28da2352503b23e086f8e78096b9fd585d1d14eca01613e13"}, - {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:2ed09183922d66c4ec5fdaa59b4d14e105c084dd0febd27452de8f6f74704143"}, - {file = "cryptography-41.0.4-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:5a0f09cefded00e648a127048119f77bc2b2ec61e736660b5789e638f43cc397"}, - {file = "cryptography-41.0.4-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:9eeb77214afae972a00dee47382d2591abe77bdae166bda672fb1e24702a3860"}, - {file = "cryptography-41.0.4-cp37-abi3-win32.whl", hash = "sha256:3b224890962a2d7b57cf5eeb16ccaafba6083f7b811829f00476309bce2fe0fd"}, - {file = "cryptography-41.0.4-cp37-abi3-win_amd64.whl", hash = "sha256:c880eba5175f4307129784eca96f4e70b88e57aa3f680aeba3bab0e980b0f37d"}, - {file = "cryptography-41.0.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:004b6ccc95943f6a9ad3142cfabcc769d7ee38a3f60fb0dddbfb431f818c3a67"}, - {file = "cryptography-41.0.4-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:86defa8d248c3fa029da68ce61fe735432b047e32179883bdb1e79ed9bb8195e"}, - {file = "cryptography-41.0.4-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:37480760ae08065437e6573d14be973112c9e6dcaf5f11d00147ee74f37a3829"}, - {file = "cryptography-41.0.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:b5f4dfe950ff0479f1f00eda09c18798d4f49b98f4e2006d644b3301682ebdca"}, - {file = "cryptography-41.0.4-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:7e53db173370dea832190870e975a1e09c86a879b613948f09eb49324218c14d"}, - {file = "cryptography-41.0.4-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:5b72205a360f3b6176485a333256b9bcd48700fc755fef51c8e7e67c4b63e3ac"}, - {file = "cryptography-41.0.4-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:93530900d14c37a46ce3d6c9e6fd35dbe5f5601bf6b3a5c325c7bffc030344d9"}, - {file = "cryptography-41.0.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:efc8ad4e6fc4f1752ebfb58aefece8b4e3c4cae940b0994d43649bdfce8d0d4f"}, - {file = "cryptography-41.0.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c3391bd8e6de35f6f1140e50aaeb3e2b3d6a9012536ca23ab0d9c35ec18c8a91"}, - {file = "cryptography-41.0.4-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:0d9409894f495d465fe6fda92cb70e8323e9648af912d5b9141d616df40a87b8"}, - {file = "cryptography-41.0.4-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:8ac4f9ead4bbd0bc8ab2d318f97d85147167a488be0e08814a37eb2f439d5cf6"}, - {file = "cryptography-41.0.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:047c4603aeb4bbd8db2756e38f5b8bd7e94318c047cfe4efeb5d715e08b49311"}, - {file = "cryptography-41.0.4.tar.gz", hash = "sha256:7febc3094125fc126a7f6fb1f420d0da639f3f32cb15c8ff0dc3997c4549f51a"}, + {file = "cryptography-41.0.5-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:da6a0ff8f1016ccc7477e6339e1d50ce5f59b88905585f77193ebd5068f1e797"}, + {file = "cryptography-41.0.5-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:b948e09fe5fb18517d99994184854ebd50b57248736fd4c720ad540560174ec5"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d38e6031e113b7421db1de0c1b1f7739564a88f1684c6b89234fbf6c11b75147"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e270c04f4d9b5671ebcc792b3ba5d4488bf7c42c3c241a3748e2599776f29696"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ec3b055ff8f1dce8e6ef28f626e0972981475173d7973d63f271b29c8a2897da"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:7d208c21e47940369accfc9e85f0de7693d9a5d843c2509b3846b2db170dfd20"}, + {file = "cryptography-41.0.5-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:8254962e6ba1f4d2090c44daf50a547cd5f0bf446dc658a8e5f8156cae0d8548"}, + {file = "cryptography-41.0.5-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:a48e74dad1fb349f3dc1d449ed88e0017d792997a7ad2ec9587ed17405667e6d"}, + {file = "cryptography-41.0.5-cp37-abi3-win32.whl", hash = "sha256:d3977f0e276f6f5bf245c403156673db103283266601405376f075c849a0b936"}, + {file = "cryptography-41.0.5-cp37-abi3-win_amd64.whl", hash = "sha256:73801ac9736741f220e20435f84ecec75ed70eda90f781a148f1bad546963d81"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:3be3ca726e1572517d2bef99a818378bbcf7d7799d5372a46c79c29eb8d166c1"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:e886098619d3815e0ad5790c973afeee2c0e6e04b4da90b88e6bd06e2a0b1b72"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:573eb7128cbca75f9157dcde974781209463ce56b5804983e11a1c462f0f4e88"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:0c327cac00f082013c7c9fb6c46b7cc9fa3c288ca702c74773968173bda421bf"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:227ec057cd32a41c6651701abc0328135e472ed450f47c2766f23267b792a88e"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:22892cc830d8b2c89ea60148227631bb96a7da0c1b722f2aac8824b1b7c0b6b8"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:5a70187954ba7292c7876734183e810b728b4f3965fbe571421cb2434d279179"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:88417bff20162f635f24f849ab182b092697922088b477a7abd6664ddd82291d"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c707f7afd813478e2019ae32a7c49cd932dd60ab2d2a93e796f68236b7e1fbf1"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:580afc7b7216deeb87a098ef0674d6ee34ab55993140838b14c9b83312b37b86"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:fba1e91467c65fe64a82c689dc6cf58151158993b13eb7a7f3f4b7f395636723"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:0d2a6a598847c46e3e321a7aef8af1436f11c27f1254933746304ff014664d84"}, + {file = "cryptography-41.0.5.tar.gz", hash = "sha256:392cb88b597247177172e02da6b7a63deeff1937fa6fec3bbf902ebd75d97ec7"}, ] [package.dependencies] @@ -869,7 +869,7 @@ tests = ["pytest", "pytest-cov", "pytest-xdist"] name = "cython" version = "0.29.36" description = "The Cython compiler for writing C extensions for the Python language." -optional = false +optional = true python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" files = [ {file = "Cython-0.29.36-cp27-cp27m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1ea33c1c57f331f5653baa1313e445fbe80d1da56dd9a42c8611037887897b9d"}, @@ -934,7 +934,7 @@ typing-inspect = ">=0.4.0,<1" name = "ddsketch" version = "2.0.4" description = "Distributed quantile sketches" -optional = false +optional = true python-versions = ">=2.7" files = [ {file = "ddsketch-2.0.4-py3-none-any.whl", hash = "sha256:3227a270fd686a29d3a7128f9352ccf852314410380fc11384356f1ae2a75938"}, @@ -1122,7 +1122,7 @@ typing = ["typing-extensions (>=4.7.1)"] name = "flatbuffers" version = "23.5.26" description = "The FlatBuffers serialization format for Python" -optional = false +optional = true python-versions = "*" files = [ {file = "flatbuffers-23.5.26-py2.py3-none-any.whl", hash = "sha256:c0ff356da363087b915fde4b8b45bdda73432fc17cddb3c8157472eab1422ad1"}, @@ -1364,7 +1364,7 @@ websockets = ">=10.0,<12.0" name = "graphlib-backport" version = "1.0.3" description = "Backport of the Python 3.9 graphlib module for Python 3.6+" -optional = false +optional = true python-versions = ">=3.6,<4.0" files = [ {file = "graphlib_backport-1.0.3-py3-none-any.whl", hash = "sha256:24246967b9e7e6a91550bc770e6169585d35aa32790258579a8a3899a8c18fde"}, @@ -1375,7 +1375,7 @@ files = [ name = "graphql-core" version = "3.2.3" description = "GraphQL implementation for Python, a port of GraphQL.js, the JavaScript reference implementation for GraphQL." -optional = false +optional = true python-versions = ">=3.6,<4" files = [ {file = "graphql-core-3.2.3.tar.gz", hash = "sha256:06d2aad0ac723e35b1cb47885d3e5c45e956a53bc1b209a9fc5369007fe46676"}, @@ -1461,7 +1461,7 @@ test = ["objgraph", "psutil"] name = "grpcio" version = "1.59.0" description = "HTTP/2-based RPC framework" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "grpcio-1.59.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:225e5fa61c35eeaebb4e7491cd2d768cd8eb6ed00f2664fa83a58f29418b39fd"}, @@ -1538,7 +1538,7 @@ files = [ name = "hdbscan" version = "0.8.33" description = "Clustering based on density with variable density clusters" -optional = false +optional = true python-versions = "*" files = [ {file = "hdbscan-0.8.33.tar.gz", hash = "sha256:57fabc5f0e45f48d2407b35c731192abc896376411fe7e4bb836ffa03d38f90d"}, @@ -1576,7 +1576,7 @@ socks = ["socksio (==1.*)"] name = "httptools" version = "0.6.1" description = "A collection of framework independent HTTP protocol utils." -optional = false +optional = true python-versions = ">=3.8.0" files = [ {file = "httptools-0.6.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d2f6c3c4cb1948d912538217838f6e9960bc4a521d7f9b323b3da579cd14532f"}, @@ -1680,7 +1680,7 @@ typing = ["pydantic (<2.0)", "types-PyYAML", "types-requests", "types-simplejson name = "humanfriendly" version = "10.0" description = "Human friendly output for text interfaces using Python" -optional = false +optional = true python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ {file = "humanfriendly-10.0-py2.py3-none-any.whl", hash = "sha256:1697e1a8a8f550fd43c2865cd84542fc175a61dcb779b6fee18cf6b6ccba1477"}, @@ -2219,7 +2219,7 @@ requests = ">=2,<3" name = "llvmlite" version = "0.41.1" description = "lightweight wrapper around basic LLVM functionality" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "llvmlite-0.41.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c1e1029d47ee66d3a0c4d6088641882f75b93db82bd0e6178f7bd744ebce42b9"}, @@ -2459,7 +2459,7 @@ files = [ name = "monotonic" version = "1.6" description = "An implementation of time.monotonic() for Python 2 & < 3.3" -optional = false +optional = true python-versions = "*" files = [ {file = "monotonic-1.6-py2.py3-none-any.whl", hash = "sha256:68687e19a14f11f26d140dd5c86f3dba4bf5df58003000ed467e0e2a69bca96c"}, @@ -2481,7 +2481,7 @@ files = [ name = "mpmath" version = "1.3.0" description = "Python library for arbitrary-precision floating-point arithmetic" -optional = false +optional = true python-versions = "*" files = [ {file = "mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c"}, @@ -2702,7 +2702,7 @@ setuptools = "*" name = "numba" version = "0.58.1" description = "compiling Python code using LLVM" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "numba-0.58.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:07f2fa7e7144aa6f275f27260e73ce0d808d3c62b30cff8906ad1dec12d87bbe"}, @@ -2774,7 +2774,7 @@ files = [ name = "onnxruntime" version = "1.16.1" description = "ONNX Runtime is a runtime accelerator for Machine Learning models" -optional = false +optional = true python-versions = "*" files = [ {file = "onnxruntime-1.16.1-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:28b2c7f444b4119950b69370801cd66067f403d19cbaf2a444735d7c269cce4a"}, @@ -2919,7 +2919,7 @@ files = [ name = "overrides" version = "7.4.0" description = "A decorator to automatically detect mismatch when overriding a method." -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "overrides-7.4.0-py3-none-any.whl", hash = "sha256:3ad24583f86d6d7a49049695efe9933e67ba62f0c7625d53c59fa832ce4b8b7d"}, @@ -2974,8 +2974,8 @@ files = [ [package.dependencies] numpy = [ {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, + {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -3211,7 +3211,7 @@ testing = ["pytest", "pytest-benchmark"] name = "posthog" version = "3.0.2" description = "Integrate PostHog into any python application." -optional = false +optional = true python-versions = "*" files = [ {file = "posthog-3.0.2-py2.py3-none-any.whl", hash = "sha256:a8c0af6f2401fbe50f90e68c4143d0824b54e872de036b1c2f23b5abb39d88ce"}, @@ -3266,7 +3266,7 @@ wcwidth = "*" name = "protobuf" version = "4.24.4" description = "" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "protobuf-4.24.4-cp310-abi3-win32.whl", hash = "sha256:ec9912d5cb6714a5710e28e592ee1093d68c5ebfeda61983b3f40331da0b1ebb"}, @@ -3327,7 +3327,7 @@ files = [ name = "pulsar-client" version = "3.3.0" description = "Apache Pulsar Python client library" -optional = false +optional = true python-versions = "*" files = [ {file = "pulsar_client-3.3.0-cp310-cp310-macosx_10_15_universal2.whl", hash = "sha256:c31afd3e67a044ff93177df89e08febf214cc965e95ede097d9fe8755af00e01"}, @@ -3399,7 +3399,7 @@ files = [ name = "pyarrow" version = "13.0.0" description = "Python library for Apache Arrow" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pyarrow-13.0.0-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:1afcc2c33f31f6fb25c92d50a86b7a9f076d38acbcb6f9e74349636109550148"}, @@ -3613,7 +3613,7 @@ plugins = ["importlib-metadata"] name = "pynndescent" version = "0.5.10" description = "Nearest Neighbor Descent" -optional = false +optional = true python-versions = "*" files = [ {file = "pynndescent-0.5.10.tar.gz", hash = "sha256:5d5dc683c03ef55fe3ddf693859720ca18f85c6e6e5bb0b4f14870278d5288ad"}, @@ -3644,7 +3644,7 @@ diagrams = ["jinja2", "railroad-diagrams"] name = "pypika" version = "0.48.9" description = "A SQL query builder API for Python" -optional = false +optional = true python-versions = "*" files = [ {file = "PyPika-0.48.9.tar.gz", hash = "sha256:838836a61747e7c8380cd1b7ff638694b7a7335345d0f559b04b2cd832ad5378"}, @@ -3654,7 +3654,7 @@ files = [ name = "pyreadline3" version = "3.4.1" description = "A python implementation of GNU readline." -optional = false +optional = true python-versions = "*" files = [ {file = "pyreadline3-3.4.1-py3-none-any.whl", hash = "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb"}, @@ -3665,7 +3665,7 @@ files = [ name = "pysqlite3-binary" version = "0.5.2.post1" description = "DB-API 2.0 interface for Sqlite 3.x" -optional = false +optional = true python-versions = "*" files = [ {file = "pysqlite3_binary-0.5.2.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:668e7853b9e3db5c23b32a57634f658db5008fa1781121d2554a103c34775fe8"}, @@ -4501,7 +4501,7 @@ files = [ name = "sortedcontainers" version = "2.4.0" description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set" -optional = false +optional = true python-versions = "*" files = [ {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"}, @@ -4635,7 +4635,7 @@ full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyam name = "strawberry-graphql" version = "0.208.2" description = "A library for creating GraphQL APIs" -optional = false +optional = true python-versions = ">=3.8,<4.0" files = [ {file = "strawberry_graphql-0.208.2-py3-none-any.whl", hash = "sha256:682a07bd9fe8691d145eb02e3ce8f65114f6c293184c659b31545f728351f813"}, @@ -4669,7 +4669,7 @@ starlite = ["starlite (>=1.48.0)"] name = "sympy" version = "1.12" description = "Computer algebra system (CAS) in Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "sympy-1.12-py3-none-any.whl", hash = "sha256:c3588cd4295d0c0f603d0f2ae780587e64e2efeedb3521e46b9bb1d08d184fa5"}, @@ -4753,7 +4753,7 @@ blobfile = ["blobfile (>=2)"] name = "tokenizers" version = "0.13.3" description = "Fast and Customizable Tokenizers" -optional = false +optional = true python-versions = "*" files = [ {file = "tokenizers-0.13.3-cp310-cp310-macosx_10_11_x86_64.whl", hash = "sha256:f3835c5be51de8c0a092058a4d4380cb9244fb34681fd0a295fbf0a52a5fdf33"}, @@ -4917,7 +4917,7 @@ urllib3 = ">=1.26.0" name = "typer" version = "0.9.0" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "typer-0.9.0-py3-none-any.whl", hash = "sha256:5d96d986a21493606a358cae4461bd8cdf83cbf33a5aa950ae629ca3b51467ee"}, @@ -4986,7 +4986,7 @@ files = [ name = "umap-learn" version = "0.5.4" description = "Uniform Manifold Approximation and Projection" -optional = false +optional = true python-versions = "*" files = [ {file = "umap-learn-0.5.4.tar.gz", hash = "sha256:8cb2fa20b2493f9adbff3bfa3b3e3787f6d67d1547e688ea2bdc272b37d89e18"}, @@ -5051,7 +5051,7 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", name = "uvloop" version = "0.19.0" description = "Fast implementation of asyncio event loop on top of libuv" -optional = false +optional = true python-versions = ">=3.8.0" files = [ {file = "uvloop-0.19.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:de4313d7f575474c8f5a12e163f6d89c0a878bc49219641d49e6f1444369a90e"}, @@ -5115,7 +5115,7 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess name = "watchfiles" version = "0.21.0" description = "Simple, modern and high performance file watching and code reload in python." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "watchfiles-0.21.0-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:27b4035013f1ea49c6c0b42d983133b136637a527e48c132d368eb19bf1ac6aa"}, @@ -5292,7 +5292,7 @@ files = [ name = "wheel" version = "0.41.2" description = "A built-package format for Python" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "wheel-0.41.2-py3-none-any.whl", hash = "sha256:75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8"}, @@ -5306,7 +5306,7 @@ test = ["pytest (>=6.0.0)", "setuptools (>=65)"] name = "wrapt" version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -optional = false +optional = true python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ {file = "wrapt-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:ca1cccf838cd28d5a0883b342474c630ac48cac5df0ee6eacc9c7290f76b11c1"}, @@ -5488,7 +5488,11 @@ files = [ docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] +[extras] +rag = ["chromadb", "pysqlite3-binary"] +tracing = ["arize-phoenix"] + [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<3.12" -content-hash = "a51e19df3eef79367e1f81e08eb8b2c0a07be48cc6255e505bffdc2e07b8a117" +content-hash = "02c6869f8347d112fcca7de18309e25ab8a25b93d69ee91b5fd648925537eb33" diff --git a/pyproject.toml b/pyproject.toml index bf6e2db..60f687d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,18 +16,22 @@ nbwrite = "nbwrite.cli:cli" [tool.poetry.dependencies] pytest = ">=6.1.0" python = ">=3.8.1,<3.12" -openai = {extras = ["embeddings"], version = "^0.28.1"} +openai = {optional = true, extras = ["embeddings"], version = "^0.28.1"} pathlib = "^1.0.1" click = "^8.1.7" -langchain = {optional = false, version = "^0.0.312", extras = ["openai"]} +langchain = {version = "^0.0.312", extras = ["openai"]} nbformat = "^5.9.2" -chromadb = "^0.4.14" -pysqlite3-binary = {version = "^0.5.2", markers = "sys_platform == 'linux'"} -arize-phoenix = {extras = ["experimental"], version = "^0.0.49"} +chromadb = {optional = true, version = "^0.4.14"} +pysqlite3-binary = {optional = true, version = "^0.5.2", markers = "sys_platform == 'linux'"} +arize-phoenix = {optional = true, extras = ["experimental"], version = "^0.0.49"} python-dotenv = "^1.0.0" pyyaml = "^6.0.1" rich = "^13.6.0" +[tool.poetry.extras] +tracing = ["arize-phoenix"] +rag = ["chromadb", "pysqlite3-binary", "openai"] + [tool.poetry.dev-dependencies] pytest = "^7.1.0" pre-commit = "^2.8.2" diff --git a/src/nbwrite/config.py b/src/nbwrite/config.py index 9d46f83..87917b6 100644 --- a/src/nbwrite/config.py +++ b/src/nbwrite/config.py @@ -20,7 +20,7 @@ class GenerationConfig(BaseModel): class Config(BaseModel): task: str - steps: List[str] - packages: List[str] - out: str - generation: GenerationConfig + steps: List[str] = [] + packages: List[str] = [] + out: str = "nbwrite-out" + generation: GenerationConfig = GenerationConfig() diff --git a/src/nbwrite/index.py b/src/nbwrite/index.py index 57c634a..0abaf17 100644 --- a/src/nbwrite/index.py +++ b/src/nbwrite/index.py @@ -1,5 +1,4 @@ import importlib.util -import os import platform from pathlib import Path from typing import Any, Dict, List @@ -10,13 +9,6 @@ from langchain.text_splitter import Language, RecursiveCharacterTextSplitter from langchain.vectorstores import Chroma -if platform.system() == "Linux": - # https://docs.trychroma.com/troubleshooting#sqlite - __import__("pysqlite3") - import sys - - sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") - def get_embeddings(): return OpenAIEmbeddings(disallowed_special=()) @@ -27,6 +19,12 @@ def create_index( retriever_kwargs: Dict[str, Any], text_splitter_kwargs: Dict[str, Any], ): + if platform.system() == "Linux": + # https://docs.trychroma.com/troubleshooting#sqlite + __import__("pysqlite3") + import sys + + sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") python_splitter = RecursiveCharacterTextSplitter.from_language( language=Language.PYTHON, **text_splitter_kwargs diff --git a/src/nbwrite/writer.py b/src/nbwrite/writer.py index b4ca469..6535e1b 100644 --- a/src/nbwrite/writer.py +++ b/src/nbwrite/writer.py @@ -15,7 +15,7 @@ from langchain.schema import format_document from langchain.schema.messages import SystemMessage from langchain.schema.output_parser import StrOutputParser -from langchain.schema.runnable import RunnableParallel +from langchain.schema.runnable import RunnableLambda, RunnableParallel from nbformat.v4 import ( new_code_cell, new_markdown_cell, @@ -42,13 +42,19 @@ def gen( if os.getenv("NBWRITE_PHOENIX_TRACE"): click.echo("Enabling Phoenix Trace") - from phoenix.trace.langchain import ( - LangChainInstrumentor, - OpenInferenceTracer, - ) - - tracer = OpenInferenceTracer() - LangChainInstrumentor(tracer).instrument() + try: + from phoenix.trace.langchain import ( + LangChainInstrumentor, + OpenInferenceTracer, + ) + + tracer = OpenInferenceTracer() + LangChainInstrumentor(tracer).instrument() + except ModuleNotFoundError: + click.echo( + "In order to use Phoenix Tracing you must `pip install 'nbwrite[tracing]'" + ) + exit(1) prompt = ChatPromptTemplate.from_messages( [ @@ -57,22 +63,26 @@ def gen( ] ) - retriever = create_index( - config.packages, - config.generation.retriever_kwargs, - config.generation.text_splitter_kwargs, - ) - - def _combine_documents( - docs, document_prompt=PromptTemplate.from_template(template="{page_content}"), document_separator="\n\n" # type: ignore - ): - doc_strings = [format_document(doc, document_prompt) for doc in docs] - return document_separator.join(doc_strings) + if len(config.packages) > 0: + try: + retriever = create_index( + config.packages, + config.generation.retriever_kwargs, + config.generation.text_splitter_kwargs, + ) + context_chain = itemgetter("task") | retriever | _combine_documents + except ModuleNotFoundError: + click.echo( + "In order to use `packages`, you must `pip install 'nbwrite[rag]'`" + ) + exit(1) + else: + context_chain = RunnableLambda(lambda _: "none") llm = get_llm(**config.generation.llm_kwargs) | StrOutputParser() chain = ( { - "context": itemgetter("task") | retriever | _combine_documents, + "context": context_chain, "task": itemgetter("task"), "steps": itemgetter("steps"), "packages": itemgetter("packages"), @@ -114,3 +124,10 @@ def _combine_documents( click.echo(f"Wrote notebook to {filename}") except Exception as e: logger.error(f"Error writing notebook (generation {generation}): {e}") + + +def _combine_documents( + docs, document_prompt=PromptTemplate.from_template(template="{page_content}"), document_separator="\n\n" # type: ignore +): + doc_strings = [format_document(doc, document_prompt) for doc in docs] + return document_separator.join(doc_strings) diff --git a/tests/resources/nbwrite-in/minimal.yaml b/tests/resources/nbwrite-in/minimal.yaml new file mode 100644 index 0000000..15a4160 --- /dev/null +++ b/tests/resources/nbwrite-in/minimal.yaml @@ -0,0 +1,2 @@ +task: | + Plot the iris dataset using pandas diff --git a/tests/test_cli.py b/tests/test_cli.py index 8bfacf1..3d404a0 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -56,3 +56,33 @@ def test_cli(tmpdir: local): assert "Hello, world!" in "".join( output.text for output in cell.outputs ) + + +def test_cli_minimal(tmpdir: local): + + if os.getenv("NBWRITE_DEBUG_MODE"): + outdir = "test-debug-out" + [pp.unlink() for pp in Path(outdir).glob("*.ipynb")] + else: + outdir = str(tmpdir) + runner = CliRunner() + args = [ + "tests/resources/nbwrite-in/minimal.yaml", + "--out", + outdir, + ] + + shell_fmt = " \\\n ".join(["nbwrite", *args]) + logger.warn(f"Running\n{shell_fmt}") + + with patch("nbwrite.writer.get_llm") as mock_get_llm: + mock_get_llm.return_value = FakeListLLM( + responses=["Code:\n```python\nprint('Hello, world!')\n```\n"] + ) + result = runner.invoke(cli, args) + + assert result.exit_code == 0 + + logger.warn(f"Checking outputs in {outdir}") + outputs = list(Path(outdir).glob("*.ipynb")) + assert len(outputs) == 2