Skip to content

Commit 9d79747

Browse files
authored
More updates to the OSB build (opensearch-project#635)
Signed-off-by: Govind Kamat <govkamat@amazon.com>
1 parent cc1f62b commit 9d79747

File tree

7 files changed

+67
-55
lines changed

7 files changed

+67
-55
lines changed

.ci/build.sh

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
#!/usr/bin/env bash
22

3-
pyenv_init() {
4-
PATH=$HOME/.pyenv/shims:$PATH:$HOME/.pyenv/bin
5-
}
6-
73
function setup {
8-
export THESPLOG_FILE="${THESPLOG_FILE:-${BENCHMARK_HOME}/.benchmark/logs/actor-system-internal.log}"
9-
# this value is in bytes, the default is 50kB. We increase it to 200kiB.
10-
export THESPLOG_FILE_MAXSIZE=${THESPLOG_FILE_MAXSIZE:-204800}
11-
# adjust the default log level from WARNING
12-
export THESPLOG_THRESHOLD="INFO"
4+
export BENCHMARK_HOME=$GITHUB_WORKSPACE
5+
6+
export THESPLOG_FILE=$BENCHMARK_HOME/.benchmark/logs/actor-system-internal.log
7+
export THESPLOG_FILE_MAXSIZE=204800 # default is 50 KiB
8+
export THESPLOG_THRESHOLD=INFO # default log level is WARNING
139

14-
pyenv_init
1510
export TERM=dumb
1611
export LC_ALL=en_US.UTF-8
12+
13+
# Init pyenv.
14+
PATH=$HOME/.pyenv/shims:$PATH:$HOME/.pyenv/bin
1715
}
1816

19-
function build {
17+
function build_and_unit_test {
2018
setup
2119

2220
set -e
23-
make install-devel
21+
make develop
2422
make lint
2523
make test
2624
}
2725

28-
function build_it {
26+
function run_it {
2927
setup
3028

31-
export BENCHMARK_HOME="$GITHUB_WORKSPACE"
32-
3329
docker pull ubuntu/squid:latest
3430

3531
# make it38, it39, etc. so they run as concurrent GHA jobs

.github/workflows/integ-test.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,4 @@ jobs:
4242
- run: echo "JAVA17_HOME=$JAVA_HOME" >> $GITHUB_ENV
4343

4444
- name: Run the CI build script
45-
run: bash .ci/build.sh build_it ${{ matrix.python-version }}
46-
env:
47-
BENCHMARK_HOME: env.GITHUB_WORKSPACE
45+
run: bash .ci/build.sh run_it ${{ matrix.python-version }}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Release drafter
1+
name: Publish Release to GitHub
22

33
on:
44
push:
55
tags:
66
- "*"
77

88
jobs:
9-
draft-a-release:
9+
publish-release:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout Repository
@@ -22,21 +22,20 @@ jobs:
2222
issue-title: 'Release opensearch-benchmark'
2323
issue-body: "Please approve or deny the release of opensearch-benchmark. **Tag**: ${{ github.ref_name }} **Commit**: ${{ github.sha }}"
2424
exclude-workflow-initiator-as-approver: true
25+
2526
- name: Set up Python 3
2627
uses: actions/setup-python@v3
2728
with:
2829
python-version: '3.x'
29-
- name: Install build tools
30-
run: |
31-
python -m pip install --upgrade build
30+
3231
- name: Build project for distribution
3332
run: |
34-
python -m build
35-
tar -zvcf artifacts.tar.gz dist
36-
- name: Release
33+
make build
34+
tar zcvf artifacts.tar.gz dist
35+
36+
- name: Publish release
3737
uses: softprops/action-gh-release@v1
3838
with:
3939
draft: true
4040
generate_release_notes: true
41-
files: |
42-
artifacts.tar.gz
41+
files: artifacts.tar.gz

.github/workflows/unit-test.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ jobs:
1717
run: git clone https://github.com/pyenv/pyenv.git ~/.pyenv
1818

1919
- name: Run the CI build script
20-
run: bash .ci/build.sh build
21-
env:
22-
BENCHMARK_HOME: env.GITHUB_WORKSPACE
20+
run: bash .ci/build.sh build_and_unit_test

DEVELOPER_GUIDE.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,29 @@ This document will walk you through on what's needed to start contributing code
2323

2424
### Prerequisites
2525

26-
- **Pyenv**: Install `pyenv` and follow the instructions in the output of `pyenv init` to set up your shell and restart it before proceeding.
27-
For more details please refer to the [PyEnv installation instructions](https://github.com/pyenv/pyenv#installation).
26+
- **pyenv**: Install `pyenv` and follow the instructions in the output of `pyenv init` to set up your shell and restart it before proceeding.
27+
For more details please refer to the [pyenv installation instructions](https://github.com/pyenv/pyenv#installation).
2828

29-
**Optional Step:** For Debian-based systems, install the following modules to continue with the next steps:
29+
`pyenv` requires that the C compiler and development libraries be installed, so that the specified Python versions can be build from source. The installation instructions vary from platform to platform.
30+
31+
For Debian-based systems, install the following modules to continue with the next steps:
3032
```
3133
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
3234
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
3335
xz-utils tk-dev libffi-dev liblzma-dev git
3436
```
3537
38+
For Amazon Linux 2023, run the following command:
39+
```
40+
sudo yum -y install gcc openssl-devel bzip2-devel libffi-devel ncurses-devel sqlite-devel readline-devel zlib-devel xz-devel
41+
```
42+
43+
On the Mac platform, XCode needs to be installed as well as some additional required libraries:
44+
```
45+
xcode-select --install
46+
brew install pyenv jq zlib xz
47+
```
48+
3649
- **JDK**: Although OSB is a Python application, it optionally builds and provisions OpenSearch clusters. JDK version 17 is used to build the current version of OpenSearch. Please refer to the [build setup requirements](https://github.com/opensearch-project/OpenSearch/blob/ca564fd04f5059cf9e3ce8aba442575afb3d99f1/DEVELOPER_GUIDE.md#install-prerequisites).
3750
Note that the `javadoc` executable should be available in the JDK installation. An earlier version of the JDK can be used, but not all the integration tests will pass.
3851
@@ -54,7 +67,7 @@ For those working on WSL2, it is recommended to clone the repository and set up
5467
After you git cloned the forked copy of OpenSearch Benchmark, use the following command-line instructions to set up OpenSearch Benchmark for development:
5568
```
5669
cd opensearch-benchmark
57-
make install-devel
70+
make develop
5871
```
5972
6073
Depending on the platform and shell you have, use the following command to activate the virtual environment:

Makefile

+20-14
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
# under the License.
1717

1818
SHELL = /bin/bash
19+
PYTHON = python3
1920
PIP = pip3
2021
VERSIONS = $(shell jq -r '.python_versions | .[]' .ci/variables.json | sed '$$d')
2122
VERSION38 = $(shell jq -r '.python_versions | .[]' .ci/variables.json | sed '$$d' | grep 3\.8)
2223
PYENV_ERROR = "\033[0;31mIMPORTANT\033[0m: Please install pyenv and run \033[0;31meval \"\$$(pyenv init -)\"\033[0m.\n"
2324

25+
all: develop
26+
2427
pyinst:
2528
@which pyenv > /dev/null 2>&1 || { printf $(PYENV_ERROR); exit 1; }
2629
@for i in $(VERSIONS); do pyenv install --skip-existing $$i; done
@@ -31,6 +34,10 @@ pyinst38:
3134
pyenv install --skip-existing $(VERSION38)
3235
pyenv local $(VERSION38)
3336

37+
check-pip:
38+
# Install pyenv if the Python environment is externally managed.
39+
@if ! $(PIP) > /dev/null 2>&1 || ! $(PIP) install pip > /dev/null 2>&1; then make pyinst38; fi
40+
3441
check-java:
3542
@if ! test "$(JAVA_HOME)" || ! java --version > /dev/null 2>&1 || ! javadoc --help > /dev/null 2>&1; then \
3643
echo "Java installation issues for running integration tests" >&2; \
@@ -40,23 +47,22 @@ check-java:
4047
echo "NOTE: Java version 17 required to have all integration tests pass" >&2; \
4148
fi
4249

43-
install-deps: pyinst38
44-
# @if test `uname` = Darwin -o `python3 --version | sed 's/.* 3.\([0-9]*\).*/3\1/'` -lt 38; then make pyinst38; fi
50+
install-deps: check-pip
4551
$(PIP) install --upgrade pip setuptools wheel
4652

47-
install-user: install-deps
48-
PIP_ONLY_BINARY=h5py $(PIP) install -e .
53+
# pylint does not work with Python versions >3.8:
54+
# Value 'Optional' is unsubscriptable (unsubscriptable-object)
55+
develop: pyinst38 install-deps
56+
PIP_ONLY_BINARY=h5py $(PIP) install -e .[develop]
4957

50-
install-devel: install-deps
51-
$(PIP) install -e .[develop]
52-
53-
wheel:
54-
$(PIP) install --upgrade pip setuptools wheel
55-
PIP_ONLY_BINARY=h5py $(PIP) wheel .
58+
build: install-deps
59+
$(PIP) install --upgrade build
60+
$(PYTHON) -m build
5661

57-
install: wheel
58-
PIP_ONLY_BINARY=h5py $(PIP) install opensearch_benchmark-*.whl
59-
rm -r *.whl *.egg-info
62+
# Builds a wheel from source, then installs it.
63+
install: build
64+
PIP_ONLY_BINARY=h5py $(PIP) install dist/opensearch_benchmark-*.whl
65+
rm -rf dist
6066

6167
clean:
6268
rm -rf .benchmarks .eggs .tox .benchmark_it .cache build dist *.egg-info logs junit-py*.xml *.whl NOTICE.txt
@@ -75,7 +81,7 @@ tox-env-clean:
7581
lint:
7682
@find osbenchmark benchmarks scripts tests it -name "*.py" -exec pylint -j0 -rn --load-plugins pylint_quotes --rcfile=$(CURDIR)/.pylintrc \{\} +
7783

78-
test:
84+
test: develop
7985
pytest tests/
8086

8187
it: pyinst check-java python-caches-clean tox-env-clean

docker/Dockerfile

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,41 @@
66
# Stage 1: build packages and compile where needed
77
#
88
FROM python:3.11.2-slim AS build-stage
9-
WORKDIR /opensearch-benchmark
109

1110
RUN apt-get -y update && \
1211
apt-get install -y curl git gcc pbzip2 pigz make jq && \
1312
apt-get -y upgrade
1413

1514
COPY . opensearch-benchmark
1615

17-
RUN cd opensearch-benchmark; make wheel
16+
# There is no binary package currently available for yappi on ARM.
17+
RUN cd opensearch-benchmark; \
18+
make build; \
19+
if test "`uname -m`" = aarch64; then pip wheel yappi && cp yappi-*.whl dist; fi
1820

1921

2022
#
2123
# Stage 2: create image
2224
#
2325
FROM python:3.11.2-slim AS image-stage
24-
WORKDIR /opensearch-benchmark
2526
ENV BENCHMARK_RUNNING_IN_DOCKER=True
2627

2728
RUN groupadd --gid 1000 opensearch-benchmark && \
2829
useradd -d /opensearch-benchmark -m -k /dev/null -g 1000 -N -u 1000 -l -s /bin/bash benchmark
2930

31+
WORKDIR /opensearch-benchmark
32+
3033
RUN mkdir -p /opensearch-benchmark/.benchmark && \
3134
chown -R 1000:0 /opensearch-benchmark/.benchmark
3235

33-
COPY --from=build-stage /opensearch-benchmark/opensearch-benchmark/yappi-*.whl /opensearch-benchmark/opensearch-benchmark/opensearch_benchmark-*.whl ./
36+
COPY --from=build-stage /opensearch-benchmark/dist/*.whl ./
3437

35-
# There is no binary package currently available for yappi on ARM.
3638
RUN set -ex; \
3739
apt-get -y update; \
3840
apt-get install -y git pbzip2; \
3941
apt-get -y upgrade; \
4042
rm -rf /var/lib/apt/lists/*; \
41-
PIP_ONLY_BINARY=h5py pip install yappi-*.whl opensearch_benchmark-*.whl; \
43+
PIP_ONLY_BINARY=h5py pip install *.whl; \
4244
rm *.whl
4345

4446
USER 1000

0 commit comments

Comments
 (0)