Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
19f9763
Move run_all_examples module from string_ops folder to top level exam…
juliannguyen4 Jul 10, 2026
a3daf28
Move Example class from examples.string_ops to examples package
juliannguyen4 Jul 13, 2026
de15810
Clean up Get() example using C# client's get() example as a reference…
juliannguyen4 Jul 14, 2026
82a0c1d
Move setup code for Get() class to a new base class fixture.
juliannguyen4 Jul 14, 2026
8912778
Close client connection after example code has finished running.
juliannguyen4 Jul 14, 2026
ef3a213
Fix invalid Python syntax. self should not be passed to super().__ini…
juliannguyen4 Jul 14, 2026
e3e3ec1
WIP
juliannguyen4 Jul 14, 2026
c9cf5fc
Remove more boilerplate code that has been handled in the base class
juliannguyen4 Jul 14, 2026
41c15b6
Finish removing all the boilerplate code that is handled in the paren…
juliannguyen4 Jul 14, 2026
cabc6c7
Reviewed all async examples and removed them since this client doesn'…
juliannguyen4 Jul 14, 2026
760b734
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Jul 16, 2026
660048b
Clean up more examples. TODO - looking at client big list
juliannguyen4 Jul 16, 2026
5f105e8
Get client_big_list.py to work again. TODO - need to decide whether t…
juliannguyen4 Jul 16, 2026
94e1ffc
Further cleanup of boilerplate. TODO - looking at multithreaded example
juliannguyen4 Jul 17, 2026
6ae77d5
More boilerplate removal...
juliannguyen4 Jul 17, 2026
38db3d5
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Jul 20, 2026
ebc537c
Finish first pass of converting all examples to use boilerplate class
juliannguyen4 Jul 20, 2026
85743a3
Further cleanup. Update all copyright notices in examples/client.
juliannguyen4 Jul 21, 2026
6ef6645
WIP on resolving import modules when importing each code example
juliannguyen4 Jul 21, 2026
8ed0dcd
WIP. Reduce nested ifs in info_all example.
juliannguyen4 Jul 22, 2026
66827c4
Clean up query code example.
juliannguyen4 Jul 22, 2026
fa048f7
more cleanup of TTL example.
juliannguyen4 Jul 23, 2026
c8004f7
run_all_examples.py now works. TODO - aggregate.py failing.
juliannguyen4 Jul 23, 2026
43e015d
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Jul 23, 2026
5461b69
Get all code examples to run successfully
juliannguyen4 Jul 24, 2026
ac205f5
Convert outdated select_many code example to batch_read.
juliannguyen4 Jul 24, 2026
fcfce76
Further WIP cleanup for ttl example. Add ability to run specific code…
juliannguyen4 Jul 27, 2026
2e58cc2
Finish up ttl code example changes
juliannguyen4 Jul 27, 2026
725717e
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Jul 27, 2026
d599c8c
Create subclass that injects udf_path into client config. Have UDF co…
juliannguyen4 Jul 27, 2026
b70e637
WIP on addressing TODO's left in PR
juliannguyen4 Jul 27, 2026
3ec81a3
Further cleanup and addressing of TODO's. Convert scan examples to qu…
juliannguyen4 Jul 27, 2026
84b8df7
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Jul 28, 2026
9109364
Address UDF not found errors by ensuring the user path is loaded prop…
juliannguyen4 Jul 28, 2026
3ed3933
UDFExample also needs to close the client connection...
juliannguyen4 Jul 28, 2026
85a87eb
Add missing super() commands or class won't be cleaned up / set up pr…
juliannguyen4 Jul 28, 2026
b42cac9
Also run string ops code examples (fixes regression). Makes sure exam…
juliannguyen4 Jul 29, 2026
a743542
Verified that all code examples that indirectly inherit from Example …
juliannguyen4 Jul 29, 2026
01cc035
Improve commenting.
juliannguyen4 Jul 29, 2026
cadb5d9
Prevent exception raised by __del__ due to record being deleted. Remo…
juliannguyen4 Jul 29, 2026
5ac4317
Clean up batch read example output.
juliannguyen4 Jul 29, 2026
60a8dad
Final review pass
juliannguyen4 Jul 29, 2026
1331327
update instructions on how to run examples.
juliannguyen4 Jul 29, 2026
1284764
Replace __del__ with cleanup method and call it explicitly in run_all…
juliannguyen4 Jul 29, 2026
9ebbb49
Make gha step easier to read
juliannguyen4 Jul 29, 2026
64b81ed
Clear up why we set additional config settings after running the server.
juliannguyen4 Jul 29, 2026
88a69ff
Move admin examples to examples/client for consistency. WIP on conver…
juliannguyen4 Jul 29, 2026
0b12ab3
Finish cleaning up admin examples.
juliannguyen4 Jul 29, 2026
472e6a1
Move AdminExample base class to client/admin subfolder since that's t…
juliannguyen4 Jul 29, 2026
be1aae3
Address runtime errors for admin tests
juliannguyen4 Jul 29, 2026
97359a3
Run non-EE code examples without logging in, and run admin code examp…
juliannguyen4 Jul 29, 2026
96887fd
For the EE code examples, only run with security enabled without TLS …
juliannguyen4 Jul 29, 2026
327d324
Make sure server config commands work with EE.
juliannguyen4 Jul 29, 2026
ac45dde
In order for admin user to change the server config dynamically, it m…
juliannguyen4 Jul 29, 2026
efbc4a3
Make sure server has time to finish creating role before cleanup step…
juliannguyen4 Jul 29, 2026
1dc8f96
Address CI failures by making sure user is created before being clean…
juliannguyen4 Jul 29, 2026
8939f1e
Add delay after every admin command that sends changes to server.
juliannguyen4 Jul 29, 2026
1fec48e
Remove Python 2 compatibility code.
juliannguyen4 Jul 29, 2026
a96007c
Remove deprecated code examples with APIs that were removed a long ti…
juliannguyen4 Jul 29, 2026
f2cb78c
nsup-period and default-ttl need to be configured only for the CE exa…
juliannguyen4 Jul 29, 2026
2202c24
TODO addressed
juliannguyen4 Jul 29, 2026
31ac410
Remove Python 2 comment.
juliannguyen4 Jul 29, 2026
eea2346
Address var naming for admin_query_user*_info. It's not just roles th…
juliannguyen4 Jul 29, 2026
e145b77
leave comment to optimize later. It doesn't matter though since it do…
juliannguyen4 Jul 30, 2026
eefda32
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Aug 4, 2026
b4f88bf
Merge remote-tracking branch 'origin/dev' into CLIENT-5049-convert-ex…
juliannguyen4 Aug 7, 2026
0312ada
Update copyright year for all remaining code examples in examples/cli…
juliannguyen4 Aug 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ jobs:
test: [
stubtest,
doctest,
code-examples
ce-code-examples,
ee-code-examples
]
fail-fast: false
needs: [
Expand Down Expand Up @@ -261,22 +262,33 @@ jobs:
- name: Install client
run: pip install ./*.whl

- if: ${{ matrix.test == 'doctest' || matrix.test == 'code-examples' }}
- if: ${{ matrix.test == 'doctest' || endsWith(matrix.test, 'code-examples') }}
uses: aerospike/shared-workflows/.github/actions/setup-aerospike-server@bd168dedaa4fc0b17a560541779d815540eded2d # v3.7.0
with:
num-nodes: 1
oidc-provider: ${{ vars.OIDC_PROVIDER_NAME }}
oidc-audience: ${{ vars.OIDC_AUDIENCE }}
server-tag: ${{ matrix.test == 'code-examples' && '8.1.3.0-35-20260629033923' || needs.get-env-vars.outputs.server-tag }}
server-container-repo: database-docker-virtual/aerospike-server
config-file: ./.github/workflows/aerospike-ce.conf

- if: ${{ matrix.test == 'code-examples' }}
# We cannot run this module with the cwd being string_ops
# Otherwise we will get relative import errors
# https://stackoverflow.com/a/47030746
run: python3 -m string_ops.run_all_examples
working-directory: examples
server-container-repo: database-docker-virtual/aerospike-server${{ matrix.test == 'ee-code-examples' && '-enterprise' || '' }}
config-file: ${{ (matrix.test == 'doctest' || matrix.test == 'ce-code-examples') && './.github/workflows/aerospike-ce.conf' || '' }}
enable-security: ${{ matrix.test == 'ee-code-examples' }}

- name: Run canonical code examples
if: ${{ endsWith(matrix.test, 'code-examples') }}
run: |
# This is required for the TTL code example
run_tools=(
docker run --rm --network host aerospike/aerospike-tools asinfo -v
)

if [[ ${{ matrix.test == 'ce-code-examples' }} == true ]]; then
"${run_tools[@]}" "set-config:context=namespace;id=test;nsup-period=1"
"${run_tools[@]}" "set-config:context=namespace;namespace=test;default-ttl=10S"
fi

python3 -m examples.run_all_examples "$SERVER_EDITION"
env:
SERVER_EDITION: ${{ matrix.test == 'ce-code-examples' && 'CE' || 'EE' }}

- name: Install test dependencies
if: ${{ matrix.test == 'doctest' }}
Expand Down
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ Examples

Example applications are provided in the `examples directory of the GitHub repository <https://github.com/aerospike/aerospike-client-python/tree/master/examples/client>`__

For examples, to run the ``kvs.py``:
For examples, to run all code examples:

::

python examples/client/kvs.py
python3 -m examples.run_all_examples

To run a specific code example from ``examples/client/kvs.py``:

python3 -m examples.run_all_examples KVS

Benchmarks
----------
Expand Down
65 changes: 65 additions & 0 deletions examples/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import aerospike
import os


class Example:
def __init__(
self,
host: str = "127.0.0.1",
port: int = 3000,
user: str = None,
password: str = None,
namespace: str = "test",
set_name: str = "demo",
extra_config: dict = {}
):
self.config = {
"hosts": [(host, port)],
"user": user,
"password": password
}
self.config |= extra_config
client = aerospike.client(self.config)

self.client = client
self.namespace = namespace
self.set_name = set_name
self.user_key = "docreadkey"
self.key = (self.namespace, self.set_name, self.user_key)
self.non_existent_key = (self.namespace, self.set_name, "nonexistent")
self.BIN_NAME = "a"

def cleanup(self):
self.client.close()

class UDFExample(Example):
def __init__(self):
extra_config = {
'lua': {
'user_path': os.path.dirname(__file__) + "/client/"
}
}
super().__init__(extra_config=extra_config)

class ExampleWithIndex(Example):
INDEX_NAME = "index_name"
def __init__(self):
super().__init__()

self.client.index_single_value_create(self.namespace, self.set_name, self.BIN_NAME, aerospike.INDEX_INTEGER, self.INDEX_NAME)

def cleanup(self):
self.client.index_remove(self.namespace, self.INDEX_NAME)

super().cleanup()

class ExampleWithRecord(Example):
def __init__(self):
super().__init__()

self.client.put(self.key, bins={self.BIN_NAME: 1})

def cleanup(self):
self.client.remove(self.key)

super().cleanup()
127 changes: 0 additions & 127 deletions examples/admin/change_password.py

This file was deleted.

119 changes: 0 additions & 119 deletions examples/admin/create_role.py

This file was deleted.

Loading
Loading