Skip to content

Commit 969b77f

Browse files
committed
Merge branch 'iuliaferoli-es-to-client' of https://github.com/iuliaferoli/elasticsearch-py into iuliaferoli-es-to-client
2 parents 1c2d29c + 25fd0e8 commit 969b77f

File tree

137 files changed

+9280
-1919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+9280
-1919
lines changed

.buildkite/pipeline.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
steps:
2-
- label: ":elasticsearch: :python: ES Python ({{ matrix.python }})"
2+
- label: ":elasticsearch: :python: ES Python ({{ matrix.python }}) {{ matrix.nox_session }} "
33
agents:
44
provider: "gcp"
55
env:
66
PYTHON_VERSION: "{{ matrix.python }}"
77
TEST_SUITE: "platinum"
88
STACK_VERSION: "8.11.0-SNAPSHOT"
99
PYTHON_CONNECTION_CLASS: "{{ matrix.connection }}"
10+
NOX_SESSION: "{{ matrix.nox_session }}"
1011
matrix:
1112
setup:
1213
python:
@@ -19,4 +20,15 @@ steps:
1920
connection:
2021
- "urllib3"
2122
- "requests"
23+
nox_session:
24+
- "test"
25+
adjustments:
26+
- with:
27+
python: "3.7"
28+
connection: "urllib3"
29+
nox_session: "test_otel"
30+
- with:
31+
python: "3.12"
32+
connection: "urllib3"
33+
nox_session: "test_otel"
2234
command: ./.buildkite/run-tests

.buildkite/pull-requests.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"enabled": true,
55
"pipeline_slug": "elasticsearch-py-integration-tests",
66
"allow_org_users": true
7+
},
8+
{
9+
"enabled": true,
10+
"pipeline_slug": "docs-build-pr",
11+
"allow_org_users": true
712
}
813
]
914
}

.buildkite/run-repository.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m"
1818
echo -e "\033[34;1mINFO:\033[0m VERSION ${ELASTICSEARCH_VERSION}\033[0m"
1919
echo -e "\033[34;1mINFO:\033[0m CONTAINER ${ELASTICSEARCH_CONTAINER}\033[0m"
2020
echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m"
21+
echo -e "\033[34;1mINFO:\033[0m NOX_SESSION ${NOX_SESSION}\033[0m"
2122
echo -e "\033[34;1mINFO:\033[0m PYTHON_VERSION ${PYTHON_VERSION}\033[0m"
2223
echo -e "\033[34;1mINFO:\033[0m PYTHON_CONNECTION_CLASS ${PYTHON_CONNECTION_CLASS}\033[0m"
2324

@@ -45,4 +46,4 @@ docker run \
4546
--name elasticsearch-py \
4647
--rm \
4748
elastic/elasticsearch-py \
48-
nox -s test-${PYTHON_VERSION}
49+
nox -s ${NOX_SESSION}-${PYTHON_VERSION}

