Releases: aerospike/aerospike-client-python
11.1.0
New Features
- [CLIENT-2223] Add support for rack aware reads in an RF=3 deployment.
- [CLIENT-2288] aerospike.client(): add client config options "max_error_rate" and "error_rate_window".
- [CLIENT-2113] aerospike.client(): add min_conns_per_node support.
- [CLIENT-2119] Show type hints in code editor.
Bug Fixes
- [CLIENT-2159] Fix some memory leaks.
- [CLIENT-2278] batch_operate(): update ttl using batch write policy.
- [CLIENT-2286] aerospike.client(): fix client config batch policy not accepting "replica" value.
- [CLIENT-2229] Docs: aerospike_helpers.expressions.hll.HLLMayContain: fix return value description.
- [CLIENT-2269] Docs: fix some incorrect keyword arguments.
- [CLIENT-2255] Docs: aerospike_helpers.operations: batch operations can also accept operations.
- [CLIENT-1776] Docs: aerospike.client(): update some default client config values.
11.0.1
Breaking Changes
Revert adding base64 methods to aerospike module
These methods have been removed from the aerospike module due to memory errors when they are called:
aerospike.get_expression_base64()
aerospike.get_cdtctx_base64()
Course of action
Call these methods from a client instance instead of the aerospike
module. Assuming client
is an instance of aerospike.Client
, the above calls should be replaced by:
client.get_expression_base64()
client.get_cdtctx_base64()
Bug Fixes
- [CLIENT-2267] Revert adding base64 methods to aerospike module.
11.0.0
Breaking Changes
Batch methods: stop accepting a tuple of keys and bins
For the following functions:
client.get_many()
client.exists_many()
The keys
parameter no longer takes in a tuple of keys. It only takes in a list of keys.
In addition, client.select_many()
no longer takes in a tuple for the keys
and bins
parameters. Those parameters only take in a list of keys and bins, respectively.
Course of action:
Change code such as this:
keys = (("test", "demo", 1), ("test", "demo", 2))
bins = ("bin1", "bin2")
client.select_many(keys, bins)
...to this instead:
keys = [("test", "demo", 1), ("test", "demo", 2)]
bins = ["bin1", "bin2"]
client.select_many(keys, bins)
Expressions: add support for comparing KeyOrderedDicts (new server feature)
Before server 6.3, it is possible to compare maps in expressions if the maps were nested inside a list. For example, this code would work before server 6.3:
from aerospike_helpers.expressions import base as expr
client.put(key, {"bin": [{"a": 1}]})
exp = expr.Eq(expr.ListBin("bin"), [{"a": 1}]).compile()
record = client.get(key, {"expressions": exp})
print(record[2])
# {'bin': [{'a': 1}]}
This is now unsupported in server 6.3 because comparing unordered maps can potentially lead to inconsistent results. However, it is possible in server 6.3 to compare key-ordered maps in expressions.
Course of action:
For those using a server version < 6.3, no action is necessary. But it is recommended not to compare unordered maps in expressions.
For those upgrading to server 6.3, maps stored in the server must be key-ordered in order to be compared against in expressions. If the maps in the server are already key-ordered, and you would like to compare them in expressions, you must wrap any dictionaries in expressions with the KeyOrderedDict class.
For example, the code above must store the map as a key ordered map before comparing it in an expression:
from aerospike_helpers.expressions import base as expr
from aerospike import KeyOrderedDict
client.put(key, {"bin": [KeyOrderedDict({"a": 1})]})
exp = expr.Eq(expr.ListBin("bin"), [KeyOrderedDict({"a": 1})]).compile()
record = client.get(key, {"expressions": exp})
print(record[2])
# {'bin': [{'a': 1}]}
Return AEROSPIKE_ERR_NAMESPACE_NOT_FOUND instead of AEROSPIKE_ERR_CLIENT when a namespace cannot be found
Course of action:
Change code such as this:
from aerospike import exception as exc
key = ("nonexistent_namespace", "demo", 1)
try:
client.get(key)
except exc.ClientError:
print("Incorrect namespace")
...to this instead:
from aerospike import exception as exc
key = ("nonexistent_namespace", "demo", 1)
try:
client.get(key)
except exc.NamespaceNotFound:
print("Incorrect namespace")
Return last error code received when scan/query maxRetries is exceeded
When running a query or scan, if max_retries is exceeded, the transaction will return the last suberror that was received instead of a MaxRetriesExceeded error. For example, if you try to run a query on a non-indexed bin, the client will return an IndexNotFound error from the last attempt to query the bin.
This code will no longer work:
query = client.query("test", "demo")
query.select("bin_without_index")
query.where(p.equals("bin_without_index", 1))
def callback(input_tuple):
pass
try:
query.foreach(callback)
except exc.MaxRetriesExceeded:
print("Query failed")
Course of action:
When handling a MaxRetriesExceeded exception, change it to the exact error that is expected to get thrown during the last query attempt. In this case, it is an IndexNotFound error:
try:
query.foreach(callback)
except exc.IndexNotFound:
print("Query failed")
New Features
- [CLIENT-2176] Map operations: add support for MAP_ORDERED and MAP_UNORDERED return types.
- [CLIENT-2144] Expressions: add support for comparing KeyOrderedDicts.
- [CLIENT-2158] Add base64 API functions to aerospike module.
Improvements
- [CLIENT-701] Batch methods: stop accepting a tuple of keys and bins.
- [CLIENT-2197] Return AEROSPIKE_ERR_NAMESPACE_NOT_FOUND instead of AEROSPIKE_ERR_CLIENT when a namespace cannot be found.
- [CLIENT-2143] Return last error code received when scan/query maxRetries is exceeded.
- [CLIENT-2192] Add support for RHEL 9.
Bug Fixes
- [CLIENT-1749] Documentation: add missing map return type MAP_RETURN_EXISTS.
10.0.1
Bug Fixes
- [CLIENT-2157] - udf_put(): Stop hanging behavior when copying lua file to user path.
10.0.0
Important Note
- A bug affecting this version of the Python client has been identified. On ARM chipsets only, disk space may increase until out of space, we strongly recommend that you upgrade to Python client 10.0.1 at the earliest opportunity.
Breaking Changes
- get_cdtctx_base64(): take in context directly instead of a dictionary. See Incompatible API Changes for details.
Improvements
- [CLIENT-1612] - Support Python 3.10.
- [CLIENT-2090] - Support Python 3.11.
- [CLIENT-2114] - Add support for Alpine linux.
- [CLIENT-2047] - Add info policy to client config.
- [CLIENT-1989] - get_cdtctx_base64(): take in context directly instead of a dictionary.
Bug Fixes
- [CLIENT-2121] - query.apply(): make argument parameter optional.
9.0.0
Breaking Changes
- Change default send_bool_as constant to AS_BOOL. See Incompatible API Changes for details.
- batch_get_ops(): Remove meta field.
- scan_apply(): Report correct error value and message if scan wait fails.
Improvements
- [CLIENT-2074] - Change default send_bool_as constant to AS_BOOL.
- [CLIENT-2004] - Add missing bin type for server booleans.
- [CLIENT-2012] - scan_apply(): Report correct error value and message if scan wait fails.
Bug Fixes
- [CLIENT-2005] - Docs: add missing batch policy "respond_all_keys".
- [CLIENT-2075] - Docs: add missing batch policy "allow_inline_ssd".
- [CLIENT-2008] - batch_get_ops(): Remove meta field.
8.0.0
Improvements
- [CLIENT-1850] Support ARM64 and Mac M1 (#315)
Breaking Changes
- [CLIENT-1877] Remove support for Python 3.6 in version 8.0 (#306)
- [CLIENT-1854] Connect when calling client constructor and conditionally no-op connect() (#297)
- See more details below.
Bug Fixes
- [CLIENT-1849] Fix failing bitwise operations on M1 (#315)
- [CLIENT-1853] Add missing info policy parameter to job_info() in docs (#292)
- [CLIENT-1935] Add metadata ttl and gen fields for BatchRecord Read and Write (#321 and #316)
Development
- [CLIENT-1863] Build using pyproject.toml (#298)
- The build commands have changed. See more details below.
- [CLIENT-1939] Replace references of test/run script (#311)
- To run tests, run
python3 -m pytest new_tests
instead of./run
- To run tests, run
- [CLIENT-1857] Update test instructions and remove test/run script (#296)
- [CLIENT-1930] Remove unneeded commands from Github Actions test workflow (#309)
- [CLIENT-1876] Lint C wrapper code using Github actions (#305)
- [CLIENT-1843] Lint test code (#301)
- [CLIENT-1962] Split up github actions test workflow into multiple jobs
- Use flake8 config file instead of command line arguments (and update instructions)
- Run build, install, and integration tests on all supported Python versions
- Show preview of ReadTheDocs docs for PRs
Breaking Changes
[CLIENT-1854] Python client crashes while doing IO during server upgrade/downgrade (#297)
- Calling the
aerospike.Client
constructor establishes the connection.- If user authentication is required, pass in a username and password in the client configuration dictionary by using the keys
"username"
and"password"
.
- If user authentication is required, pass in a username and password in the client configuration dictionary by using the keys
aerospike.Client.connect()
only runs if the connection was closed by callingclose()
beforehand. Otherwise, usingconnect()
does nothing.
Before version 8.0.0:
config = {
'hosts': hosts,
'policies': {'auth_mode': aerospike.AUTH_INTERNAL},
}
client = aerospike.client(config)
client.connect(user, password)
At version 8.0.0:
config = {
'hosts': hosts,
'policies': {'auth_mode': aerospike.AUTH_INTERNAL},
'user': user,
'password': password
}
client = aerospike.client(config)
# following is no-op
client.connect(user, password)
Having the client connect to the server when the constructor is called makes the Python client's behavior more
consistent with our other clients, and it also removes the possibility of an application trying to perform server
operations with the client without a connection.
If you are using a try/except
block and have the constructor call outside of the try
block, move
the constructor call into the try
block. If an exception happens, it would be coming from the
constructor and not the connect() method.
This line of code:
client = aerospike.client(config).connect()
should not have an issue.
But code such as this:
client = aerospike.client(config)
try:
client.connect()
except Exception:
# eat exception and do something
Should be changed to this instead:
try:
client = aerospike.client(config)
except Exception:
# eat exception and do something
[CLIENT-1863] Build using pyproject.toml (#298)
The commands to build and install the client for developers has changed from:
python3 setup.py build --force
python3 setup.py install --force
to:
# pip install build
python3 -m build
pip install .
7.1.1
Python Client 7.1.1
date: 10/03/2022Bug Fixes:
- [CLIENT-1784] - Potential Memory leak with Python client.
Improvements:
- [CLIENT-1830] - Add CDT CTX base64 method for using sindex-create info command.
- [CLIENT-1825] - Expose ttl as part query object attributes.
7.1.0
Python Client 7.1.0
date: 09/09/2022Bug Fixes:
- [CLIENT-1810] - Read policy POLICY_KEY_SEND is not respected when set at the client level.
New Features:
- [CLIENT-1799] - Support batch read operations.
Improvements:
- [CLIENT-1749] - Add 'EXISTS' return type for CDT read operations.
- [CLIENT-1801] - Support creating an secondary index on elements within a CDT using context.
- [CLIENT-1795] - Make c-client "fail_if_not_connected" option configurable.
- [CLIENT-1791] - Review and clean up Sphinx documentation.
- [CLIENT-1792] - Update build instructions.
7.0.2
Python Client 7.0.2
date: 05/31/2022Bug Fixes:
- [CLIENT-1742] - Fix reference count leaks in client 7.x Batch APIs.
- [CLIENT-1753] - Fix reference count leak in cdt_ctx map_key_create and list_index_create cases.
- [CLIENT-1710] - Change BatchRecords default argument from an empty list to None.