Skip to content

Commit f8c8dc0

Browse files
authored
Merge pull request #42 from stackhpc/readme-update
README update
2 parents 6bc45e4 + a560935 commit f8c8dc0

File tree

2 files changed

+59
-28
lines changed

2 files changed

+59
-28
lines changed

README.md

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ with a JSON payload of the form:
7979

8080
The currently supported reducers are `max`, `min`, `mean`, `sum`, `select` and `count`. All reducers return the result using the same datatype as specified in the request except for `count` which always returns the result as `int64`.
8181

82+
The proxy adds two custom headers `x-activestorage-dtype` and `x-activestrorage-shape` to the HTTP response to allow the numeric result to be reconstructed from the binary content of the response.
83+
8284
[//]: <> (TODO: No OpenAPI support yet).
8385
[//]: <> (For a running instance of the proxy server, the full OpenAPI specification is browsable as a web page at the `{proxy-address}/redoc/` endpoint or in raw JSON form at `{proxy-address}/openapi.json`.)
8486

@@ -92,12 +94,53 @@ In particular, the following are known limitations which we intend to address:
9294
* No support for missing data
9395
* No support for compressed or encrypted objects
9496

97+
## Running
98+
99+
There are various ways to run the S3 Active Storage server.
100+
101+
### Running in a container
102+
103+
The simplest method is to run it in a container using a pre-built image:
104+
105+
```sh
106+
docker run -it --detach --rm --net=host --name s3-active-storage ghcr.io/stackhpc/s3-active-storage-rs:latest
107+
```
108+
109+
Images are published to [GitHub Container Registry](https://github.com/stackhpc/s3-active-storage-rs/pkgs/container/s3-active-storage-rs) when the project is released.
110+
The `latest` tag corresponds to the most recent release, or you can use a specific release e.g. `0.1.0`.
111+
112+
This method does not require access to the source code.
113+
114+
### Building a container image
115+
116+
If you need to use unreleased changes, but still want to run in a container, it is possible to build an image.
117+
First, clone this repository:
118+
119+
```sh
120+
git clone https://github.com/stackhpc/s3-active-storage-rs.git
121+
cd s3-active-storage-rs
122+
```
123+
124+
```sh
125+
make build
126+
```
127+
128+
The image will be tagged as `s3-active-storage`.
129+
The image may be pushed to a registry, or deployed locally.
130+
131+
```sh
132+
make run
133+
```
134+
95135
## Build
96136

137+
If you prefer not to run the S3 Active Storage server in a container, it will be necessary to build a binary.
138+
Building locally may also be preferable during development to take advantage of incremental compilation.
139+
97140
### Prerequisites
98141

99142
This project is written in Rust, and as such requires a Rust toolchain to be installed in order to build it.
100-
The Minimum Supported Rust Version (MSRV) is 1.62.1, due to a dependency on the [AWS SDK](https://github.com/awslabs/aws-sdk-rust).
143+
The Minimum Supported Rust Version (MSRV) is 1.66.1, due to a dependency on the [AWS SDK](https://github.com/awslabs/aws-sdk-rust).
101144
It may be necessary to use [rustup](https://rustup.rs/) rather than the OS provided Rust toolchain to meet this requirement.
102145
See the [Rust book](https://doc.rust-lang.org/book/ch01-01-installation.html) for toolchain installation.
103146

@@ -125,7 +168,7 @@ cargo run --release
125168
Or installed to the system:
126169

127170
```sh
128-
cargo install
171+
cargo install --path . --locked
129172
```
130173

131174
Then run:
@@ -161,7 +204,7 @@ In a separate terminal, set up the Python virtualenv then upload some sample dat
161204

162205
```sh
163206
# Create a virtualenv
164-
python -m venv ./venv
207+
python3 -m venv ./venv
165208
# Activate the virtualenv
166209
source ./venv/bin/activate
167210
# Install dependencies
@@ -178,33 +221,22 @@ Proxy functionality can be tested using the [S3 active storage compliance suite]
178221

179222
Request authentication is implemented using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication) with the username and password consisting of your S3 Access Key ID and Secret Access Key, respectively. These credentials are then used internally to authenticate with the upstream S3 source using [standard AWS authentication methods](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html)
180223

181-
A request to an active storage proxy running on localhost with Minio as the S3 source is as simple as:
182-
183-
```python
184-
import json
185-
import numpy as np
186-
import requests
187-
188-
request_data = {
189-
'source': 'http://localhost:9000',
190-
'bucket': 'sample-data',
191-
'object': 'data-float32.dat',
192-
'dtype': 'float32',
193-
# All other fields assume their default values
194-
}
224+
A basic Python client is provided in `scripts/client.py`.
225+
First install dependencies in a Python virtual environment:
195226

196-
reducer = 'sum'
197-
response = requests.post(
198-
f'http://localhost:8000/v1/{reducer}',
199-
json=request_data,
200-
auth=('minioadmin', 'minioadmin')
201-
)
202-
shape = json.loads(response.headers['x-activestorage-shape'])
203-
sum_result = np.frombuffer(response.content, dtype=response.headers['x-activestorage-dtype'])
204-
sum_result = sum_result.reshape(shape)
227+
```sh
228+
# Create a virtualenv
229+
python3 -m venv ./venv
230+
# Activate the virtualenv
231+
source ./venv/bin/activate
232+
# Install dependencies
233+
pip install scripts/requirements.txt
205234
```
206235

207-
The proxy adds two custom headers `x-activestorage-dtype` and `x-activestrorage-shape` to the HTTP response to allow the numeric result to be reconstructed from the binary content of the response.
236+
Then use the client to make a request:
237+
```sh
238+
venv/bin/python ./scripts/client.py sum --server http://localhost:8080 --source http://localhost:9000 --username minioadmin --password minioadmin --bucket sample-data --object data-uint32.dat --dtype uint32
239+
```
208240

209241
---
210242

scripts/upload_sample_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def n_bytes(self):
2424
S3_URL = 'http://localhost:9000'
2525

2626
s3_fs = s3fs.S3FileSystem(key='minioadmin', secret='minioadmin', client_kwargs={'endpoint_url': S3_URL})
27-
data_dir = pathlib.Path('./testdata')
2827
bucket = pathlib.Path('sample-data')
2928

3029
#Make sure s3 bucket exists

0 commit comments

Comments
 (0)