.github/make.sh

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
#!/usr/bin/env bash
2+
3+
# ------------------------------------------------------- #
4+
#
5+
# Skeleton for common build entry script for all elastic
6+
# clients. Needs to be adapted to individual client usage.
7+
#
8+
# Must be called: ./.github/make.sh <target> <params>
9+
#
10+
# Version: 1.1.0
11+
#
12+
# Targets:
13+
# ---------------------------
14+
# assemble <VERSION> : build client artefacts with version
15+
# bump <VERSION> : bump client internals to version
16+
# codegen <VERSION> : generate endpoints
17+
# docsgen <VERSION> : generate documentation
18+
# examplegen : generate the doc examples
19+
# clean : clean workspace
20+
#
21+
# ------------------------------------------------------- #
22+
23+
# ------------------------------------------------------- #
24+
# Bootstrap
25+
# ------------------------------------------------------- #
26+
27+
script_path=$(dirname "$(realpath -s "$0")")
28+
repo=$(realpath "$script_path/../")
29+
30+
# shellcheck disable=SC1090
31+
CMD=$1
32+
TASK=$1
33+
TASK_ARGS=()
34+
VERSION=$2
35+
STACK_VERSION=$VERSION
36+
set -euo pipefail
37+
38+
product="elastic/elasticsearch-py"
39+
output_folder=".github/output"
40+
codegen_folder=".github/output"
41+
OUTPUT_DIR="$repo/${output_folder}"
42+
REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
43+
WORKFLOW="${WORKFLOW-staging}"
44+
mkdir -p "$OUTPUT_DIR"
45+
46+
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
47+
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
48+
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
49+
50+
# ------------------------------------------------------- #
51+
# Parse Command
52+
# ------------------------------------------------------- #
53+
54+
case $CMD in
55+
clean)
56+
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
57+
rm -rf "$output_folder"
58+
echo -e "\033[32;1mdone.\033[0m"
59+
exit 0
60+
;;
61+
assemble)
62+
if [ -v $VERSION ]; then
63+
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
64+
exit 1
65+
fi
66+
echo -e "\033[36;1mTARGET: assemble artefact $VERSION\033[0m"
67+
TASK=release
68+
TASK_ARGS=("$VERSION" "$output_folder")
69+
;;
70+
codegen)
71+
VERSION=$(git rev-parse --abbrev-ref HEAD)
72+
echo -e "\033[36;1mTARGET: codegen API $VERSION\033[0m"
73+
TASK=codegen
74+
# VERSION is BRANCH here for now
75+
TASK_ARGS=("$VERSION" "$codegen_folder")
76+
;;
77+
docsgen)
78+
if [ -v $VERSION ]; then
79+
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
80+
exit 1
81+
fi
82+
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
83+
TASK=codegen
84+
# VERSION is BRANCH here for now
85+
TASK_ARGS=("$VERSION" "$codegen_folder")
86+
;;
87+
examplesgen)
88+
echo -e "\033[36;1mTARGET: generate examples\033[0m"
89+
TASK=codegen
90+
# VERSION is BRANCH here for now
91+
TASK_ARGS=("$VERSION" "$codegen_folder")
92+
;;
93+
bump)
94+
if [ -v $VERSION ]; then
95+
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
96+
exit 1
97+
fi
98+
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
99+
TASK=bump
100+
# VERSION is BRANCH here for now
101+
TASK_ARGS=("$VERSION")
102+
;;
103+
*)
104+
echo -e "\nUsage:\n\t $CMD is not supported right now\n"
105+
exit 1
106+
esac
107+
108+
109+
# ------------------------------------------------------- #
110+
# Build Container
111+
# ------------------------------------------------------- #
112+
113+
echo -e "\033[34;1mINFO: building $product container\033[0m"
114+
115+
docker build \
116+
--build-arg BUILDER_UID="$(id -u)" \
117+
--file $repo/.buildkite/Dockerfile \
118+
--tag ${product} \
119+
.
120+
121+
# ------------------------------------------------------- #
122+
# Run the Container
123+
# ------------------------------------------------------- #
124+
125+
echo -e "\033[34;1mINFO: running $product container\033[0m"
126+
127+
if [[ "$CMD" == "assemble" ]]; then
128+
129+
# Build dists into .github/output
130+
docker run \
131+
-u "$(id -u)" \
132+
--rm -v $repo/.github/output:/code/elasticsearch-py/dist \
133+
$product \
134+
/bin/bash -c "pip install build; python /code/elasticsearch-py/utils/build-dists.py $VERSION"
135+
136+
# Verify that there are dists in .github/output
137+
if compgen -G ".github/output/*" > /dev/null; then
138+
139+
# Tarball everything up in .github/output
140+
if [[ "$WORKFLOW" == 'snapshot' ]]; then
141+
cd $repo/.github/output && tar -czvf elasticsearch-py-$VERSION-SNAPSHOT.tar.gz * && cd -
142+
else
143+
cd $repo/.github/output && tar -czvf elasticsearch-py-$VERSION.tar.gz * && cd -
144+
fi
145+
146+
echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m"
147+
exit 0
148+
else
149+
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
150+
exit 1
151+
fi
152+
fi
153+
154+
if [[ "$CMD" == "bump" ]]; then
155+
docker run \
156+
--rm -v $repo:/code/elasticsearch-py \
157+
$product \
158+
/bin/bash -c "python /code/elasticsearch-py/utils/bump-version.py $VERSION"
159+
160+
exit 0
161+
fi
162+
163+
if [[ "$CMD" == "codegen" ]]; then
164+
docker run \
165+
--rm -v $repo:/code/elasticsearch-py \
166+
$product \
167+
/bin/bash -c "cd /code && python -m pip install nox && \
168+
git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-python.git && \
169+
cd /code/elastic-client-generator-python && GIT_BRANCH=$VERSION python -m nox -s generate-es && \
170+
cd /code/elasticsearch-py && python -m nox -s format"
171+
172+
exit 0
173+
fi
174+
175+
if [[ "$CMD" == "docsgen" ]]; then
176+
echo "TODO"
177+
fi
178+
179+
if [[ "$CMD" == "examplesgen" ]]; then
180+
echo "TODO"
181+
fi
182+
183+
echo "Must be called with '.github/make.sh [command]"
184+
exit 1

README.rst

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Elasticsearch Python Client
1414
.. image:: https://static.pepy.tech/badge/elasticsearch
1515
:target: https://pepy.tech/project/elasticsearch?versions=*
1616

17+
.. image:: https://badge.buildkite.com/68e22afcb2ea8f6dcc20834e3a5b5ab4431beee33d3bd751f3.svg
18+
:target: https://buildkite.com/elastic/elasticsearch-py-integration-tests
19+
1720
.. image:: https://clients-ci.elastic.co/job/elastic+elasticsearch-py+main/badge/icon
1821
:target: https://clients-ci.elastic.co/job/elastic+elasticsearch-py+main
1922

@@ -72,12 +75,27 @@ Usage
7275
Compatibility
7376
-------------
7477

