-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support Poetry for local development. Add local development guide. #193
Conversation
Thanks for taking a crack at this. Is there anyway we can do this without duplicating the list of dependencies from requirements.txt? |
@jhamon I've read up more on the subject and I think it should be okay to remove the requirements*.txt files - as you mention, the dependencies themselves will now be managed in As far as I'm aware, it's most common to With the new contributor's guide (feedback also very welcome there) then current and future maintainers should be able to use The same should be true for our Please let me know if I've missed anything, as you're more familiar with this project than I am. Thank you 🙇 |
@zackproser I followed the contribution guide and it works for me. Thanks! It can also work with |
Awesome - thanks for confirming @StankoKuveljic ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy smokes. This is a great contribution!
I pointed out a few things about CI and publishing I would like to see addressed but this seems 95% there.
Also, since we're done with tox (good riddance) you can also delete the tox.ini
file.
pyproject.toml
Outdated
|
||
[tool.poetry] | ||
name = "pinecone" | ||
version = "2.2.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the pinecone/__version__
file was the one source of truth on the package version and the value stored there gets updated automatically as part of the publish release CI job. Since poetry needs it in this toml file, we have to maintain and update both version numbers as part of our release process.
Fortunately there is a poetry version
command that can handle the file manipulations in toml for us. I think you need to:
-
Bump the version stored in pyproject.toml during the publish workflow. Do it by adjusting this publish job. I would add a step before building and publishing happens to update the toml version using a command like
poetry version ${{ inputs.releaseLevel }}
(this variable already exists and should contain a value likemajor
,minor
,patch
that aligns with the bump types poetry knows about according topoetry version -h
). -
Leave the existing bump step alone, since I think we still need to update
__version__
. Unless poetry makes a change to it during the publish. But after a few minutes of googling I don't think it does. -
And then also remember to add and commit the change as part of this step. If you forget this step then version will be out of date and there could be a version conflict on a future release.
I would make your best attempt at making these changes, but don't try running the job to test them for now (since publishing a release is not something we want to do off of a dev branch). I'll work out any kinks when I try to publish the next release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome thanks so much for the detailed explanation and links. I'll take a crack at this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a stab in 69d7fe5 LMK what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the conversation here, I think the changes to publish-to-pypi.yaml
make sense. Thanks, Zack!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we've bumped versions in the current client so you'll need to rebase / resolve the version number here, possibly.
I suppose one other thing that comes to mind is the I'm not sure whether setup.py is still needed in a poetry world. Definitely needs some googling / research. And if we could keep these optional grpc dependencies isolated I think that would be good. |
Thanks for mentioning this - I was wondering about it, too. Poetry supports this concept of FWIW, I had the same experience as you when encountering the
Roger - makes sense to me. Do you share the opinion that Poetry is generally the preferred / sanest way to manage Python projects these days? I've heard that from two Python gurus that I trust so far. I'll spend some time looking into separating the grpc dependencies again. Thanks for your help! |
I believe I've separated out our gRPC dependencies in the Poetry fashion in 6406198 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work here, @zackproser. I feel like this is a huge improvement to our workflow within this repository, and I believe it makes sense to go ahead and incorporate Poetry.
I've left some minor comments and suggestions, but overall I feel like this is good to go.
I checked out your fork & branch locally and ran all the associated poetry commands successfully. Feels like it works really well out of the box:
As for the CI changes, I think things look good. We're maintaining the previous __version__
management behavior and leveraging poetry version
properly to align things. Like Jen mentioned, if we run into issues when publishing we can resolve them then.
Overall big net win I think, thanks so much!
pyproject.toml
Outdated
|
||
[tool.poetry] | ||
name = "pinecone" | ||
version = "2.2.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the conversation here, I think the changes to publish-to-pypi.yaml
make sense. Thanks, Zack!
@@ -0,0 +1,127 @@ | |||
# Contributing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Thanks a ton for adding a detailed CONTRIBUTING file! We need something similar for the other clients, and it's great you took the initiative here with the Poetry migration. 🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much! It is my pleasure. I want to make this as straightforward as possible for all of us and our customers and community members.
pyproject.toml
Outdated
|
||
[tool.poetry] | ||
name = "pinecone" | ||
version = "2.2.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we've bumped versions in the current client so you'll need to rebase / resolve the version number here, possibly.
pyproject.toml
Outdated
version = "2.2.2" | ||
description = "The official Python client for Pinecone's vector database" | ||
authors = ["Pinecone Systems, Inc. <support@pinecone.io>"] | ||
license = "https://github.com/pinecone-io/pinecone-python-client/blob/main/LICENSE.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LICENSE
file was updated yesterday to Apache 2.0, this may need an update as well: #204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling out - looking at main
it appears the link to the license file didn't change, even if the license type and content did - so I think we're okay, so long as this is truly the right way to reference the license in a pyproject.toml (via URL).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it's also fair to use the string Apache-2.0
for the license property, so I did that in 165608e
@austin-denoble Thanks so much for taking the time to do a detailed review and local testing! 🙇 I'll address all your feedback and tackle rebasing first thing tomorrow AM. |
8bdebca
to
5ac2fe4
Compare
-pyproject.toml will now be the source of truth for dependencies
-Our pinecone/__version__ file has been the source of truth for our release process -Poetry uses pyproject.toml. For the time being, we need to update both files. They should both always contain the same version
-The repo level package is pinecone-client - e.g., pip install \ pinecone-client, and the pinecone subdirectory is the module
Co-authored-by: Austin DeNoble <austin.d@pinecone.io>
Co-authored-by: Austin DeNoble <austin.d@pinecone.io>
da250e5
to
15fd509
Compare
## Problem After the poetry migration in #193 the `PyPI Release: Nightly (pinecone-client-nightly)` has been failing: https://github.com/pinecone-io/pinecone-python-client/actions/runs/6374232183/job/17298658421 The reason is we removed the `setup.py` file as a part of the migration and `nightly-release.yaml` used to adjust the module name via `sed -i 's/pinecone-client/pinecone-client-nightly/g' setup.py`. To achieve something similar now that we've changed our build / packaging process to use Poetry, we need to look at updating the `pyproject.toml` file. While looking at correcting this, I realized the resulting build artifacts from `make package` (which now calls `poetry build`) now have different package names which may cause issues with PyPI: - (Old) `pinecone-client-2.2.4.tar.gz` - (New) `pinecone-2.2.4.tar.gz` - (Old) `pinecone_client-2.2.4-py3-none-any.whl` - (New) `pinecone-2.2.4-py3-none-any.whl` ## Solution - I updated `nightly-release.yaml` to call `sed -i ...` on the `pyproject.toml` file instead of `setup.py`. This should swap out `name: pinecone-client` for `name: pinecone-client-nightly` under `[tools.poetry]` which should fix up the package naming. - Added a `packages` section to `pyproject.toml` to define the top-level pinecone package entrypoint. Poetry uses the `name` field by default unless this is specified which is why we were ending up with artifacts called `pinecone-...` rather than `pinecone-client-...`. **Note:** Poetry swaps the hyphen in `pinecone-client` for an underscore in the resulting build output artifacts. New packages: - `pinecone_client-2.2.4.tar.gz` - `pinecone_client-2.2.4-py3-none-any.whl` The `.whl` naming is equivalent, and the `tar.gz` has an underscore rather than a hyphen. I think ultimately this shouldn't matter given the guidance around `name` here: https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#name > Comparison of project names is case insensitive and treats arbitrarily-long runs of underscores, hyphens, and/or periods as equal. For example, if you register a project named cool-stuff, users will be able to download it or declare a dependency on it using any of the following spellings: Cool-Stuff cool.stuff COOL_STUFF CoOl__-.-__sTuFF ## Type of Change - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [X] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Describe specific steps for validating this change.
Problem
Closes #192
These changes add support for managing the Pinecone Python client via Poetry, a virtualenv and dependency manager.
The intent is to provide a more consistent development experience for maintainers and contributors and to support the common workflow of needing to develop against the pinecone client as a dependency of a Jupyter notebook, or Python script or program that also imports other common libraries such as LangChain.
These changes also add a new CONTRIBUTING guide (link to rendered version for easier review) which explains how to develop the Pinecone Python client locally even across multiple shells using Poetry.
The intent of this guide is to significantly ease local development of Pinecone in scenario like Jupyter Notebooks and Python applications where
pinecone
and supporting libraries such aslangchain
are often imported after beingpip install
ed.Solution
[tool.poetry.dependencies]
section[tool.poetry.dev-dependencies]
Type of Change
Test Plan
poetry install
locallypoetry shell
locallypoetry build
locallymake test
within the Poetry virtualenv