You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Poetry](https://python-poetry.org/) is a tool that combines [virtualenv](https://virtualenv.pypa.io/en/latest/) usage with dependency management, to provide a consistent experience for project maintainers and contributors who need to develop the pinecone-python-client
23
-
as a library.
23
+
as a library.
24
24
25
-
A common need when making changes to the Pinecone client is to test your changes against existing Python code or Jupyter Notebooks that `pip install` the Pinecone Python client as a library.
25
+
A common need when making changes to the Pinecone client is to test your changes against existing Python code or Jupyter Notebooks that `pip install` the Pinecone Python client as a library.
26
26
27
-
Developers want to be able to see their changes to the library immediately reflected in their main application code, as well as to track all changes they make in git, so that they can be contributed back in the form of a pull request.
27
+
Developers want to be able to see their changes to the library immediately reflected in their main application code, as well as to track all changes they make in git, so that they can be contributed back in the form of a pull request.
28
28
29
-
The Pinecone Python client therefore supports Poetry as its primary means of enabling a consistent local development experience. This guide will walk you through the setup process so that you can:
29
+
The Pinecone Python client therefore supports Poetry as its primary means of enabling a consistent local development experience. This guide will walk you through the setup process so that you can:
30
30
1. Make local changes to the Pinecone Python client that are separated from your system's Python installation
31
31
2. Make local changes to the Pinecone Python client that are immediately reflected in other local code that imports the pinecone client
32
32
3. Track all your local changes to the Pinecone Python client so that you can contribute your fixes and feature additions back via GitHub pull requests
33
33
34
34
### Step 1. Fork the Pinecone python client repository
35
35
36
-
On the [GitHub repository page](https://github.com/pinecone-io/pinecone-python-client) page, click the fork button at the top of the screen and create a personal fork of the repository:
36
+
On the [GitHub repository page](https://github.com/pinecone-io/pinecone-python-client) page, click the fork button at the top of the screen and create a personal fork of the repository:
37
37
38
38

39
39
40
-
It will take a few seconds for your fork to be ready. When it's ready, **clone your fork** of the Pinecone python client repository to your machine.
40
+
It will take a few seconds for your fork to be ready. When it's ready, **clone your fork** of the Pinecone python client repository to your machine.
41
41
42
-
Change directory into the repository, as we'll be setting up a virtualenv from within the root of the repository.
42
+
Change directory into the repository, as we'll be setting up a virtualenv from within the root of the repository.
43
43
44
-
### Step 1. Install Poetry
44
+
### Step 1. Install Poetry
45
45
46
-
Visit [the Poetry site](https://python-poetry.org/) for installation instructions.
46
+
Visit [the Poetry site](https://python-poetry.org/) for installation instructions.
47
47
48
-
### Step 2. Install dependencies
48
+
### Step 2. Install dependencies
49
49
50
-
Run `poetry install` from the root of the project.
50
+
Run `poetry install` from the root of the project.
51
51
52
52
### Step 3. Activate the Poetry virtual environment and verify success
53
53
54
-
Run `poetry shell` from the root of the project. At this point, you now have a virtualenv set up in this directory, which you can verify by running:
54
+
Run `poetry shell` from the root of the project. At this point, you now have a virtualenv set up in this directory, which you can verify by running:
55
55
56
56
`poetry env info`
57
57
58
-
You should see something similar to the following output:
58
+
You should see something similar to the following output:
If you want to extract only the path to your new virtualenv, you can run `poetry env info --path`
75
75
76
-
##Loading your virtualenv in another shell
76
+
### Step 4. Enable pre-commit hooks.
77
77
78
-
It's a common need when developing against this client to load it as part of some other application or Jupyter Notebook code, modify
79
-
it directly, see your changes reflected immediately and also have your changes tracked in git so you can contribute them back.
78
+
Run `poetry run pre-commit install` to enable checks to run when you commit so you don't have to find out during your CI run that minor issues need to be addressed.
80
79
81
-
It's important to understand that, by default, if you open a new shell or terminal window, or, for example, a new pane in a tmux session,
82
-
your new shell will not yet reference the new virtualenv you created in the previous step.
80
+
## Loading your virtualenv in another shell
81
+
82
+
It's a common need when developing against this client to load it as part of some other application or Jupyter Notebook code, modify
83
+
it directly, see your changes reflected immediately and also have your changes tracked in git so you can contribute them back.
84
+
85
+
It's important to understand that, by default, if you open a new shell or terminal window, or, for example, a new pane in a tmux session,
86
+
your new shell will not yet reference the new virtualenv you created in the previous step.
83
87
84
88
### Step 1. Get the path to your virtualenv
85
89
86
-
We're going to first get the path to the virtualenv we just created, by running:
90
+
We're going to first get the path to the virtualenv we just created, by running:
87
91
88
92
```bash
89
93
poetry env info --path
@@ -93,48 +97,48 @@ You'll get a path similar to this one: `/home/youruser/.cache/pypoetry/virtuale
93
97
94
98
### Step 2. Load your existing virtualenv in your new shell
95
99
96
-
Within this path is a shell script that lives at `<your-virtualenv-path>/bin/activate`. Importantly, you cannot simply run this script, but you
97
-
must instead source it like so:
100
+
Within this path is a shell script that lives at `<your-virtualenv-path>/bin/activate`. Importantly, you cannot simply run this script, but you
In the above example, ensure you're using your own virtualenv path as returned by `poetry env info --path`.
103
107
104
-
### Step 3. Test out your virtualenv
108
+
### Step 3. Test out your virtualenv
105
109
106
-
Now, we can test that our virtualenv is working properly by adding a new test module and function to the `pinecone` client within our virtualenv
107
-
and running it from the second shell.
110
+
Now, we can test that our virtualenv is working properly by adding a new test module and function to the `pinecone` client within our virtualenv
111
+
and running it from the second shell.
108
112
109
113
#### Create a new test file in pinecone-python-client
110
-
In the root of your working directory of the `pinecone-python-client` where you first ran `poetry shell`, add a new file named `hello_virtualenv.py` under the `pinecone` folder.
114
+
In the root of your working directory of the `pinecone-python-client` where you first ran `poetry shell`, add a new file named `hello_virtualenv.py` under the `pinecone` folder.
111
115
112
-
In that file write the following:
116
+
In that file write the following:
113
117
114
118
```python
115
119
defhello():
116
120
print("Hello, from your virtualenv!")
117
121
```
118
-
Save the file.
122
+
Save the file.
119
123
120
-
#### Create a new test file in your second shell
121
-
This step demonstrates how you can immediately test your latest Pinecone client code from any local Python application or Jupyter Notebook:
124
+
#### Create a new test file in your second shell
125
+
This step demonstrates how you can immediately test your latest Pinecone client code from any local Python application or Jupyter Notebook:
122
126
123
-
In your second shell, where you ran `source` to load your virtualenv, create a python file named `test.py` and write the following:
127
+
In your second shell, where you ran `source` to load your virtualenv, create a python file named `test.py` and write the following:
124
128
125
129
```python
126
130
from pinecone import hello_virtualenv
127
131
128
132
hello_virtualenv.hello()
129
133
```
130
134
131
-
Save the file. Run it with your Python binary. Depending on your system, this may either be `python` or `python3`:
135
+
Save the file. Run it with your Python binary. Depending on your system, this may either be `python` or `python3`:
132
136
133
137
```bash
134
138
python3 test.py
135
139
```
136
140
137
-
You should see the following output:
141
+
You should see the following output:
138
142
139
143
```bash
140
144
❯ python3 test.py
@@ -154,7 +158,7 @@ Prerequisites:
154
158
- You must have initialized the git submodules under codegen
155
159
156
160
```sh
157
-
git submodule
161
+
git submodule
158
162
```
159
163
160
164
@@ -164,4 +168,4 @@ To regenerate the generated portions of the client with the latest version of th
0 commit comments