75-
Language clients are forward compatible; meaning that clients support communicating
76-
with greater or equal minor versions of Elasticsearch. Elasticsearch language clients
77-
are only backwards compatible with default distributions and without guarantees made.
78+
Language clients are forward compatible; meaning that the clients support
79+
communicating with greater or equal minor versions of Elasticsearch without
80+
breaking. It does not mean that the clients automatically support new features
81+
of newer Elasticsearch versions; it is only possible after a release of a new
82+
client version. For example, a 8.12 client version won't automatically support
83+
the new features of the 8.13 version of Elasticsearch, the 8.13 client version
84+
is required for that. Elasticsearch language clients are only backwards
85+
compatible with default distributions and without guarantees made.
86+
87+
+-----------------------+-------------------------+-----------+
88+
| Elasticsearch version | elasticsearch-py branch | Supported |
89+
+=======================+=========================+===========+
90+
| main | main | |
91+
+-----------------------+-------------------------+-----------+
92+
| 8.x | 8.x | 8.x |
93+
+-----------------------+-------------------------+-----------+
94+
| 7.x | 7.x | 7.17 |
95+
+-----------------------+-------------------------+-----------+
7896

7997
If you have a need to have multiple versions installed at the same time older
80-
versions are also released as ``elasticsearch2`` and ``elasticsearch5``.
98+
versions are also released as ``elasticsearch7`` and ``elasticsearch8``.
8199

82100

83101
Documentation
@@ -89,6 +107,20 @@ Documentation for the client is `available on elastic.co`_ and `Read the Docs`_.
89107
.. _Read the Docs: https://elasticsearch-py.readthedocs.io
90108

91109

110+
Feedback 🗣️
111+
-----------
112+
113+
The engineering team here at Elastic is looking for developers to participate in
114+
research and feedback sessions to learn more about how you use our Python client and
115+
what improvements we can make to their design and your workflow. If you're interested in
116+
sharing your insights into developer experience and language client design, please fill
117+
out this `short form`_. Depending on the number of responses we get, we may either
118+
contact you for a 1:1 conversation or a focus group with other developers who use the
119+
same client. Thank you in advance - your feedback is crucial to improving the user
120+
experience for all Elasticsearch developers!
121+
122+
.. _short form: https://forms.gle/bYZwDQXijfhfwshn9
123+
92124
License
93125
-------
94126

dev-requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
elastic-transport>=8.0.0b1, <9
1+
# TODO switch back to elastic-transport>=8,<9 between elastic-transport release and elasticsearch-py release
2+
elastic-transport @ git+https://github.com/elastic/elastic-transport-python
23
requests>=2, <3
34
aiohttp
45
pytest
@@ -28,4 +29,4 @@ protobuf<4; python_version<="3.7"
2829
# Override Read the Docs default (sphinx<2 and sphinx-rtd-theme<0.5)
2930
sphinx>2
3031
sphinx-rtd-theme>0.5
31-
sphinx-autodoc-typehints
32+
sphinx-autodoc-typehints

docs/examples/28d3bb1dbed615c6e719d50d48ab6fb4.asciidoc renamed to docs/examples/08f20902821a4f7a73ce7b959c5bdbdc.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resp = client.search(
1111
"flags": "ALL",
1212
"case_insensitive": True,
1313
"max_determinized_states": 10000,
14-
"rewrite": "constant_score",
14+
"rewrite": "constant_score_blended",
1515
}
1616
}
1717
}

docs/examples/13d90ba227131aefbf4fcfd5992e662a.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// query-dsl/bool-query.asciidoc:153
1+
// query-dsl/bool-query.asciidoc:156
22

33
[source, python]
44
----

docs/examples/178c920d5e8ec0071f77290fa059802c.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// indices/update-settings.asciidoc:122
1+
// indices/update-settings.asciidoc:132
22

33
[source, python]
44
----

docs/examples/1aa91d3d48140d6367b6cabca8737b8f.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/bulk.asciidoc:625
1+
// docs/bulk.asciidoc:634
22

33
[source, python]
44
----
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// cluster/allocation-explain.asciidoc:10
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.allocation_explain(
6+
body={
7+
"index": "my-index-000001",
8+
"shard": 0,
9+
"primary": False,
10+
"current_node": "my-node",
11+
},
12+
)
13+
print(resp)
14+
----

docs/examples/20005d8a6555b259b299d862cd218701.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// query-dsl/match-query.asciidoc:175
1+
// query-dsl/match-query.asciidoc:186
22

33
[source, python]
44
----
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// cluster/reroute.asciidoc:195
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.reroute(
6+
metric="none",
7+
body={
8+
"commands": [
9+
{
10+
"move": {
11+
"index": "test",
12+
"shard": 0,
13+
"from_node": "node1",
14+
"to_node": "node2",
15+
}
16+
},
17+
{
18+
"allocate_replica": {
19+
"index": "test",
20+
"shard": 1,
21+
"node": "node3",
22+
}
23+
},
24+
]
25+
},
26+
)
27+
print(resp)
28+
----

0 commit comments

Comments
 (0)